Exemplo n.º 1
0
        /// <summary>
        /// Removes the component from the entity.
        /// </summary>
        /// <param name="type">The type of the entity.</param>
        public void RemoveComponent(Type type)
        {
            var cmp = components[type];

            if (cmp == null)
            {
                return;
            }

            if (cmp.GetType().IsSubclassOf(typeof(Behavior)))
            {
                var behavior = cmp as Behavior;
                behaviorManager.RemoveBehavior(behavior);
            }

            if (cmp.GetType().IsSubclassOf(typeof(Drawable)))
            {
                var drawable = cmp as Drawable;
                renderManager.RemoveDrawable(drawable);
            }

            ComponentRemoved?.Invoke(this, new ComponentEventArgs(cmp));
            components.Remove(type);
        }