示例#1
0
        public bool RemoveComponent(GameObjectComponent component, bool Destroy = true)  //Remove a component from a gameobject
        {
            if (component == null)
            {
                return(false);
            }

            bool FoundComp = GameObjectComponents.Remove(component);

            if (Destroy && FoundComp)
            {
                component.Destroy();
            }

            return(FoundComp);
        }
示例#2
0
        public bool AddComponent_Generic(GameObjectComponent component)  //Add a component to a gameobject
        {
            bool CanBeAdded = false;

            foreach (Type type in CanBeAddedMultipleTimes)
            {
                if (type == component.GetType())
                {
                    CanBeAdded = true;
                    break;
                }
            }

            if (GameObjectComponents.Find(Item => Item.GetType() == component.GetType()) == null || CanBeAdded)
            {
                component.gameObject = this;
                GameObjectComponents.Insert(GameObjectComponents.Count, component);

                return(true);
            }

            return(false);
        }
示例#3
0
 private T ConvertGOC <T>(GameObjectComponent GOC) where T : GameObjectComponent
 {
     return(GOC as T);
 }