Ejemplo n.º 1
0
 public AbstractLockstep(float deltaTime, ICommunicator communicator, IPhysicsManagerBase physicsManager, int syncWindow, int panicWindow, int rollbackWindow, TrueSyncEventCallback OnGameStarted, TrueSyncEventCallback OnGamePaused, TrueSyncEventCallback OnGameUnPaused, TrueSyncEventCallback OnGameEnded, TrueSyncPlayerDisconnectionCallback OnPlayerDisconnection, TrueSyncUpdateCallback OnStepUpdate, TrueSyncInputDataProvider InputDataProvider)
 {
     AbstractLockstep.instance  = this;
     this.deltaTime             = deltaTime;
     this.syncWindow            = syncWindow;
     this.panicWindow           = panicWindow;
     this.rollbackWindow        = rollbackWindow;
     this.totalWindow           = syncWindow + rollbackWindow;
     this.StepUpdate            = OnStepUpdate;
     this.OnGameStarted         = OnGameStarted;
     this.OnGamePaused          = OnGamePaused;
     this.OnGameUnPaused        = OnGameUnPaused;
     this.OnGameEnded           = OnGameEnded;
     this.OnPlayerDisconnection = OnPlayerDisconnection;
     this.InputDataProvider     = InputDataProvider;
     this.ticks                = 0;
     this.players              = new Dictionary <byte, TSPlayer>(4);
     this.activePlayers        = new List <TSPlayer>(4);
     this.auxPlayersSyncedData = new List <SyncedData>(4);
     this.auxPlayersInputData  = new List <InputDataBase>(4);
     this.communicator         = communicator;
     this.physicsManager       = physicsManager;
     this.compoundStats        = new CompoundStats();
     this.bufferSyncedInfo     = new GenericBufferWindow <SyncedInfo>(3);
     this.checksumOk           = true;
     this.simulationState      = AbstractLockstep.SimulationState.NOT_STARTED;
     this.bodiesToDestroy      = new Dictionary <int, List <IBody> >();
     this.playersDisconnect    = new Dictionary <int, List <byte> >();
     this.ReplayMode           = ReplayRecord.replayMode;
 }
Ejemplo n.º 2
0
        public AbstractLockstep(FP deltaTime, ICommunicator communicator, IPhysicsManager physicsManager, int syncWindow, int panicWindow, int rollbackWindow, TrueSyncEventCallback OnGameStarted, TrueSyncEventCallback OnGamePaused, TrueSyncEventCallback OnGameUnPaused, TrueSyncEventCallback OnGameEnded, TrueSyncPlayerDisconnectionCallback OnPlayerDisconnection, TrueSyncUpdateCallback OnStepUpdate, TrueSyncInputCallback GetLocalData)
        {
            this.deltaTime             = deltaTime;
            this.syncWindow            = syncWindow;
            this.panicWindow           = panicWindow;
            this.rollbackWindow        = rollbackWindow;
            this.totalWindow           = syncWindow + rollbackWindow;
            this.StepUpdate            = OnStepUpdate;
            this.OnGameStarted         = OnGameStarted;
            this.OnGamePaused          = OnGamePaused;
            this.OnGameUnPaused        = OnGameUnPaused;
            this.OnGameEnded           = OnGameEnded;
            this.OnPlayerDisconnection = OnPlayerDisconnection;
            this.GetLocalData          = GetLocalData;
            this.ticks        = 0;
            this.players      = new SortedDictionary <byte, TSPlayer>();
            this.communicator = communicator;
            bool flag = communicator != null;

            if (flag)
            {
                this.communicator.AddEventListener(new OnEventReceived(this.OnEventDataReceived));
            }
            this.physicsManager     = physicsManager;
            this.compoundStats      = new CompoundStats();
            this.bufferSyncedInfo   = new GenericBufferWindow <SyncedInfo>(3);
            this.checksumOk         = true;
            this.simulationState    = AbstractLockstep.SimulationState.NOT_STARTED;
            this.bodiesToDestroy    = new Dictionary <int, List <IBody> >();
            this.delegatesToExecute = new Dictionary <int, List <Delegate> >();
            this.ReplayRecord       = ReplayRecord.replayToLoad;
            this.ReplayMode         = ReplayRecord.replayMode;
            this.time = FP.Zero;
            StateTracker.AddTracking(this, "time");
        }
Ejemplo n.º 3
0
 public GenericBufferWindow(int size, GenericBufferWindow <T> .NewInstance NewInstance)
 {
     this.size         = size;
     this.currentIndex = 0;
     this.buffer       = new T[size];
     for (int i = 0; i < size; i++)
     {
         this.buffer[i] = NewInstance();
     }
 }
Ejemplo n.º 4
0
 public CompoundStats()
 {
     this.bufferStats = new GenericBufferWindow <Stats>(10);
     this.globalStats = new Stats();
     this.timerAcc    = 0;
 }
Ejemplo n.º 5
0
 public CompoundStats()
 {
     bufferStats = new GenericBufferWindow <Stats>(BUFFER_WINDOW);
     globalStats = new Stats();
     timerAcc    = 0f;
 }
Ejemplo n.º 6
0
 public RollbackLockstep(float deltaTime, ICommunicator communicator, IPhysicsManagerBase physicsManager, int syncWindow, int panicTime, int rollbackWindow, TrueSyncEventCallback OnGameStarted, TrueSyncEventCallback OnGamePaused, TrueSyncEventCallback OnGameUnPaused, TrueSyncEventCallback OnGameEnded, TrueSyncPlayerDisconnectionCallback OnPlayerDisconnection, TrueSyncUpdateCallback OnStepUpdate, TrueSyncInputCallback GetLocalData, TrueSyncInputDataProvider InputDataProvider) : base(deltaTime, communicator, physicsManager, syncWindow, panicTime, rollbackWindow, OnGameStarted, OnGamePaused, OnGameUnPaused, OnGameEnded, OnPlayerDisconnection, OnStepUpdate, GetLocalData, InputDataProvider)
 {
     this.bufferWorldClone = new GenericBufferWindow <IWorldClone>(rollbackWindow, new GenericBufferWindow <IWorldClone> .NewInstance(physicsManager.GetWorldClone));
     this.rollbackIndex    = rollbackWindow;
 }