public virtual void Add(ISystem aSystem, int aPriority = 0) { if (IsLocked) { _pending.Add(new KeyValuePair <AntPriorityPair <ISystem>, PendingChange>(new AntPriorityPair <ISystem>(aSystem, aPriority), PendingChange.Add)); } else { _systems.Add(new AntPriorityPair <ISystem>(aSystem, aPriority)); _systems = _systems.OrderBy(x => x.Priority).ToList(); var initializeSystem = aSystem as IInitializeSystem; if (initializeSystem != null) { _initializeSystems.Add(new AntPriorityPair <IInitializeSystem>(initializeSystem, aPriority)); _initializeSystems = _initializeSystems.OrderBy(x => x.Priority).ToList(); } var deinitializeSystem = aSystem as IDeinitializeSystem; if (deinitializeSystem != null) { _deinitializeSystems.Add(new AntPriorityPair <IDeinitializeSystem>(deinitializeSystem, aPriority)); _deinitializeSystems = _deinitializeSystems.OrderBy(x => x.Priority).ToList(); } var disableSystem = aSystem as IDisableSystem; if (disableSystem != null) { _disableSystems.Add(new AntPriorityPair <IDisableSystem>(disableSystem, aPriority)); _disableSystems = _disableSystems.OrderBy(x => x.Priority).ToList(); } var enableSystem = aSystem as IEnableSystem; if (enableSystem != null) { _enableSystems.Add(new AntPriorityPair <IEnableSystem>(enableSystem, aPriority)); _enableSystems = _enableSystems.OrderBy(x => x.Priority).ToList(); } var executeSystem = aSystem as IExecuteSystem; if (executeSystem != null) { _executeSystems.Add(new AntPriorityPair <IExecuteSystem>(executeSystem, aPriority)); _executeSystems = _executeSystems.OrderBy(x => x.Priority).ToList(); } var cleanupSystem = aSystem as ICleanupSystem; if (cleanupSystem != null) { _cleanupSystems.Add(new AntPriorityPair <ICleanupSystem>(cleanupSystem, aPriority)); _cleanupSystems = _cleanupSystems.OrderBy(x => x.Priority).ToList(); } aSystem.AddedToEngine(_engine); } }
public void AddSystem(ISystem aSystem, int aPriority) { aSystem.Priority = aPriority; if (!IsLocked) { _systems.Add(new AntSystemPriority(aSystem, aPriority)); _systems = _systems.OrderBy(sys => sys.Priority).ToList(); aSystem.Engine = this; aSystem.AddedToEngine(this); } else { _pending.Add(new KeyValuePair <ISystem, PendingChange>(aSystem, PendingChange.Add)); } }
public void AddSystem(ISystem system, int priority) { _systems.Add(new SystemPriorityPair(system, priority)); _systems = _systems.OrderBy(s => s.Priority).ToList(); system.AddedToEngine(this); }