/// <summary> /// Add a component to the given entity. /// If the component's type does not already exist, /// add it to the bag of available component types. /// </summary> /// <typeparam name="T">Component type you want to add.</typeparam> /// <param name="entity">The entity to which you want to add the component.</param> /// <param name="component">The component instance you want to add.</param> internal void AddComponent <T>(Entity entity, IEntityComponent component) where T : IEntityComponent { Debug.Assert(entity != null, "Entity must not be null."); Debug.Assert(component != null, "Component must not be null."); ComponentType type = ComponentTypeManager.GetTypeFor <T>(); AddComponent(entity, component, type); }
/// <summary> /// Appends the types. /// </summary> /// <param name="builder">The builder.</param> /// <param name="headerMessage">The header message.</param> /// <param name="typeBits">The type bits.</param> private static void AppendTypes(StringBuilder builder, string headerMessage, BigInteger typeBits) { if (typeBits != 0) { builder.AppendLine(headerMessage); foreach (Type type in ComponentTypeManager.GetTypesFromBits(typeBits)) { builder.Append(", "); builder.AppendLine(type.Name); } } }
/// <summary> /// Marks the component to remove. The actual removal is deferred and will happen in the next EntityWorld update. /// Faster removal of components from a entity. /// </summary> /// <param name="componentType">The type.</param> public void RemoveComponent(Type componentType) { this.entityManager.RemoveComponent(this, ComponentTypeManager.GetTypeFor(componentType)); }
/// <summary> /// Marks the component to remove. The actual removal is deferred and will happen in the next EntityWorld update. /// </summary> /// <typeparam name="T">Component Type.</typeparam> public void RemoveComponent <T>() where T : IEntityComponent { this.entityManager.RemoveComponent(this, ComponentTypeManager.GetTypeFor <T>()); }
/// <summary> /// Checks whether the given component can be reset. /// </summary> /// <param name="componentType">Type of the component.</param> public bool CanReset(Type componentType) { return(this.entityManager.CanReset(this, ComponentTypeManager.GetTypeFor(componentType))); }