if my child holds only values that is getting access in another class should i make the child class struct or a class
would it hurt or help performance?.
what the code might look like
skills{//child class
string skillname;
string skilldesc;
int stateffect1;
int stateffect2;
int stateffect3;
texture2d image;
int something[];
}
mainclass{
skills[] listofskills;
}
Firstly, be careful with the word “baseclass” because it means a class that another class is extending. Looking at your pseudo code it doesn’t look like that’s what you are doing
The main benefit of a struct is that it’s easy on the garbage collector.
The main disadvantage of it is that whenever you assign it or pass it as a parameter, it gets “copied”, which (depending on the “weight” of the struct) can get heavier than passing/assigning a class.
I’d say those are the most important points to consider.
If skills is something that you have a lot of or you create them constantly in the Update method or in loops etc. then using a struct might be good.
If skills is something that is stored for a longer time and passed around in your code, Class is a better option.
Looking at the variable names and imagining what skills could be used for, I’d probably make it Class.