Пример #1
0
        /// <summary>Check if a component on a given entity can reset.</summary>
        /// <param name="entity">The entity for which you want to get the component</param>
        /// <param name="componentType">The desired component type</param>
        internal bool CanReset(Entity entity, ComponentType componentType)
        {
            Debug.Assert(entity != null, "Entity must not be null.");
            Debug.Assert(componentType != null, "Component type must not be null.");

            IResettableComponent component = GetComponent(entity, componentType) as IResettableComponent;

            if (component != null)
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        /// <summary>Resets the component of the given component type for the given entity by overwriting it with
        /// a new one.</summary>
        /// <param name="entity">The entity for which you want to get the component</param>
        /// <param name="componentType">The desired component type</param>
        /// <param name="args">The initialize parameters</param>
        internal void ResetComponent(
            Entity entity,
            ComponentType componentType,
            params object[] args)
        {
            Debug.Assert(entity != null, "Entity must not be null.");
            Debug.Assert(componentType != null, "Component type must not be null.");

            IResettableComponent component =
                GetComponent(entity, componentType) as IResettableComponent;

            if (component != null)
            {
                component.Reset(args);
            }
        }