Common Mistakes - GoldhawkInteractive/X2-Modding GitHub Wiki
Faults in the framework, design or the programmer using the framework; all issues found while using Artitas:
The following pattern:
var group = World.FindGroup<T>();
group.Clear();
is a bug, as you are just clearing a set without removing the Group Components from the Entities in this Group.
The correct solution is:
World.ClearGroup<T>();
*) Noted as an open issue to address.
Ideally we re-use Components
where appropriate. An example of this a NameComponent
containing a single string.
It can be used on all types of entities to indicate the actual name. Refrain from creating or naming Component
such that they are tied to the type of Entity
you are using. E.g.: EnemyNameComponent
or HeroNameComponent
.
(Debatable)
All<>
on the Archetype tends to indicate the components that are required at construction of an Archetype.
If Components
get added by Systems
later on, you can indicate their usage through Any<>
. This primarily goes for components which have their entire lifecycle governed by a System. An example being .components involved in Overwatch to keep track of state.
Per example, if a System adds in components to handle specific logic, it should be the one to handle cleaning up those components. This way Systems can be cleanly added and removed from Worlds to quickly switch core gamelogic.
E.g.: if an entity gets deleted or killed (status-change) the System responsible for adding the Component should remove it / clean it up.
If an entity requires a specific structure, require the link that denotes this structure, or use a component to indicate that the structure is properly setup.
E.g.: A combatant is only valid if it has an Inventory of Slot-entities.