상속: NetworkObject
예제 #1
0
        public override void Deserialize(Bitstream msg)
        {
            State = new List<PlayerStateData>();
            int count = msg.ReadUInt16();
            for (int i = 0; i < count; ++i)
            {
                var o = new PlayerStateData();
                o.Forward = msg.ReadBool();
                o.Back = msg.ReadBool();
                o.Left = msg.ReadBool();
                o.Right = msg.ReadBool();

                o.Position = msg.ReadVector2();
                o.SimTick = (uint)msg.ReadInt32();

                State.Add(o);
            }
            SnapId = msg.ReadInt32();
        }
예제 #2
0
 protected void AddClientState(PlayerStateData state)
 {
     _stateList.Add(state);
     _moveBuffer.AddToTail(state);
 }
예제 #3
0
        private void SendClientState()
        {
            if (GetServerNode() == null) return;

            var states = GetClientState();
            if (states == null) return;

            var playerEnt = GetPlayer();
            if (playerEnt == null) return;

            ClientStatePacket packet = new ClientStatePacket();
            packet.State = states;
            packet.PreviousState = _lastClientState;
            packet.PlayerId = (uint)playerEnt.UniqueId;
            _lastClientState = states.Count > 0 ? states.Last() : null;
            _bifrost.Send(packet, 1);
        }
예제 #4
0
 internal static void SetCurrentPlayerState(uint id, PlayerStateData data)
 {
     var e = _manager.GetEntityByUniqueId(id);
     EntitySystems.Components.PlayerComponent pc =
         e.GetComponent<EntitySystems.Components.PlayerComponent>();
     if (pc != null)
     {
         pc.LastSyncState = data;
     }
 }