コード例 #1
0
 public void InvokeFrameSyncFixedUpdate(FrameSyncInput input, FrameSyncUpdateType frameSyncUpdateType)
 {
     foreach (IFrameSyncUpdate frameSyncUpdate in _frameSyncUpdates)
     {
         frameSyncUpdate.FrameSyncUpdate(input, frameSyncUpdateType);
     }
 }
コード例 #2
0
        internal void ApplyPrediction(FrameSyncInput input, InputFrame i1, InputFrame i2)
        {
            //copy i1 to i2
            SWBytes.CopyFull(i1.bytes, i2.bytes);

            //let input reset
            //important to reset triggers
            input.InputJustCopied(i2.bytes);

            byte inputSize = input.Size;

            if (bytes.DataLength > 0)
            {
                byte playerCount = bytes.PopByte();

                for (int i = 0; i < playerCount; i++)
                {
                    byte            playerID = bytes.PopByte();
                    FrameSyncPlayer player   = input.GetPlayer(playerID);
                    byte            offset   = player.InputOffset;
                    SWBytes.Copy(bytes, i2.bytes, bytes.ReadIndex, offset, inputSize);
                    bytes.SkipRead(inputSize);
                }
            }

            //reset read index
            bytes.SetReadIndex(0);

            //prepare bitarray
            input.InputDeltaJustApplied(i2.bytes);
        }
コード例 #3
0
        internal void Apply(FrameSyncInput input, InputFrame i1, InputFrame i2)
        {
            //copy i1 to i2
            SWBytes.CopyFull(i1.bytes, i2.bytes);

            //let input reset
            //important to reset triggers
            input.InputJustCopied(i2.bytes);

            //apply delta for each player
            byte inputSize = input.Size;

            SWConsole.Crit($"ApplyDelta delta frameNumber={frameNumber} {bytes.FullString()}");

            while (bytes.DataLength > 0)
            {
                byte            playerID = bytes.PopByte();
                FrameSyncPlayer player   = input.GetPlayer(playerID);
                if (player == null)
                {
                    SWConsole.Error($"InputFrameDelta Apply: player not found {playerID}");
                }
                byte offset = player.InputOffset;
                SWBytes.Copy(bytes, i2.bytes, bytes.ReadIndex, offset, inputSize);
                bytes.SkipRead(inputSize);
            }

            //reset read index
            bytes.SetReadIndex(0);

            //prepare bitarray
            input.InputDeltaJustApplied(i2.bytes);
        }
コード例 #4
0
 public override void Update(FrameSyncGame game, FrameSyncInput input, FrameSyncUpdateType updateType)
 {
     foreach (var pair in _behaviours)
     {
         StaticFrameSyncBehaviour behaviour = pair.Value;
         if (!behaviour._isInitialized)
         {
             behaviour.InvokeFrameSyncDataInitialize(game);
         }
         behaviour.InvokeFrameSyncFixedUpdate(input, updateType);
     }
 }
コード例 #5
0
        public override void Update(FrameSyncGame game, FrameSyncInput input, FrameSyncUpdateType updateType)
        {
            foreach (var pair in _behaviours)
            {
                DynamicFrameSyncBehaviour behaviour = pair.Value;

                if (behaviour.hasBufferedToRemove)
                {
                    continue;
                }

                if (!behaviour._isInitialized)
                {
                    behaviour.InvokeFrameSyncDataInitialize(game);
                }

                behaviour.InvokeFrameSyncFixedUpdate(input, updateType);
            }

            foreach (DynamicFrameSyncBehaviour behaviour in _bufferedNewBehaviours)
            {
                if (!behaviour._isInitialized)
                {
                    behaviour.InvokeFrameSyncDataInitialize(game);
                }
                behaviour.InvokeFrameSyncFixedUpdate(input, updateType);

                _behaviours.Add(behaviour.FrameSyncBehaviourID, behaviour);
            }

            foreach (DynamicFrameSyncBehaviour behaviour in _bufferedRemovedBehaviours)
            {
                Remove(behaviour);
            }

            _bufferedNewBehaviours.Clear();
            _bufferedRemovedBehaviours.Clear();
        }
コード例 #6
0
 public void SetFrameSyncInputConfig(FrameSyncInputConfig inputConfig)
 {
     _input = new FrameSyncInput(inputConfig);
     _input.SetInputProvider(this);
 }
コード例 #7
0
 public virtual void Update(FrameSyncGame game, FrameSyncInput input, FrameSyncUpdateType updateType)
 {
 }
コード例 #8
0
 public FrameSyncGame(FrameSyncInput input)
 {
     _input = input;
 }
コード例 #9
0
 public abstract void OnCollectLocalPlayerInputs(FrameSyncInput input, FrameSyncGame game);