Exemple #1
0
    public void Isolated_When_TheLockstepCheckPasses_Then_TheLocksOfThatTurnAreDeleted()
    {
        //SETUP
        World world = new World("Test World");
        //DefaultWorldInitialization.Initialize("Test World", editorWorld: false);

        var checkSystem = world.GetOrCreateSystem <LockstepCheckSystem>();

        Entity e1 = world.EntityManager.CreateEntity(typeof(LockstepCkeck));
        Entity e2 = world.EntityManager.CreateEntity(typeof(LockstepCkeck));

        world.EntityManager.SetComponentData(e1, new LockstepCkeck()
        {
            Turn = 4, Type = LockstepCheckType.COMMAND
        });
        world.EntityManager.SetComponentData(e2, new LockstepCkeck()
        {
            Turn = 4, Type = LockstepCheckType.CONFIRMATION
        });

        //ACTION
        checkSystem.Update();
        LockstepCheckSystem.AllCheksOfTurnAreRecieved(4);

        //ASSERT
        Assert.IsFalse(LockstepCheckSystem.AllCheksOfTurnAreRecieved(4));



        World.DisposeAllWorlds();
    }
Exemple #2
0
    public void Isolated_When_OffLineMode_Then_TheLocksetCheckAllwaysPasses()
    {
        //ACTION
        OfflineMode.SetOffLineMode(true);

        //ASSERT
        Assert.IsTrue(LockstepCheckSystem.AllCheksOfTurnAreRecieved(4));
        Assert.IsTrue(LockstepCheckSystem.AllCheksOfTurnAreRecieved(499));
        Assert.IsTrue(LockstepCheckSystem.AllCheksOfTurnAreRecieved(41));
        Assert.IsTrue(LockstepCheckSystem.AllCheksOfTurnAreRecieved(0));


        World.DisposeAllWorlds();
    }
Exemple #3
0
    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
    }