Пример #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();
        }