protected override void OnCreate()
        {
            base.OnCreate();

            _simWorldSystem = World.GetOrCreateSystem <SimulationWorldSystem>();
            _simWorldSystem.SimWorldAccessor.SubmitSystem = this;
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            _simulationWorldSystem = World.GetOrCreateSystem <SimulationWorldSystem>();
            _tickSystem            = World.GetOrCreateSystem <TickSimulationSystem>();
        }
Example #3
0
        protected override void OnCreate()
        {
            base.OnCreate();

            _session = OnlineService.ServerInterface.SessionServerInterface;
            _session.RegisterNetMessageReceiver <NetMessageRequestSimSync>(OnSimSyncRequest);

            _simWorldSystem      = World.GetOrCreateSystem <SimulationWorldSystem>();
            _tickSystem          = World.GetOrCreateSystem <TickSimulationSystem>();
            _constructTickSystem = World.GetOrCreateSystem <ConstructSimulationTickSystem>();
        }
Example #4
0
        protected override void OnCreate()
        {
            base.OnCreate();

            _session = OnlineService.ClientInterface.SessionClientInterface;

            _tickSystem        = World.GetOrCreateSystem <TickSimulationSystem>();
            _simWorldSystem    = World.GetOrCreateSystem <SimulationWorldSystem>();
            _receiveTickSystem = World.GetOrCreateSystem <ReceiveSimulationTickSystem>();

            _requestSync = true;
        }
Example #5
0
        // !! CONSIDER SPLITING THIS SYSTEM IN TWO (one for load, one for save)!!

        protected override void OnCreate()
        {
            base.OnCreate();

#if DEBUG
            s_commandInstance = this;
            GameConsole.SetCommandOrVarEnabled("Sim.SaveToMemory", true);
            GameConsole.SetCommandOrVarEnabled("Sim.SaveToFile", true);
            GameConsole.SetCommandOrVarEnabled("Sim.LoadFromMemory", true);
            GameConsole.SetCommandOrVarEnabled("Sim.LoadFromFile", true);
#endif

            _simulationWorldSystem = World.GetOrCreateSystem <SimulationWorldSystem>();
            _tickSystem            = World.GetOrCreateSystem <TickSimulationSystem>();
        }
Example #6
0
        public void Initialize(SessionInterface sessionInterface, ConstructSimulationTickSystem.ValidationDelegate simInputValidationMethod)
        {
            if (IsInitialized)
            {
                throw new Exception($"{nameof(SimulationControlSystemGroup)} is already initialized");
            }

            IsInitialized = true;

            switch (sessionInterface)
            {
            case SessionClientInterface _:     // Client
                IsClient = true;
                IsLocal  = false;
                IsServer = false;
                break;

            case null:     // Local play
                IsClient = false;
                IsLocal  = true;
                IsServer = false;
                break;

            case SessionServerInterface _:      // Server
                IsClient = false;
                IsLocal  = false;
                IsServer = true;
                break;
            }

            _simulationWorldSystem = World.GetOrCreateSystem <SimulationWorldSystem>();
            _simulationWorldSystem.ClearSimWorld();
            _simulationWorldSystem.ReadyForEntityInjections = true;
            World.GetOrCreateSystem <ViewSystemGroup>().Initialize(this);

            ManualCreateAndAddSystem <SubmitSimulationInputSystem>();
            ManualCreateAndAddSystem <LoadSimulationSceneSystem>();
            ManualCreateAndAddSystem <SaveAndLoadSimulationSystem>();
            ManualCreateAndAddSystem <ChecksumSystem>();

            if (IsMaster)
            {
                ManualCreateAndAddSystem <ConstructSimulationTickSystem>().ValidationMethod = simInputValidationMethod;
            }

            if (IsClient)
            {
                ManualCreateAndAddSystem <ReceiveSimulationSyncSystem>();
                ManualCreateAndAddSystem <ReceiveSimulationTickSystem>();
            }

            if (IsServer)
            {
                ManualCreateAndAddSystem <SendSimulationSyncSystem>();
                ManualCreateAndAddSystem <SendSimulationTickSystem>();
                ManualCreateAndAddSystem <ReceiveSimulationInputSystem>();
            }
            ManualCreateAndAddSystem <RequestChecksumSystem>();    // todo: move back to server


#if UNITY_EDITOR
            // This is a hack to force the EntityDebugger to correctly update the list of displayed systems
            {
                PlayerLoopSystem   playerLoop = PlayerLoop.GetCurrentPlayerLoop();
                PlayerLoopSystem[] oldArray   = playerLoop.subSystemList;
                playerLoop.subSystemList = new PlayerLoopSystem[oldArray.Length];
                Array.Copy(oldArray, 0, playerLoop.subSystemList, 0, oldArray.Length);
                PlayerLoop.SetPlayerLoop(playerLoop);
            }
#endif
        }