Пример #1
0
 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     _id            = reader.ReadString();
     _revealOrder   = reader.ReadInt();
     _read          = reader.ReadBool();
     _newlyRevealed = reader.ReadBool();
 }
        public static Scanner ReadScanner(this NetworkReader reader)
        {
            bool   scannerOpen  = reader.ReadBool();
            bool   scannerEmpty = reader.ReadBool();
            string documentText = reader.ReadString();
            string scannedText  = reader.ReadString();

            return(new Scanner(scannerOpen, scannerEmpty, documentText, scannedText));
        }
Пример #3
0
 public void Serialize(ref bool value)
 {
     if (IsReading)
     {
         value = m_Reader.ReadBool();
     }
     else
     {
         m_Writer.WriteBool(value);
     }
 }
Пример #4
0
        public static Printer ReadPrinter(this NetworkReader reader)
        {
            int  trayCount    = reader.Read <int>();
            int  trayCapacity = reader.Read <int>();
            bool trayOpen     = reader.ReadBool();

            return(new Printer(trayCount, trayCapacity, trayOpen));
        }
        public static WeaponProjectile OnDeserialize(NetworkReader reader)
        {
            string           weaponId = reader.ReadString();
            WeaponProjectile weapon   = WeaponsResourceManager.GetWeapon(weaponId) as WeaponProjectile;

            weapon.currentProjectileCount = reader.ReadInt();
            weapon.isReloading            = reader.ReadBool();
            return(weapon);
        }
Пример #6
0
        public void Read(NetworkReader reader)
        {
            ObjectId = reader.ReadInt32();
            Id       = reader.ReadInt32();
            X        = reader.ReadInt32();
            Y        = reader.ReadInt32();

            var length = reader.ReadInt32();

            Stats = new Stat[length];
            for (var i = 0; i < length; i++)
            {
                Stats[i] = new Stat();
                Stats[i].Read(reader);
            }

            LastDirection = reader.ReadInt32();
            IsPlayer      = reader.ReadBool();
            IsEntity      = reader.ReadBool();
        }
Пример #7
0
        public static UpdateTileMessage.NetMessage Deserialize(this NetworkReader reader)
        {
            var message = new UpdateTileMessage.NetMessage();

            message.Changes         = new List <UpdateTileMessage.DelayedData>();
            message.MatrixSyncNetID = reader.ReadUInt();
            while (true)
            {
                var Continue = reader.ReadBool();
                if (Continue == false)
                {
                    break;
                }

                var WorkingOn = new UpdateTileMessage.DelayedData
                {
                    Position        = reader.ReadVector3Int(),
                    TileType        = (TileType)reader.ReadInt(),
                    layerType       = (LayerType)reader.ReadInt(),
                    TileName        = reader.ReadString(),
                    MatrixSyncNetID = message.MatrixSyncNetID,
                    TransformMatrix = Matrix4x4.identity,
                    Colour          = Color.white
                };



                while (true)
                {
                    byte Operation = reader.ReadByte();

                    if (Operation == (byte)EnumOperation.NoMoreData)
                    {
                        break;
                    }

                    if (Operation == (byte)EnumOperation.Colour)
                    {
                        WorkingOn.Colour = reader.ReadColor();
                    }

                    if (Operation == (byte)EnumOperation.Matrix4x4)
                    {
                        WorkingOn.TransformMatrix = reader.ReadMatrix4x4();
                    }
                }
                message.Changes.Add(WorkingOn);
            }

            return(message);
        }
Пример #8
0
        public override void Deserialize(NetworkReader reader)
        {
            connectionId = reader.ReadInt32();
            toServer = reader.ReadBool();

        }
        public static RequestInteractMessage.NetMessage Deserialize(this NetworkReader reader)
        {
            var message = new RequestInteractMessage.NetMessage();

            var componentID = reader.ReadUShort();

            if (componentID == RequestInteractMessage.UNKNOWN_COMPONENT_TYPE_ID)
            {
                //client didn't know which to trigger, leave ComponentType null
                message.ComponentType = null;
            }
            else
            {
                //client requested a specific component.
                message.ComponentType = RequestInteractMessage.componentIDToComponentType[componentID];
            }

            message.InteractionType = RequestInteractMessage.interactionIDToInteractionType[reader.ReadByte()];
            if (componentID != RequestInteractMessage.UNKNOWN_COMPONENT_TYPE_ID)
            {
                // client specified exact component
                message.ProcessorObject = reader.ReadUInt();
            }
            else
            {
                // client requested server to check the interaction
                message.ProcessorObject = NetId.Invalid;
            }
            message.Intent = (Intent)reader.ReadByte();

            if (message.InteractionType == typeof(PositionalHandApply))
            {
                message.TargetObject   = reader.ReadUInt();
                message.TargetVector   = reader.ReadVector2();
                message.TargetBodyPart = (BodyPartType)reader.ReadUInt();
                message.IsAltUsed      = reader.ReadBool();
            }
            else if (message.InteractionType == typeof(HandApply))
            {
                message.TargetObject   = reader.ReadUInt();
                message.TargetBodyPart = (BodyPartType)reader.ReadUInt();
                message.IsAltUsed      = reader.ReadBool();
            }
            else if (message.InteractionType == typeof(AimApply))
            {
                message.TargetVector     = reader.ReadVector2();
                message.MouseButtonState = reader.ReadBool() ? MouseButtonState.PRESS : MouseButtonState.HOLD;
                message.TargetBodyPart   = (BodyPartType)reader.ReadUInt();
            }
            else if (message.InteractionType == typeof(MouseDrop))
            {
                message.TargetObject = reader.ReadUInt();
                message.UsedObject   = reader.ReadUInt();
            }
            else if (message.InteractionType == typeof(InventoryApply))
            {
                message.StorageIndexOnGameObject = reader.ReadUInt();
                message.UsedObject = reader.ReadUInt();
                message.Storage    = reader.ReadUInt();
                message.SlotIndex  = reader.ReadInt();
                message.NamedSlot  = (NamedSlot)reader.ReadInt();
                message.IsAltUsed  = reader.ReadBool();
            }
            else if (message.InteractionType == typeof(TileApply))
            {
                message.TargetVector = reader.ReadVector2();
            }
            else if (message.InteractionType == typeof(TileMouseDrop))
            {
                message.UsedObject   = reader.ReadUInt();
                message.TargetVector = reader.ReadVector2();
            }
            else if (message.InteractionType == typeof(ConnectionApply))
            {
                message.TargetObject     = reader.ReadUInt();
                message.TargetVector     = reader.ReadVector2();
                message.connectionPointA = (Connection)reader.ReadByte();
                message.connectionPointB = (Connection)reader.ReadByte();
            }
            else if (message.InteractionType == typeof(ContextMenuApply))
            {
                message.TargetObject    = reader.ReadUInt();
                message.RequestedOption = reader.ReadString();
            }
            else if (message.InteractionType == typeof(AiActivate))
            {
                message.TargetObject = reader.ReadUInt();
                message.ClickTypes   = (AiActivate.ClickTypes)reader.ReadByte();
            }

            return(message);
        }
Пример #10
0
 public override void Deserialize(NetworkReader reader)
 {
     base.Deserialize(reader);
     _conditionName  = reader.ReadString();
     _conditionState = reader.ReadBool();
 }
Пример #11
0
 public object Read(NetworkReader reader)
 {
     return(reader.ReadBool());
 }
        /// <summary>
        /// Used to deserialize a serialized scene object which occurs
        /// when the client is approved or during a scene transition
        /// </summary>
        /// <param name="objectStream">inbound stream</param>
        /// <param name="reader">reader for the stream</param>
        /// <param name="networkManager">NetworkManager instance</param>
        /// <returns>optional to use NetworkObject deserialized</returns>
        internal static NetworkObject DeserializeSceneObject(NetworkBuffer objectStream, NetworkReader reader, NetworkManager networkManager)
        {
            var   isPlayerObject  = reader.ReadBool();
            var   networkId       = reader.ReadUInt64Packed();
            var   ownerClientId   = reader.ReadUInt64Packed();
            var   hasParent       = reader.ReadBool();
            ulong?parentNetworkId = null;

            if (hasParent)
            {
                parentNetworkId = reader.ReadUInt32Packed();
            }

            var isSceneObject = reader.ReadBool();

            var        prefabHash = reader.ReadUInt32Packed();
            Vector3?   position   = null;
            Quaternion?rotation   = null;

            // Check to see if we have position and rotation values that follows
            if (reader.ReadBool())
            {
                position = new Vector3(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
                rotation = Quaternion.Euler(reader.ReadSinglePacked(), reader.ReadSinglePacked(), reader.ReadSinglePacked());
            }

            //Attempt to create a local NetworkObject
            var networkObject = networkManager.SpawnManager.CreateLocalNetworkObject(isSceneObject, prefabHash, ownerClientId, parentNetworkId, position, rotation);

            // Determine if this NetworkObject has NetworkVariable data to read
            var networkVariableDataIsIncluded = reader.ReadBool();

            if (networkVariableDataIsIncluded)
            {
                // (See Part 1 above in the NetworkObject.SerializeSceneObject method to better understand this)
                // Part 2: This makes sure that if one NetworkObject fails to construct (for whatever reason) then we can "skip past"
                // that specific NetworkObject but continue processing any remaining serialized NetworkObjects as opposed to just
                // throwing an exception and skipping the remaining (if any) NetworkObjects.  This will prevent one misconfigured
                // issue (or more) from breaking the entire loading process.
                var networkVariableDataSize = reader.ReadUInt32();
                if (networkObject == null)
                {
                    // Log the error that the NetworkObject failed to construct
                    Debug.LogError($"Failed to spawn {nameof(NetworkObject)} for Hash {prefabHash}.");

                    // If we failed to load this NetworkObject, then skip past the network variable data
                    objectStream.Position += networkVariableDataSize;

                    // We have nothing left to do here.
                    return(null);
                }
            }

            // Spawn the NetworkObject
            networkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, isSceneObject, isPlayerObject, ownerClientId, objectStream, false, 0, true, false);

            var bufferQueue = networkManager.BufferManager.ConsumeBuffersForNetworkId(networkId);

            // Apply buffered messages
            if (bufferQueue != null)
            {
                while (bufferQueue.Count > 0)
                {
                    Messaging.Buffering.BufferManager.BufferedMessage message = bufferQueue.Dequeue();
                    networkManager.HandleIncomingData(message.SenderClientId, message.NetworkChannel, new ArraySegment <byte>(message.NetworkBuffer.GetBuffer(), (int)message.NetworkBuffer.Position, (int)message.NetworkBuffer.Length), message.ReceiveTime, false);
                    Messaging.Buffering.BufferManager.RecycleConsumedBufferedMessage(message);
                }
            }

            return(networkObject);
        }
Пример #13
0
 public override void Deserialize(NetworkReader reader)
 {
     toServer   = reader.ReadBool();
     objectId   = reader.ReadNetworkObjectId();
     instanceId = reader.ReadNetworkInstanceId();
 }
 public DefaultHudUpdateMessage(NetworkReader reader)
 {
     WeaponId       = reader.ReadString();
     CurrentBullets = reader.ReadInt();
     IsReloading    = reader.ReadBool();
 }
Пример #15
0
 public static Guid?ReadGuidNullable(this NetworkReader reader) => reader.ReadBool() ? ReadGuid(reader) : default(Guid?);