Re: Sunday, April 23, 2017
Posted: Wed Apr 26, 2017 12:45 pm
Josh, you have a beautiful entity system.
Just make thrusters a sub-class of entities, inherit the current system, add the extra code you need. Done.
By your own admission, they aren't exactly uncommon, so a unique class for them has no real penalty.
*OR* make a single 0.0-1.0 float for all entities, call it activationLevel or something, and for non-thrusters use it in any number of ways, possibly armor damage/dirtiness levels, or shield brightness on the part (higher after being hit more recently)
Thrusters just use that single float then for their thrust level.
(This way gives modders more options )
Doing it this way is far faster, and more elegant than trying to solve a general case for a thing that ISN'T a general case.
Actually thinking about it, do it as an inherited class, entityWithAnExtraFloat.
Then you can choose to have that float or not. :V
For entity, when calling that float's variable name just have it default to 0. Then you don't have to treat either any differently.
Just make thrusters a sub-class of entities, inherit the current system, add the extra code you need. Done.
By your own admission, they aren't exactly uncommon, so a unique class for them has no real penalty.
*OR* make a single 0.0-1.0 float for all entities, call it activationLevel or something, and for non-thrusters use it in any number of ways, possibly armor damage/dirtiness levels, or shield brightness on the part (higher after being hit more recently)
Thrusters just use that single float then for their thrust level.
(This way gives modders more options )
Doing it this way is far faster, and more elegant than trying to solve a general case for a thing that ISN'T a general case.
Actually thinking about it, do it as an inherited class, entityWithAnExtraFloat.
Then you can choose to have that float or not. :V
For entity, when calling that float's variable name just have it default to 0. Then you don't have to treat either any differently.