コード例 #1
0
ファイル: SteamChannel.cs プロジェクト: sky-xk-nge/Unturned
        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);
            }
        }