/// <summary> /// Adds new system to processing. /// </summary> /// <param name="system">System instance.</param> public EcsSystems Add(IEcsSystem system) { #if DEBUG if (system == null) { throw new ArgumentNullException(); } #endif EcsInjections.Inject(_world, system); var preInitSystem = system as IEcsPreInitSystem; if (preInitSystem != null) { _preInitSystems.Add(preInitSystem); } var initSystem = system as IEcsInitSystem; if (initSystem != null) { _initSystems.Add(initSystem); } var runSystem = system as IEcsRunSystem; if (runSystem != null) { if (_runSystemsCount == _runSystems.Length) { var newRunSystems = new IEcsRunSystem[_runSystemsCount << 1]; Array.Copy(_runSystems, 0, newRunSystems, 0, _runSystemsCount); _runSystems = newRunSystems; } _runSystems[_runSystemsCount++] = runSystem; } return(this); }
/// <summary> /// Gets all run systems. /// </summary> /// <param name="list">List to put results in it. If null - will be created.</param> /// <returns>Amount of systems in list.</returns> public int GetRunSystems(ref IEcsRunSystem[] list) { if (list == null || list.Length < _runSystemsCount) { list = new IEcsRunSystem[_runSystemsCount]; } Array.Copy(_runSystems, 0, list, 0, _runSystemsCount); return(_runSystemsCount); }
public int GetRunSystems(ref IEcsRunSystem[] list) { var itemsCount = _runSystemsCount; if (itemsCount == 0) { return(0); } if (list == null || list.Length < itemsCount) { list = new IEcsRunSystem[_runSystems.Length]; } for (int i = 0, iMax = itemsCount; i < iMax; i++) { list[i] = _runSystems[i]; } return(itemsCount); }
public void AddUpdateSystem(IEcsRunSystem system) { updateSystems.Add(system); }