private static void AddComponent <TComponent>(this Entity entity, TComponent component) where TComponent : Component { if (EntityExists(entity)) { ApiProvider.AddComponentToScene(entity, component); components.Set(entity.Index, entity.Gen, component); } }
public static Component?AddComponent(this Entity entity, Type componentType) { if (IsComponent(componentType) && EntityExists(entity)) { Component?c = ApiProvider.AddComponentToScene(entity, componentType); if (c == null) { throw new SynthesisException($"Failed to add component of type {componentType.FullName} to entity"); } components.Set(entity.Index, entity.Gen, c); return(c); } return(null); }