-
i need dynamic Descriptor so that our design team configure some attribute/behaviors and create Descriptor based on it On run time, cuz i cant delete added component when entity destroyed the added component will not be deleted |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Svelto.ECS doesn't allow adding/removing components AFTER an entity is built, but you can add dynamically components to an entity descriptor before the entity is built. EntityInitializer BuildEntity<T>(uint entityID, ExclusiveBuildGroup groupStructId, T descriptorEntity,
IEnumerable<object> implementors = null,
[System.Runtime.CompilerServices.CallerMemberName] string caller = null) where T : IEntityDescriptor; if (condition)
{
_componentBuildersCacheList.Add(new ComponentBuilder<extracomponent>());
}
return new DynamicEntityDescriptor< BaseEntityDescriptor >(_componentBuildersCacheList); DynamicEntityDescriptor generic parameter is the "Base" descriptor that you will use for Swap and Remove operations. The extra dynamic components are either added through the list passed by the parameter or through the public DynamicEntityDescriptor methods like Add |
Beta Was this translation helpful? Give feedback.
Svelto.ECS doesn't allow adding/removing components AFTER an entity is built, but you can add dynamically components to an entity descriptor before the entity is built.
The components added dynamically will be regularly swapped / removed like static components. In order to achieve this, you need to use
DynamicEntityDescriptor
and a specific BuildEntityOverload: