示例#1
0
        public void receive(CSteamID steamID, byte[] packet, int offset, int size)
        {
            if (SteamChannel.onTriggerReceive != null)
            {
                SteamChannel.onTriggerReceive(this, steamID, packet, offset, size);
            }
            if (size < 2)
            {
                return;
            }
            int num = (int)packet[offset + 1];

            if (num < 0 || num >= this.calls.Length)
            {
                return;
            }
            ESteamPacket esteamPacket = (ESteamPacket)packet[offset];

            if (esteamPacket == ESteamPacket.UPDATE_VOICE && size < 5)
            {
                return;
            }
            if (esteamPacket == ESteamPacket.UPDATE_UNRELIABLE_CHUNK_BUFFER || esteamPacket == ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER)
            {
                SteamPacker.openRead(offset + 2, packet);
                this.calls[num].method.Invoke(this.calls[num].component, new object[]
                {
                    steamID
                });
                SteamPacker.closeRead();
            }
            else if (this.calls[num].types.Length > 0)
            {
                if (esteamPacket == ESteamPacket.UPDATE_VOICE)
                {
                    SteamChannel.voice[0] = steamID;
                    SteamChannel.voice[1] = packet;
                    SteamChannel.voice[2] = (int)BitConverter.ToUInt16(packet, offset + 2);
                    this.calls[num].method.Invoke(this.calls[num].component, SteamChannel.voice);
                }
                else
                {
                    object[] objects = SteamPacker.getObjects(steamID, offset, 2, packet, this.calls[num].types);
                    if (objects != null)
                    {
                        this.calls[num].method.Invoke(this.calls[num].component, objects);
                    }
                }
            }
            else
            {
                this.calls[num].method.Invoke(this.calls[num].component, null);
            }
        }
 public override void updateState(Asset asset, byte[] state)
 {
     this.gunLargeTransform = base.transform.FindChildRecursive("Gun_Large");
     this.gunSmallTransform = base.transform.FindChildRecursive("Gun_Small");
     this.meleeTransform    = base.transform.FindChildRecursive("Melee");
     this.itemTransform     = base.transform.FindChildRecursive("Item");
     this.isLocked          = ((ItemBarricadeAsset)asset).isLocked;
     this._isDisplay        = ((ItemStorageAsset)asset).isDisplay;
     if (Provider.isServer)
     {
         SteamPacker.openRead(0, state);
         this._owner = (CSteamID)SteamPacker.read(Types.STEAM_ID_TYPE);
         this._group = (CSteamID)SteamPacker.read(Types.STEAM_ID_TYPE);
         this._items = new Items(PlayerInventory.STORAGE);
         this.items.resize(((ItemStorageAsset)asset).storage_x, ((ItemStorageAsset)asset).storage_y);
         byte b = (byte)SteamPacker.read(Types.BYTE_TYPE);
         for (byte b2 = 0; b2 < b; b2 += 1)
         {
             if (BarricadeManager.version > 7)
             {
                 object[]  array     = SteamPacker.read(Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.UINT16_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_ARRAY_TYPE);
                 ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, (ushort)array[3]);
                 if (itemAsset != null)
                 {
                     this.items.loadItem((byte)array[0], (byte)array[1], (byte)array[2], new Item((ushort)array[3], (byte)array[4], (byte)array[5], (byte[])array[6]));
                 }
             }
             else
             {
                 object[]  array2     = SteamPacker.read(Types.BYTE_TYPE, Types.BYTE_TYPE, Types.UINT16_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_ARRAY_TYPE);
                 ItemAsset itemAsset2 = (ItemAsset)Assets.find(EAssetType.ITEM, (ushort)array2[2]);
                 if (itemAsset2 != null)
                 {
                     this.items.loadItem((byte)array2[0], (byte)array2[1], 0, new Item((ushort)array2[2], (byte)array2[3], (byte)array2[4], (byte[])array2[5]));
                 }
             }
         }
         if (this.isDisplay)
         {
             this.displaySkin   = (ushort)SteamPacker.read(Types.UINT16_TYPE);
             this.displayMythic = (ushort)SteamPacker.read(Types.UINT16_TYPE);
             if (BarricadeManager.version > 8)
             {
                 this.applyRotation((byte)SteamPacker.read(Types.BYTE_TYPE));
             }
             else
             {
                 this.applyRotation(0);
             }
         }
         this.items.onStateUpdated = new StateUpdated(this.onStateUpdated);
         SteamPacker.closeRead();
         if (this.isDisplay)
         {
             this.updateDisplay();
             this.refreshDisplay();
         }
     }
     else
     {
         Block block = new Block(state);
         this._owner = new CSteamID((ulong)block.read(Types.UINT64_TYPE));
         this._group = new CSteamID((ulong)block.read(Types.UINT64_TYPE));
         if (state.Length > 16)
         {
             object[] array3 = block.read(Types.UINT16_TYPE, Types.BYTE_TYPE, Types.BYTE_ARRAY_TYPE, Types.UINT16_TYPE, Types.UINT16_TYPE, Types.BYTE_TYPE);
             this.applyRotation((byte)array3[5]);
             this.setDisplay((ushort)array3[0], (byte)array3[1], (byte[])array3[2], (ushort)array3[3], (ushort)array3[4]);
         }
     }
 }