Пример #1
0
        public void AddComponent(GameObjectComponent component)
        {
            if (component.IsUnique)
            {
                if (components.Find(c => c.GetType() == component.GetType()) != null)
                {
                    throw new ArgumentException("Cant add another unique component.");
                }
            }

            if (components.Contains(component))
            {
                return;
            }

            ValidateComponent(component);

            components.Add(component);

            ComponentAdded(this, new ComponentAddedEventArgs(component));

            components.OrderAllItemsListBy(c => c.UpdateOrder);

            sortedDrawableComponents = components
                                       .Items()
                                       .OrderBy(c => c.DrawOrder)
                                       .ToList();
        }
Пример #2
0
        /// <summary>
        /// Poistaa behaviourin.
        /// </summary>
        public bool RemoveBehaviour(string name)
        {
            Behaviour behaviour = behaviours.Find(b => b.Name == name);

            if (behaviour == null)
            {
                return(false);
            }

            behaviours.Remove(behaviour);

            return(true);
        }