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(); }
/// <summary> /// Lisää uuden behaviourin. /// </summary> public bool AddBehaviour(string name, object[] args = null) { Behaviour behaviour = game.CreateBehaviour(name, this, args); if (behaviour != null) { behaviours.Add(behaviour); } else { // TODO: log warning. } return(behaviour != null); }