Exemplo n.º 1
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.SimpleEvent);

            buf.WriteInt((int)Event);
        }
Exemplo n.º 2
0
 public void Deserialize(SerializationBuffer buf)
 {
     CharacterId   = buf.ReadInt();
     ForPlayerId   = buf.ReadInt();
     SpawnPosition = buf.ReadVector3();
     SpawnRotation = buf.ReadQuaternion();
 }
Exemplo n.º 3
0
        private void DeserializePlayerCommands(SerializationBuffer buf, ref CMD intoStruct, out int receivedTick, out int receivedPlayerId)
        {
            receivedTick     = buf.ReadInt();
            receivedPlayerId = buf.ReadInt();

            intoStruct.ReadFromBuffer(buf);
        }
Exemplo n.º 4
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.PlayerRegistration);

            buf.WriteString(PlayerName);
        }
Exemplo n.º 5
0
 public void Deserialize(SerializationBuffer buf)
 {
     AtTick         = buf.ReadInt();
     FiringPlayerId = buf.ReadInt();
     FiringRotation = buf.ReadQuaternion();
     HitCharacterId = buf.ReadInt();
 }
Exemplo n.º 6
0
 public void Deserialize(SerializationBuffer buf)
 {
     Add            = buf.ReadBool();
     ForLocalPlayer = buf.ReadBool();
     PlayerId       = buf.ReadInt();
     PlayerName     = buf.ReadString();
 }
Exemplo n.º 7
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.SceneLoading);

            buf.WriteString(SceneName);
        }
Exemplo n.º 8
0
        private void DeserializeGlobalSnapshot(SerializationBuffer buf, out int receivedTick)
        {
            receivedTick = buf.ReadInt();
            int indexForReceivedTick = GetSnapshotIndexForTick(receivedTick);

            // Commands snapshot
            int commandsCount = buf.ReadInt();

            for (int i = 0; i < commandsCount; i++)
            {
                int commandsPlayerId = buf.ReadInt();

                // Don't override commands from local players
                IdentifiedData <CMD> tmpPlayerCommands = new IdentifiedData <CMD>();
                tmpPlayerCommands.DataId = commandsPlayerId;
                tmpPlayerCommands.DataStruct.ReadFromBuffer(buf);

                for (int j = 0; j < SnapshotsRingBuffer[indexForReceivedTick].CommandsSnapshot.PlayerCommands.Count; j++)
                {
                    if (SnapshotsRingBuffer[indexForReceivedTick].CommandsSnapshot.PlayerCommands[j].DataId == commandsPlayerId)
                    {
                        SnapshotsRingBuffer[indexForReceivedTick].CommandsSnapshot.PlayerCommands[j] = tmpPlayerCommands;
                        break;
                    }
                }
            }

            // World snapshot
            SnapshotsRingBuffer[indexForReceivedTick].WorldSnapshot.ReadFromBuffer(buf);
        }
        public void ReadFromBuffer(SerializationBuffer buf)
        {
            int CharacterStatesCount = buf.ReadInt();

            for (int i = 0; i < CharacterStatesCount; i++)
            {
                int characterId = buf.ReadInt();

                Vector3    position  = buf.ReadVector3();
                Quaternion rotation  = buf.ReadQuaternion();
                Vector3    velocity  = buf.ReadVector3();
                bool       isStunned = buf.ReadBool();

                // Find CharacterState corresponding to this ID and apply the state
                for (int j = 0; j < CharacterStates.Count; j++)
                {
                    if (CharacterStates[j].DataId == characterId)
                    {
                        IdentifiedData <MyCharacterState> tmpIdCharState = CharacterStates[j];

                        tmpIdCharState.DataStruct.MotorState.Position     = position;
                        tmpIdCharState.DataStruct.MotorState.Rotation     = rotation;
                        tmpIdCharState.DataStruct.MotorState.BaseVelocity = velocity;

                        tmpIdCharState.DataStruct.IsStunned = isStunned;

                        CharacterStates[j] = tmpIdCharState;
                        break;
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)FrameworkNetworkMessageID.CommandRequest);

            buf.WriteInt(ForPlayerId);
            buf.WriteInt(ForTick);
        }
Exemplo n.º 11
0
 public void WriteToBuffer(SerializationBuffer buf, bool mustBeFullState)
 {
     buf.WriteFloat(MoveAxisForward);
     buf.WriteFloat(MoveAxisRight);
     buf.WriteQuaternion(CameraRotation);
     buf.WriteBool(JumpDown);
     buf.WriteBool(Fire);
 }
Exemplo n.º 12
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.SpawnPlayer);

            buf.WriteInt(PlayerId);
            buf.WriteBool(IsLocalPlayer);
        }
Exemplo n.º 13
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.TickSync);

            buf.WriteInt(Tick);
            buf.WriteInt(Timestamp);
        }
Exemplo n.º 14
0
 public void ReadFromBuffer(SerializationBuffer buf)
 {
     MoveAxisForward = buf.ReadFloat();
     MoveAxisRight   = buf.ReadFloat();
     CameraRotation  = buf.ReadQuaternion();
     JumpDown        = buf.ReadBool();
     Fire            = buf.ReadBool();
 }
Exemplo n.º 15
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.PlayerAdd);

            buf.WriteBool(Add);
            buf.WriteBool(ForLocalPlayer);
            buf.WriteInt(PlayerId);
            buf.WriteString(PlayerName);
        }
Exemplo n.º 16
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.LazerHit);

            buf.WriteInt(AtTick);
            buf.WriteInt(FiringPlayerId);
            buf.WriteQuaternion(FiringRotation);
            buf.WriteInt(HitCharacterId);
        }
Exemplo n.º 17
0
        public void Serialize(SerializationBuffer buf)
        {
            buf.SeekZero();
            buf.WriteInt((int)NetworkMessageID.SpawnCharacter);

            buf.WriteInt(CharacterId);
            buf.WriteInt(ForPlayerId);
            buf.WriteVector3(SpawnPosition);
            buf.WriteQuaternion(SpawnRotation);
        }
Exemplo n.º 18
0
        private void SerializePlayerCommands(SerializationBuffer buf, PC forPlayer, int forTick, bool mustBeFullState)
        {
            buf.SeekZero();
            buf.WriteInt((int)FrameworkNetworkMessageID.PlayerCommands);

            buf.WriteInt(forTick);
            buf.WriteInt(forPlayer.GetId());

            CMD currentCommands = forPlayer.GetCommands();

            currentCommands.WriteToBuffer(buf, mustBeFullState);
        }
Exemplo n.º 19
0
        private void InitializeNetworking()
        {
            NetworkTransport.Shutdown();
            NetworkTransport.Init(GlobalConfig);

            Application.runInBackground = true;

            // Network buffer for messages
            NetBuffer = new SerializationBuffer(GlobalConfig.MaxPacketSize, 1.5f);

            // Message channels
            ConnectionConfig.Channels.Clear();
            ConnectionConfig.AddChannel(QosType.ReliableSequenced);
            ConnectionConfig.AddChannel(QosType.UnreliableFragmented);
            ConnectionConfig.AddChannel(QosType.Unreliable);
        }
        public void WriteToBuffer(SerializationBuffer buf, bool mustBeFullState)
        {
            int characterStatesCount = CharacterStates.Count;

            buf.WriteInt(characterStatesCount);
            for (int i = 0; i < characterStatesCount; i++)
            {
                buf.WriteInt(CharacterStates[i].DataId);

                buf.WriteVector3(CharacterStates[i].DataStruct.MotorState.Position);
                buf.WriteQuaternion(CharacterStates[i].DataStruct.MotorState.Rotation);
                buf.WriteVector3(CharacterStates[i].DataStruct.MotorState.BaseVelocity);

                buf.WriteBool(CharacterStates[i].DataStruct.IsStunned);
            }
        }
Exemplo n.º 21
0
        private void SerializeGlobalSnapshot(SerializationBuffer buf, ref GlobalSnapshot <CMD, WS> forSnapshot, int forTick, bool mustBeFullState)
        {
            buf.SeekZero();
            buf.WriteInt((int)FrameworkNetworkMessageID.GlobalState);

            buf.WriteInt(forTick);

            // Commands snapshot
            int commandsCount = forSnapshot.CommandsSnapshot.PlayerCommands.Count;

            buf.WriteInt(commandsCount);
            for (int i = 0; i < commandsCount; i++)
            {
                buf.WriteInt(forSnapshot.CommandsSnapshot.PlayerCommands[i].DataId);
                forSnapshot.CommandsSnapshot.PlayerCommands[i].DataStruct.WriteToBuffer(buf, mustBeFullState);
            }

            // World snapshot
            forSnapshot.WorldSnapshot.WriteToBuffer(buf, mustBeFullState);
        }
Exemplo n.º 22
0
 public void Deserialize(SerializationBuffer buf)
 {
     Tick      = buf.ReadInt();
     Timestamp = buf.ReadInt();
 }
Exemplo n.º 23
0
 public void Deserialize(SerializationBuffer buf)
 {
     SceneName = buf.ReadString();
 }
Exemplo n.º 24
0
 public void Deserialize(SerializationBuffer buf)
 {
     ForPlayerId = buf.ReadInt();
     ForTick     = buf.ReadInt();
 }
Exemplo n.º 25
0
 public void Deserialize(SerializationBuffer buf)
 {
     Event = (EventType)buf.ReadInt();
 }
Exemplo n.º 26
0
 public void ReadFromBuffer(SerializationBuffer buf)
 {
     KinematicCharacterSubsystemState.ReadFromBuffer(buf);
 }
Exemplo n.º 27
0
 public void WriteToBuffer(SerializationBuffer buf, bool mustBeFullState)
 {
     KinematicCharacterSubsystemState.WriteToBuffer(buf, mustBeFullState);
 }
Exemplo n.º 28
0
 public void Deserialize(SerializationBuffer buf)
 {
     PlayerId      = buf.ReadInt();
     IsLocalPlayer = buf.ReadBool();
 }
Exemplo n.º 29
0
 public void Deserialize(SerializationBuffer buf)
 {
     PlayerName = buf.ReadString();
 }