Beside the usual mistakes i made when designe my game logic i often want a Not (Entity does not have EntityComponent) filter. The question is if that is again a hint of a bad design, and if yes, how to ship around.
Usecase:
[java]
WeaponSystem:
TargetVector{
Vector3f target;
}
Systems i would like to have:
RotateEntityToTarget{
ComponentsRequired: someComponents,TargetVector.class
}
This is working as expected.
Not having a component is not a valid āstateā for a system. It would collect every entity in the whole universe whether you really wanted to or not. I mean, presumably you are detecting on some other set of components and I wonder why that isnāt enough.
In your example, what if you someday decide to have other positions other than targeting and rest? Now you need to go hunt down all of the cases that are fighting you because you sucked in the whole world. Seems like maybe you are missing a component rather than trying to detect a ānotā.
Taking a step back even further, TargetVector and RestPosition might even be too specific. One Facing component could cover every entity that ever needed to look in any direction. Whether facing is āto a targetā or āto restā is a matter of game logic. Maybe you have some entity that wants to keep looking in its target direction after the target goes away. A Facing component covers this case also⦠since the only way you get to rest is through some game logic that sets Facing to a rest orientation. It could choose not to.
Looking at it another way, exactly what is it targeting and why? Thatās the missing piece⦠the system that decides to target something and untarget it.
Ok, after thinking about it during the work afternoon i think i found my concept issue. My goal actually was to have something like a default behaviour if nothing special is specified. And it seems that is not possible actually.
@zzuegg said:
Ok, after thinking about it during the work afternoon i think i found my concept issue. My goal actually was to have something like a default behaviour if nothing special is specified. And it seems that is not possible actually.
Well, the default behavior could be applied by the thing that notices that the object was removed from some entity set.
Alternately, the default behavior is still indicated by a component. Iād have to know more about your use-case to comment better⦠like all āactorsā involved in these components (producing and consuming).