Beispiel #1
0
 public override void Deserialize(NetworkReader reader)
 {
     this.connectionId = (int) reader.ReadPackedUInt32();
     this.address = reader.ReadString();
     this.port = (int) reader.ReadPackedUInt32();
     this.isHost = reader.ReadBoolean();
     this.isYou = reader.ReadBoolean();
 }
 public override void Deserialize(NetworkReader reader)
 {
   this.netId = reader.ReadNetworkId();
   this.payload = reader.ReadBytesAndSize();
   this.teleport = reader.ReadBoolean();
   this.time = (int) reader.ReadPackedUInt32();
 }
Beispiel #3
0
    public ClientVC(NetworkReader nr)
        : base(new Vec2i(0,0), 0)
    {
        this.data = new VesselTile[VesselChunk.DATA_COUNT];

        index.x = nr.ReadInt32();
        index.y = nr.ReadInt32();

        version = nr.ReadUInt32();
        tileCount = nr.ReadInt32();

        for (int i = 0; i < tileCount; i++) {
            //read in vessel tile
            Vec2i tileI;

            tileI.x = nr.ReadInt32();
            tileI.y = nr.ReadInt32();
            FloorType floor0 = (FloorType)nr.ReadByte();
            FloorType floor1 = (FloorType)nr.ReadByte();
            WallTypeMask wallMask = (WallTypeMask)nr.ReadByte();
            bool wallNode = nr.ReadBoolean();

            VesselTile tile = new VesselTile(wallMask, wallNode, floor0, floor1, (uint)VesselTile.FLAGS.NONE);

            SetTile(tileI, tile);
        }
    }
 public override void OnDeserialize(NetworkReader reader, bool initialState)
 {
     if (reader.ReadPackedUInt32() != 0)
     {
         this.m_Slot = reader.ReadByte();
         this.m_ReadyToBegin = reader.ReadBoolean();
     }
 }
 public override void Deserialize(NetworkReader reader)
 {
   this.connectionId = (int) reader.ReadPackedUInt32();
   this.address = reader.ReadString();
   this.port = (int) reader.ReadPackedUInt32();
   this.isHost = reader.ReadBoolean();
   this.isYou = reader.ReadBoolean();
   uint num = reader.ReadPackedUInt32();
   if (num <= 0U)
     return;
   List<PeerInfoPlayer> peerInfoPlayerList = new List<PeerInfoPlayer>();
   for (uint index = 0; index < num; ++index)
   {
     PeerInfoPlayer peerInfoPlayer;
     peerInfoPlayer.netId = reader.ReadNetworkId();
     peerInfoPlayer.playerControllerId = (short) reader.ReadPackedUInt32();
     peerInfoPlayerList.Add(peerInfoPlayer);
   }
   this.playerIds = peerInfoPlayerList.ToArray();
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.connectionId = (int) reader.ReadPackedUInt32();
     this.address = reader.ReadString();
     this.port = (int) reader.ReadPackedUInt32();
     this.isHost = reader.ReadBoolean();
     this.isYou = reader.ReadBoolean();
     uint num = reader.ReadPackedUInt32();
     if (num > 0)
     {
         List<PeerInfoPlayer> list = new List<PeerInfoPlayer>();
         for (uint i = 0; i < num; i++)
         {
             PeerInfoPlayer player;
             player.netId = reader.ReadNetworkId();
             player.playerControllerId = (short) reader.ReadPackedUInt32();
             list.Add(player);
         }
         this.playerIds = list.ToArray();
     }
 }
    public override void Deserialize(NetworkReader reader) {
        //Get the no of inputs received
        int count = reader.ReadInt32();

        //Prepaare list
        if (inputsList != null) {
            inputsList.Clear(); //Detatch prev elements
        }
        inputsList = new List<Inputs>(); //Detatch prev mem

        //Build all inputs
        for (int i = 0; i < count; i++){
            //Create
            Inputs input = new Inputs();

            //Deserialize individually
            input.crouch = reader.ReadBoolean();
            input.jump = reader.ReadBoolean();
            input.move = reader.ReadBoolean();
            input.pitch = reader.ReadSingle();
            input.rotate = reader.ReadBoolean();
            input.timeStamp = reader.ReadDouble();
            input.walk = reader.ReadBoolean();
            bool[] wasd = new bool[4];
            wasd[0] = reader.ReadBoolean();
            wasd[1] = reader.ReadBoolean();
            wasd[2] = reader.ReadBoolean();
            wasd[3] = reader.ReadBoolean();
            input.wasd = wasd;
            input.yaw = reader.ReadSingle();

            //Add to the message list
            inputsList.Add(input);

            //Check if is the last input and register stamp
            if(i == count - 1) {
                stamp = input.timeStamp;
            }
        }
    }
Beispiel #8
0
        // This method would be generated
        public override void Deserialize(NetworkReader reader)
        {
            roomsCount = reader.ReadInt32();
            Rooms      = new RoomStr[roomsCount];
            for (int i = 0; i < roomsCount; i++)
            {
                index      = reader.ReadInt32();
                name       = reader.ReadString();
                map        = reader.ReadInt32();
                players    = reader.ReadInt16();
                maxPlayers = reader.ReadInt16();
                password   = reader.ReadBoolean();

                RoomStr r = new RoomStr(index, name, map, players, maxPlayers, password);
                Rooms[i] = r;
            }
        }
 public static DamageInfo ReadDamageInfo(NetworkReader reader)
 {
     return(new DamageInfo
     {
         damage = reader.ReadSingle(),
         crit = reader.ReadBoolean(),
         attacker = reader.ReadGameObject(),
         inflictor = reader.ReadGameObject(),
         position = reader.ReadVector3(),
         force = reader.ReadVector3(),
         procChainMask = ReadProcChainMask(reader),
         procCoefficient = reader.ReadSingle(),
         damageType = (DamageType)reader.ReadByte(),
         damageColorIndex = (DamageColorIndex)reader.ReadByte(),
         dotIndex = (DotController.DotIndex)(reader.ReadByte() - 1)
     });
 }
Beispiel #10
0
        private static void HandleBulletDamage(NetworkMessage netMsg)
        {
            NetworkReader reader     = netMsg.reader;
            GameObject    gameObject = reader.ReadGameObject();
            DamageInfo    damageInfo = reader.ReadDamageInfo();

            if (reader.ReadBoolean() && gameObject)
            {
                HealthComponent component = gameObject.GetComponent <HealthComponent>();
                if (component)
                {
                    component.TakeDamage(damageInfo);
                }
                GlobalEventManager.instance.OnHitEnemy(damageInfo, gameObject);
            }
            GlobalEventManager.instance.OnHitAll(damageInfo, gameObject);
        }
Beispiel #11
0
        public override void Deserialize(NetworkReader reader)
        {
            accepted  = reader.ReadBoolean();
            scene     = reader.ReadString();
            gameState = (DualNetworkManager.GameState)reader.ReadInt32();

            msgData = reader.ReadBytesAndSize();
            if (msgData == null)
            {
                msgSize = 0;
            }
            else
            {
                msgSize = msgData.Length;
            }

            extraReader = new NetworkReader(msgData);
        }
        public override void Deserialize(NetworkReader reader)
        {
            float      rigScale    = reader.ReadSingle();
            Vector3    rigPosition = reader.ReadVector3();
            Quaternion rigRotation = reader.ReadQuaternion();

            // Setting the avatar PRT
            this.avatarTransform.localScale = new Vector3(rigScale, rigScale, rigScale);
            this.avatarTransform.SetPositionAndRotation(rigPosition, rigRotation);

            // Deserializing Visualization State (if it exists)
            bool hasVisuals = reader.ReadBoolean();

            if (hasVisuals && this.currentAvatarVisuals != null)
            {
                this.currentAvatarVisuals.Deserialize(reader);
            }
        }
Beispiel #13
0
 public static PBS.Battle.View.WifiFriendly.Pokemon ReadBattleViewCompactPokemon(this NetworkReader reader)
 {
     return(new PBS.Battle.View.WifiFriendly.Pokemon
     {
         uniqueID = reader.ReadString(),
         pokemonID = reader.ReadString(),
         nickname = reader.ReadString(),
         teamPos = reader.ReadInt32(),
         battlePos = reader.ReadInt32(),
         currentHP = reader.ReadInt32(),
         maxHP = reader.ReadInt32(),
         isFainted = reader.ReadBoolean(),
         level = reader.ReadInt32(),
         gender = (PokemonGender)reader.ReadInt32(),
         nonVolatileStatus = reader.ReadString(),
         dynamaxState = (Pokemon.DynamaxState)reader.ReadInt32()
     });
 }
        public override void OnDeserialize(NetworkReader reader, bool initialState)
        {
            base.OnDeserialize(reader, initialState);

            if (initialState)
            {
                this.SetTime((float)reader.ReadDouble());

                if (reader.ReadBoolean())
                {
                    this.StartTimer();
                }
                else
                {
                    this.StopTimer();
                }
            }
        }
    public void Deserialize(ref NetworkReader reader, IEntityReferenceSerializer refSerializer, int tick)
    {
        position = reader.ReadVector3Q();
        rotation = reader.ReadFloatQ();
        aimYaw   = reader.ReadFloatQ();
        aimPitch = reader.ReadFloatQ();
        moveYaw  = reader.ReadFloatQ();

        charLocoState  = (CharPredictedStateData.LocoState)reader.ReadInt32();
        charLocoTick   = reader.ReadInt32();
        charAction     = (CharPredictedStateData.Action)reader.ReadInt32();
        charActionTick = reader.ReadInt32();
        sprinting      = reader.ReadBoolean() ? 1 : 0;
        sprintWeight   = reader.ReadFloatQ();

        damageTick      = reader.ReadInt32();
        damageDirection = reader.ReadFloatQ();

        //VR controls
        rightControllerPos = reader.ReadVector3Q();
        leftControllerPos  = reader.ReadVector3Q();
        headsetPos         = reader.ReadVector3Q();
        rightControllerRot = reader.ReadQuaternion();
        leftControllerRot  = reader.ReadQuaternion();
        headsetRot         = reader.ReadQuaternion();

        moveAngleLocal   = reader.ReadFloatQ();
        shootPoseWeight  = reader.ReadFloatQ();
        locomotionVector = reader.ReadVector2Q();
        locomotionPhase  = reader.ReadFloatQ();
        banking          = reader.ReadFloatQ();
        landAnticWeight  = reader.ReadFloatQ();
        turnStartAngle   = reader.ReadFloatQ();
        turnDirection    = reader.ReadInt16();
        squashTime       = reader.ReadFloatQ();
        squashWeight     = reader.ReadFloatQ();
        inAirTime        = reader.ReadFloatQ();
        jumpTime         = reader.ReadFloatQ();
        simpleTime       = reader.ReadFloatQ();
        footIkOffset     = reader.ReadVector2Q();
        footIkNormalLeft = reader.ReadVector3Q();
        footIkNormaRight = reader.ReadVector3Q();
    }
Beispiel #16
0
    // client-side deserialization
    //
    // I M P O R T A N T
    //
    // always read and write the same amount of bytes. never let any errors
    // happen. otherwise readstr/readbytes out of range bugs happen.
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        var agent = GetComponent <NavMeshAgent>();
        var pos   = reader.ReadVector3();
        var dest  = reader.ReadVector3();

        agent.speed            = reader.ReadSingle();
        agent.stoppingDistance = reader.ReadSingle();
        bool warped = reader.ReadBoolean();

        // area costs (see OnSerialize comment)
        for (int i = 0; i < 32; ++i)
        {
            agent.SetAreaCost(i, reader.ReadSingle());
        }

        // OnDeserialize must always return so that next one is called too
        try {
            // only try to set the destination if the agent is on a navmesh already
            // (it might not when falling from the sky after joining)
            if (agent.isOnNavMesh)
            {
                // warp if necessary. distance check to filter out false positives
                if (warped && Vector3.Distance(pos, transform.position) > agent.radius)
                {
                    agent.Warp(pos); // to pos is always smoother
                }
                // rubberbanding: if we are too far off because of a rapid position
                // change or latency, then warp
                // -> agent moves 'speed' meter per seconds
                // -> if we are 2 speed units behind, then we teleport
                //    (using speed is better than using a hardcoded value)
                if (Vector3.Distance(transform.position, pos) > agent.speed * 2)
                {
                    agent.Warp(pos);
                }

                // set destination afterwards, so that we never stop going there
                // even after being warped etc.
                agent.destination = dest;
            }
        } catch {}
    }
Beispiel #17
0
 public override void Deserialize(NetworkReader reader)
 {
     index         = reader.ReadInt32();
     type          = (BulletType)reader.ReadInt32();
     bulletsNumber = reader.ReadInt32();
     if (bulletsNumber > 0)
     {
         vect = new Vector3[bulletsNumber];
         for (int i = 0; i < bulletsNumber; i++)
         {
             vect[i] = reader.ReadVector3();
         }
     }
     thisPlayer = reader.ReadBoolean();
     if (thisPlayer)
     {
         ammo = reader.ReadInt32();
     }
 }
Beispiel #18
0
        private void ForwardAvatarHandPose(NetworkReader sReader, NetworkWriter sWriter)
        {
            sWriter.Write(sReader.ReadSingle()); // thumb
            sWriter.Write(sReader.ReadSingle()); // index
            sWriter.Write(sReader.ReadSingle()); // middle
            sWriter.Write(sReader.ReadSingle()); // ring
            sWriter.Write(sReader.ReadSingle()); // little
            bool syncFingerSwing = sReader.ReadBoolean();

            sWriter.Write(syncFingerSwing);
            if (syncFingerSwing)
            {
                sWriter.Write(sReader.ReadSingle());
                sWriter.Write(sReader.ReadSingle());
                sWriter.Write(sReader.ReadSingle());
                sWriter.Write(sReader.ReadSingle());
                sWriter.Write(sReader.ReadSingle());
            }
        }
    public override void Deserialize(NetworkReader reader)
    {
        base.Deserialize(reader);
        ComponentType   = componentIDToComponentType[reader.ReadUInt16()];
        InteractionType = interactionIDToInteractionType[reader.ReadByte()];
        ProcessorObject = reader.ReadUInt32();
        Intent          = (Intent)reader.ReadByte();

        if (InteractionType == typeof(PositionalHandApply))
        {
            TargetObject   = reader.ReadUInt32();
            TargetVector   = reader.ReadVector2();
            TargetBodyPart = (BodyPartType)reader.ReadUInt32();
        }
        else if (InteractionType == typeof(HandApply))
        {
            TargetObject   = reader.ReadUInt32();
            TargetBodyPart = (BodyPartType)reader.ReadUInt32();
        }
        else if (InteractionType == typeof(AimApply))
        {
            TargetVector     = reader.ReadVector2();
            MouseButtonState = reader.ReadBoolean() ? MouseButtonState.PRESS : MouseButtonState.HOLD;
        }
        else if (InteractionType == typeof(MouseDrop))
        {
            TargetObject = reader.ReadUInt32();
            UsedObject   = reader.ReadUInt32();
        }
        else if (InteractionType == typeof(InventoryApply))
        {
            UsedObject = reader.ReadUInt32();
            Storage    = reader.ReadUInt32();
            SlotIndex  = reader.ReadInt32();
            NamedSlot  = (NamedSlot)reader.ReadInt32();
        }
        else if (InteractionType == typeof(TileApply))
        {
            TargetVector         = reader.ReadVector2();
            TileInteractionIndex = reader.ReadByte();
        }
    }
        /// <summary>
        ///     Reads a <see cref="NetworkedWeapon" />
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static NetworkedWeapon ReadNetworkedWeapon(this NetworkReader reader)
        {
            //First, read the weapon
            TCWeapon weapon = WeaponsResourceManager.GetWeapon(reader.ReadString());

            //Return the NetworkedWeapon
            if (weapon != null)
            {
                return new NetworkedWeapon(weapon, false)
                       {
                           CurrentBulletAmount = reader.ReadInt32(),
                           IsReloading         = reader.ReadBoolean()
                       }
            }
            ;

            //Something went wrong
            Logger.Error("Sent networked weapon doesn't have a TCWeapon!");
            return(null);
        }
    }
Beispiel #21
0
    public void Deserialize(NetworkReader reader)
    {
        int allyCount = reader.ReadInt32();

        allies = new Pawn[allyCount];
        for (int i = 0; i < allyCount; i++)
        {
            allies[i] = Pawn.DeserializeNew(reader);
        }
        enemy       = Pawn.DeserializeNew(reader);
        currentTurn = reader.ReadInt32();
        int rollCount = reader.ReadInt32();

        rolls = new Element[rollCount];
        locks = new bool[rollCount];
        for (int i = 0; i < rollCount; i++)
        {
            rolls[i] = Element.All[reader.ReadByte()];
            locks[i] = reader.ReadBoolean();
        }
    }
        void ReadParameters(NetworkReader reader)
        {
            ulong dirtyBits = reader.ReadPackedUInt64();

            for (int i = 0; i < parameters.Length; i++)
            {
                if ((dirtyBits & (1ul << i)) == 0)
                {
                    continue;
                }

                AnimatorControllerParameter par = parameters[i];
                if (par.type == AnimatorControllerParameterType.Int)
                {
                    int newIntValue = reader.ReadPackedInt32();
                    _animator.SetInteger(par.nameHash, newIntValue);
                }
                else if (par.type == AnimatorControllerParameterType.Float)
                {
                    float newFloatValue = reader.ReadSingle();

                    if (_smoothFloats)
                    {
                        float currentValue = _animator.GetFloat(par.nameHash);
                        float past         = base.syncInterval + _interpolationFallbehind;
                        float rate         = Mathf.Abs(currentValue - newFloatValue) / past;
                        _floatTargets[par.nameHash] = new LerpingFloat(rate, newFloatValue);
                    }
                    else
                    {
                        _animator.SetFloat(par.nameHash, newFloatValue);
                    }
                }
                else if (par.type == AnimatorControllerParameterType.Bool)
                {
                    bool newBoolValue = reader.ReadBoolean();
                    _animator.SetBool(par.nameHash, newBoolValue);
                }
            }
        }
Beispiel #23
0
 public override void Deserialize(NetworkReader reader)
 {
     this.safeToSend = reader.ReadBoolean();
     if (!this.safeToSend)
     {
         Main.LogF("Placeholder6");
         return;
     }
     this.messageType = reader.ReadString();
     this.contextData = NetworkMessageData.Read(reader);
     if (NT_messageLookup.ContainsKey(this.messageType))
     {
         this.handler = NT_messageLookup[this.messageType];
     }
     else
     {
         this.handler = null;
         Main.LogF("Unregistered message type: " + this.messageType + " recieved.\nThis means that the message was not fully Deserialized, and may cause other networking issues.");
         return;
     }
     this.message = this.handler?.Deserialize(reader);
 }
Beispiel #24
0
        public static LineInstance DeSerializeLine(NetworkReader reader)
        {
            var lineInstance = new LineInstance();
            var num1         = reader.ReadSByte();
            var flag         = reader.ReadBoolean();

            lineInstance.isChasing = flag;
            lineInstance.m_positions.Clear();
            for (var index = 0; index <= (int)num1; ++index)
            {
                var num2    = reader.ReadByte();
                var num3    = reader.ReadByte();
                var gridPos = new GridPos(
                    num2,
                    num3,
                    -1 // TODO (int) Board.\u000E().\u000E(gridPos.x, gridPos.y)
                    );
                lineInstance.m_positions.Add(gridPos);
            }

            return(lineInstance);
        }
Beispiel #25
0
 public override void Deserialize(NetworkReader reader)
 {
     item          = ScriptableObject.CreateInstance <Data_ItemFile>();
     item.index    = reader.ReadInt32();
     item.ItemType = (ItemType)reader.ReadInt32();
     switch (item.ItemType)
     {
     case ItemType.weapon:
         item.weaponType = (weaponType)reader.ReadInt32();
         break;
     }
     item.droped = reader.ReadBoolean();
     if (item.droped)
     {
         item.pos    = reader.ReadVector3();
         item.rotate = reader.ReadQuaternion();
     }
     else
     {
         item.owner = reader.ReadInt32();
     }
     Data_ListPlayerOnScene.AddNewItem(item);
 }
Beispiel #26
0
 public override void Deserialize(NetworkReader reader)
 {
     playerCount = reader.ReadInt32();
     try
     {
         for (int i = 0; i < playerCount; i++)
         {
             PlayerStateData player = new PlayerStateData();
             player.name          = reader.ReadString();
             player.id            = reader.ReadString();
             player.position      = reader.ReadVector3();
             player.rotation      = reader.ReadQuaternion();
             player.isStrafing    = reader.ReadBoolean();
             player.state         = reader.ReadInt32();
             player.currentHP     = reader.ReadSingle();
             player.currentEnergy = reader.ReadSingle();
             Data.Add(player);
         }
     }
     catch
     {
     }
 }
Beispiel #27
0
        public static TileDefinition ReadNetworkableTileDefinition(this NetworkReader reader)
        {
            TileDefinition tileDefinition = new TileDefinition();

            string turfName    = reader.ReadString();
            string fixtureName = reader.ReadString();

            if (!string.IsNullOrEmpty(turfName))
            {
                tileDefinition.turf = turfs.FirstOrDefault(turf => turf.name == turfName);
                if (tileDefinition.turf == null)
                {
                    Debug.LogError($"Network recieved turf with name {turfName} could not be found");
                }
            }

            if (!string.IsNullOrEmpty(fixtureName))
            {
                tileDefinition.fixture = fixtures.FirstOrDefault(fixture => fixture.name == fixtureName);
                if (tileDefinition.fixture == null)
                {
                    Debug.LogError($"Network recieved fixture with name {fixtureName} could not be found");
                }
            }

            // If the boolean is false, subStates should be null.
            if (reader.ReadBoolean())
            {
                using (var stream = new MemoryStream(reader.ReadBytesAndSize())) {
                    tileDefinition.subStates = new BinaryFormatter().Deserialize(stream) as object[];
                }
            }

            // TODO: Should substates be initialized to null array?

            return(tileDefinition);
        }
    private object ReaderToObject(NetworkReader networkReader)
    {
        string type = networkReader.ReadString();

        if (type == "int")
        {
            return(networkReader.ReadInt32());
        }
        else if (type == "Vector3")
        {
            return(networkReader.ReadVector3());
        }
        else if (type == "Vector2")
        {
            return(networkReader.ReadVector2());
        }
        else if (type == "Single")
        {
            return(networkReader.ReadSingle());
        }
        else if (type == "Boolean")
        {
            return(networkReader.ReadBoolean());
        }
        else if (type == "String")
        {
            return(networkReader.ReadString());
        }
        else if (type == "Quaternion")
        {
            return(networkReader.ReadQuaternion());
        }
        else
        {
            return(null);
        }
    }
Beispiel #29
0
 public void Deserialize(ref NetworkReader reader, IEntityReferenceSerializer refSerializer, int tick)
 {
     behaviorState     = (State)reader.ReadByte();
     active            = reader.ReadBoolean() ? 1 : 0;
     requestDeactivate = reader.ReadBoolean() ? 1 : 0;
 }
Beispiel #30
0
            public override void Deserialize(NetworkReader reader)
            {
                name = reader.ReadString();

                var isNull = reader.ReadBoolean();
                if (isNull){
                    value = null;
                    return;
                }

                var typeName = reader.ReadString();
                var t = System.Type.GetType(typeName);

                if (t == typeof(string)){
                    value = reader.ReadString();
                    return;
                }
                if (t == typeof(bool)){
                    value = reader.ReadBoolean();
                    return;
                }
                if (t == typeof(int)){
                    value = reader.ReadInt32();
                    return;
                }
                if (t == typeof(float)){
                    value = reader.ReadSingle();
                    return;
                }
                if (t == typeof(Color)){
                    value = reader.ReadColor();
                    return;
                }
                if (t == typeof(Vector2)){
                    value = reader.ReadVector2();
                    return;
                }
                if (t == typeof(Vector3)){
                    value = reader.ReadVector3();
                    return;
                }
                if (t == typeof(Vector4)){
                    value = reader.ReadVector4();
                    return;
                }
                if (t == typeof(Quaternion)){
                    value = reader.ReadQuaternion();
                    return;
                }
                if (t == typeof(GameObject)){
                    value = reader.ReadGameObject();
                    return;
                }
                if (typeof(Component).RTIsAssignableFrom(t)){
                    var go = reader.ReadGameObject();
                    if (go != null){
                        value = go.GetComponent(t);
                    }
                    return;
                }
            }
Beispiel #31
0
            public override void Deserialize(NetworkReader reader)
            {
                name = reader.ReadString();

                var isNull = reader.ReadBoolean();

                if (isNull)
                {
                    value = null;
                    return;
                }

                var typeName = reader.ReadString();
                var t        = System.Type.GetType(typeName);

                if (t == typeof(string))
                {
                    value = reader.ReadString();
                    return;
                }
                if (t == typeof(bool))
                {
                    value = reader.ReadBoolean();
                    return;
                }
                if (t == typeof(int))
                {
                    value = reader.ReadInt32();
                    return;
                }
                if (t == typeof(float))
                {
                    value = reader.ReadSingle();
                    return;
                }
                if (t == typeof(Color))
                {
                    value = reader.ReadColor();
                    return;
                }
                if (t == typeof(Vector2))
                {
                    value = reader.ReadVector2();
                    return;
                }
                if (t == typeof(Vector3))
                {
                    value = reader.ReadVector3();
                    return;
                }
                if (t == typeof(Vector4))
                {
                    value = reader.ReadVector4();
                    return;
                }
                if (t == typeof(Quaternion))
                {
                    value = reader.ReadQuaternion();
                    return;
                }
                if (t == typeof(GameObject))
                {
                    value = reader.ReadGameObject();
                    return;
                }
                if (typeof(Component).RTIsAssignableFrom(t))
                {
                    var go = reader.ReadGameObject();
                    if (go != null)
                    {
                        value = go.GetComponent(t);
                    }
                    return;
                }
            }
Beispiel #32
0
        public override void Deserialize(NetworkReader reader)
        {
            base.Deserialize(reader);

            this.Accepted = reader.ReadBoolean();
        }
Beispiel #33
0
 public void Deserialize(ref SerializeContext context, ref NetworkReader reader)
 {
     position   = reader.ReadVector3();
     exploded   = reader.ReadBoolean() ? 1 : 0;
     bouncetick = reader.ReadInt32();
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.slotId = reader.ReadByte();
     this.readyState = reader.ReadBoolean();
 }
Beispiel #35
0
 public override void Deserialize(ref NetworkReader reader)
 {
     intValue   = reader.ReadInt32();
     boolValue  = reader.ReadBoolean();
     floatValue = reader.ReadFloat();
 }
 public override void Deserialize(NetworkReader reader)
 {
     Result = reader.ReadInt32();
     JustDoIt = reader.ReadBoolean();
     PlayerID = reader.ReadInt64();
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.connectionId = (int) reader.ReadPackedUInt32();
     this.netId = reader.ReadNetworkId();
     this.authorityState = reader.ReadBoolean();
 }
 public override void Deserialize(NetworkReader reader)
 {
   this.netId = reader.ReadNetworkId();
   this.authority = reader.ReadBoolean();
 }
 private void ReadParameters(NetworkReader reader, bool autoSend)
 {
   for (int index = 0; index < this.m_Animator.parameters.Length; ++index)
   {
     if (!autoSend || this.GetParameterAutoSend(index))
     {
       AnimatorControllerParameter parameter = this.m_Animator.parameters[index];
       if (parameter.type == AnimatorControllerParameterType.Int)
       {
         int num = (int) reader.ReadPackedUInt32();
         this.m_Animator.SetInteger(parameter.nameHash, num);
         this.SetRecvTrackingParam(parameter.name + ":" + (object) num, index);
       }
       if (parameter.type == AnimatorControllerParameterType.Float)
       {
         float num = reader.ReadSingle();
         this.m_Animator.SetFloat(parameter.nameHash, num);
         this.SetRecvTrackingParam(parameter.name + ":" + (object) num, index);
       }
       if (parameter.type == AnimatorControllerParameterType.Bool)
       {
         bool flag = reader.ReadBoolean();
         this.m_Animator.SetBool(parameter.nameHash, flag);
         this.SetRecvTrackingParam(parameter.name + ":" + (object) flag, index);
       }
     }
   }
 }
Beispiel #40
0
 private void ReadParameters(NetworkReader reader, bool autoSend)
 {
     for (int i = 0; i < this.m_Animator.parameters.Length; i++)
     {
         if (!autoSend || this.GetParameterAutoSend(i))
         {
             AnimatorControllerParameter parameter = this.m_Animator.parameters[i];
             if (parameter.type == AnimatorControllerParameterType.Int)
             {
                 int num2 = (int) reader.ReadPackedUInt32();
                 this.m_Animator.SetInteger(parameter.nameHash, num2);
                 this.SetRecvTrackingParam(parameter.name + ":" + num2, i);
             }
             if (parameter.type == AnimatorControllerParameterType.Float)
             {
                 float num3 = reader.ReadSingle();
                 this.m_Animator.SetFloat(parameter.nameHash, num3);
                 this.SetRecvTrackingParam(parameter.name + ":" + num3, i);
             }
             if (parameter.type == AnimatorControllerParameterType.Bool)
             {
                 bool flag = reader.ReadBoolean();
                 this.m_Animator.SetBool(parameter.nameHash, flag);
                 this.SetRecvTrackingParam(parameter.name + ":" + flag, i);
             }
         }
     }
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.netId     = reader.ReadNetworkId();
     this.authority = reader.ReadBoolean();
 }
Beispiel #42
0
    private void ReceiveSetWall(NetworkReader reader)
    {
        byte tile = reader.ReadByte();
        bool wall = reader.ReadBoolean();

        if (hosting)
        {
            SendAll(SetWallMessage(tile, wall));
        }

        if (world.walls.Contains(tile) != wall)
        {
            audio.PlayOneShot(placeSound);

            if (wall)
            {
                world.walls.Add(tile);
            }
            else
            {
                world.walls.Remove(tile);
            }
        }

        worldView.RefreshWalls();
    }
Beispiel #43
0
 public override void Deserialize(NetworkReader reader)
 {
     slotId     = reader.ReadByte();
     readyState = reader.ReadBoolean();
 }
Beispiel #44
0
 public void Deserialize(ref NetworkReader reader, IEntityReferenceSerializer refSerializer, int tick)
 {
     activeAllowed  = reader.ReadBoolean() ? 1 : 0;
     requestsActive = reader.ReadBoolean() ? 1 : 0;
 }
Beispiel #45
0
    // client-side deserialization
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        // read position, speed and movement type
        Vector2 position = reader.ReadVector2();

        agent.speed = reader.ReadSingle();
        bool hasPath = reader.ReadBoolean();

        // click or wasd movement?
        if (hasPath)
        {
            // read destination and stopping distance
            Vector2 destination      = reader.ReadVector2();
            float   stoppingDistance = reader.ReadSingle();
            //Debug.Log("OnDeserialize: click: " + destination);

            // try setting destination if on navmesh
            // (might not be while falling from the sky after joining etc.)
            if (agent.isOnNavMesh)
            {
                agent.stoppingDistance = stoppingDistance;
                agent.destination      = destination;
            }
            else
            {
                Debug.LogWarning("NetworkNavMeshAgent.OnDeserialize: agent not on NavMesh, name=" + name + " position=" + transform.position + " destination=" + destination);
            }

            requiredVelocity = Vector2.zero; // reset just to be sure
        }
        else
        {
            // read velocity
            Vector2 velocity = reader.ReadVector2();
            //Debug.Log("OnDeserialize: wasd: " + velocity);

            // cancel path if we are already doing click movement, otherwise
            // we will slide
            // => important if agent.Reset was called too. otherwise we it keeps
            //    sliding.
            // => ResetPath and not ResetMovement because we really only want to
            //    reset the path and not mess with velocity until Update()
            agent.ResetPath();

            // apply required velocity in Update later
            requiredVelocity = velocity;
        }

        // rubberbanding: if we are too far off because of a rapid position
        // change or latency, then warp
        // -> agent moves 'speed' meter per seconds
        // -> if we are speed * 2 units behind, then we teleport
        //    (using speed is better than using a hardcoded value)
        // -> we use speed * 2 for update/network latency tolerance. player
        //    might have moved quit a bit already before OnSerialize was called
        //    on the server.
        if (Vector2.Distance(transform.position, position) > agent.speed * 2 && agent.isOnNavMesh)
        {
            agent.Warp(position);
            //Debug.Log(name + " rubberbanding to " + position);
        }
    }
 public override void Deserialize(NetworkReader reader)
 {
     isJustDoIt = reader.ReadBoolean();
 }