Esempio n. 1
0
    public void OnSimulate(DeterministicFrame state)
    {
        var f = (Quantum.Frame)state;

        try {
            ApplyInputs(f);

            f.PreSimulatePrepare();

            for (Int32 i = 0; i < _systems.Length; ++i)
            {
                if (Quantum.BitSet256.IsSet(&f.Global->Systems, i))
                {
                    try {
                        _systems[i].Update(f);
                    }
                    catch (Exception exn) {
                        LogSimulationException(exn);
                    }
                }
            }

            f.PostSimulateCleanup();
        }
        catch (Exception exn) {
            LogSimulationException(exn);
        }
    }
Esempio n. 2
0
    void InitSystems(DeterministicFrame f)
    {
        // call init on ALL systems
        for (Int32 i = 0; i < _systems.Length; ++i)
        {
            try {
                _systems[i].OnInit((Quantum.Frame)f);
            }
            catch (Exception exn) {
                LogSimulationException(exn);
            }
        }

        // call OnEnabled on all systems which start enabled
        for (Int32 i = 0; i < _systems.Length; ++i)
        {
            if (_systems[i].StartEnabled)
            {
                try {
                    _systems[i].OnEnabled((Quantum.Frame)f);
                }
                catch (Exception exn) {
                    LogSimulationException(exn);
                }
            }
        }
    }
Esempio n. 3
0
    public void OnGameStart(DeterministicFrame f)
    {
        _inputStreamRead  = new Quantum.ByteStream(new Byte[1024]);
        _inputStreamWrite = new Quantum.ByteStream(new Byte[1024]);
        _localPlayers     = _session.LocalPlayerIndices.Select(x => (Quantum.PlayerRef)x).ToArray();

        // set public delegates for converting between photon/quantum players
        PhotonPlayerToQuantumPlayer = PlayerToIndex;
        QuantumPlayerToPhotonPlayer = IndexToPlayer;

        // sort runtime players
        SortRuntimePlayers();

        // init event invoker
        InitEventInvoker(_session.RollbackWindow);

        // init systems on latest frame
        InitSystems(f);

        _frame                  = (Quantum.Frame)f;
        _framePredicted         = _frame;
        _framePredictedPrevious = _frame;
        _frameVerified          = _frame;

        for (Int32 i = QuantumCallbacks.Instances.Count - 1; i >= 0; --i)
        {
            try {
                QuantumCallbacks.Instances[i].OnGameStart();
            }
            catch (Exception exn) {
                Quantum.Log.Exception(exn);
            }
        }
    }
Esempio n. 4
0
 public sealed override void CopyFrom(DeterministicFrame frame)
 {
     CopyFromGen((Frame)frame);
     CopyFromUser((Frame)frame);
 }
Esempio n. 5
0
 public void OnSimulateFinished(DeterministicFrame state)
 {
     InvokeEvents((Quantum.Frame)state);
 }
Esempio n. 6
0
 public void OnSimulateFinished(DeterministicFrame state)
 {
     // After simulation has been finished for a frame this is invoked to process events, etc.
     // Can ignore this for lockstep mode
 }
Esempio n. 7
0
 public void OnSimulate(DeterministicFrame state)
 {
     // Perform simulation here
 }
Esempio n. 8
0
 public void OnGameStart(DeterministicFrame state)
 {
     // Called when game starts, with the first frame
 }