protected override void OnUpdate() { Entities.WithAll <Simulate, MainSimulationStateComponent>().ForEach((Entity entity) => { inputSystem.Update(); selectionSystem.Update(); if (CurrentGameTurn % GAME_TURNS_REQUIRED_FOR_LOCKSTEP_TURN == 0 && CurrentGameTurn != lastGameTurnWhereLockstepWasOpen || !lockstepIsOpen) { lockstepIsOpen = LockstepCheckSystem.AllCheksOfTurnAreRecieved(CurrentLockstepTurn); if (lockstepIsOpen) { lockstepSystemGroup.Update(); lastGameTurnWhereLockstepWasOpen = CurrentGameTurn; CurrentLockstepTurn++; } } if (!lockstepIsOpen) { return; } Fix64 deltaTime = (Fix64)Time.deltaTime; SimulationTime += deltaTime; UnprocessedTime += deltaTime; if (SimulationDeltaTime <= UnprocessedTime) { blockMovementSystem.Update(); onGroupCheckSystem.Update(); updateReachableHexListSystem.Update(); resourceSourceManagerSystem.Update(); triggerGatherSystem.Update(); dropPointSystem.Update(); triggerUpdateResBufferSystem.Update(); updateResourceBufferSystem.Update(); updateOcupationMapSystem.Update(); updateDestinationSystem.Update(); sightSystem.Update(); pathRefreshSystem.Update(); pathFindingSystem.Update(); pathChangeIndexSystem.Update(); findPosibleTargetsSystem.Update(); findActionTargetSystem.Update(); findMovementTargetSystem.Update(); steeringSystem.Update(); translationSystem.Update(); movementFinisherSystem.Update(); //collisions systems collisionSystem.Update(); directionSystem.Update(); //all the action systems. startActSystem.Update(); removeReceivingActComponentsSystem.Update(); initReceivingActComponentsSystem.Update(); attackSystem.Update(); receiveDamageSystem.Update(); gatherSystem.Update(); extractResourceSystem.Update(); updateGathererAmmountSystem.Update(); endActionSystem.Update(); resourceSystem.Update(); deathSystem.Update(); //simulationSystemGroup.Update(); //lateSimulationSystemGroup.Update(); //applicationSystemGroup.Update(); UnprocessedTime -= SimulationDeltaTime; CurrentGameTurn++; } }); Entities.WithAll <Simulate>().WithNone <MainSimulationStateComponent>().ForEach((Entity entity) => { EntityManager.AddComponent <MainSimulationStateComponent>(entity); }); Entities.WithNone <Simulate>().WithAll <MainSimulationStateComponent>().ForEach((Entity entity) => { ResetState(); EntityManager.RemoveComponent <MainSimulationStateComponent>(entity); }); // have elapsed enought game ticks for another lockstep check and // the last turn that the the lockstep had been checked is not the current one or the lockstep is closed? // yes)assignate if the lockstep is open or closed // // the lockstep is open? // yes) execute lockstep system group // no) return // // add delta time to simulation time and not processed time // not processed time is greater than the time required for a game turn // yes) execute a simulation turn // no) return }