#Best practice for adding additional modular data?

1 messages · Page 1 of 1 (latest)

vague phoenix
#

I'm not sure if that title made much sense or not.. I want to add a new mechanic to my game, let's call this heat, that will be an additional value that some entities have which will cause a death event for whatever entity after reaching a threshold.

For adding to this heat value, is it best practise to have other systems, such as movement and shooting systems, to add to this heat data, or instead do I make a separate heat system that will check if an entity is moving or shooting, then add heat..?

I want to do it separately but I feel like that will create a bunch of extra overhead.

snow forge
#

As long as the new data isn't meant to be processed by other systems, then those systems won't take it into account. The basics of ECS systems are they only use and modify things they actually need, for a specific feature.

#

Why does your heat data have anything to do with movement and shooting systems? After heat, will you have something else, like stunned?

#

Those are not my question for you, but the questions you have to answer for yourself.

#

To make things modular you have to break features down into pieces of logic and find a way to generalize them so that whenever you're going to add more things, you won't have to change the existing ones.

#

For example, if "heat" and "stunned" affect movement, could you model them into some data that is far more generalized? So that whenever you introduce something new that can affect movement too, you don't have to modify the movement system again.

vague phoenix
#

something like... heat is influenced by something, but not the other way around

snow forge
#

We can't never avoid modifying existing code though. For example if there is a new mechanism that requires new kind of data never produced by old systems, then we have to modify them.