How do you avoid one big data structure containing all the current world state ?
Let's pretend we're in a real-time strategy game, how would you code a skill that decrease mana of units around it ?
With a world state it would look like that :
class MySpell : ISkillWithoutTarget
{
void Cast(Unit caster, World world)
{
foreach (Unit target in world.Units)
{
if (target.distanceWith(caster) <= N)
{
target.Mana -= X;
}
}
}
}
So my question is : Does a good alternative to "world object" exist ? Or world object is the best way to deal with these kind of interactions ?
I'm not looking for a way to organize/optimize my big data structure, but how to avoid it. I would prefer not using this architecture because almost every piece of code can touch every game object. I'm looking for decoupling to avoid ending with bug almost untraceable.