public static EffectData Deserialize(Stream stream)
    {
        EffectData effectDatum = Pool.Get <EffectData>();

        EffectData.Deserialize(stream, effectDatum, false);
        return(effectDatum);
    }
 public static EffectData Deserialize(byte[] buffer, EffectData instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         EffectData.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
    public static EffectData Deserialize(byte[] buffer)
    {
        EffectData effectDatum = Pool.Get <EffectData>();

        using (MemoryStream memoryStream = new MemoryStream(buffer))
        {
            EffectData.Deserialize(memoryStream, effectDatum, false);
        }
        return(effectDatum);
    }
Example #4
0
 public Effect(Packet p)
 {
     protobuf = EffectData.Deserialize(p);
 }
 public void FromProto(Stream stream, bool isDelta = false)
 {
     EffectData.Deserialize(stream, this, isDelta);
 }
Example #6
0
            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                serializer.ContractResolver = new JsonResolver();
                var packet = (Packet)value;

                writer.WriteStartObject();
                Action <string, object> Serialize = (string name, object obj) => {
                    writer.WritePropertyName(name);
                    serializer.Serialize(writer, obj);
                };

                if (Informative)
                {
                    Serialize("ID", packet.packetID);
                    Serialize("Name", packet.GetName());
                    Serialize("Type", packet.GetPacketTypeName());
                    Serialize("Origin", packet.GetOrigin());
                    Serialize("Delay", packet.delay);
                }
                else
                {
                    Serialize("ID", packet.packetID);
                    Serialize("TypeID", packet.type);
                    Serialize("Length", packet.incomingLength);
                    Serialize("GUID", packet.incomingGUID);
                    Serialize("Data", packet.baseStream.ToArray());
                }
                if (packet.length > 1 && Informative)
                {
                    if (packet.type == Packet.PacketType.RUST)
                    {
                        writer.WritePropertyName("Content");
                        writer.WriteStartObject();
                        packet.Position = 1;
                        switch (packet.rustID)
                        {
                        case Packet.Rust.Approved:
                            Serialize("ProtoBuf", ProtoBuf.Approval.Deserialize(packet));
                            break;

                        case Packet.Rust.Auth:
                            var bytes = packet.BytesWithSize();
                            Serialize("AuthData", BitConverter.ToString(bytes).Replace("-", ""));
                            break;

                        case Packet.Rust.ConsoleCommand:
                            Serialize("Command", packet.String());
                            break;

                        case Packet.Rust.ConsoleMessage:
                            Serialize("Message", packet.String());
                            break;

                        case Packet.Rust.DisconnectReason:
                            Serialize("Reason", packet.String());
                            break;

                        case Packet.Rust.Effect:
                            Serialize("ProtoBuf", EffectData.Deserialize(packet));
                            break;

                        case Packet.Rust.Entities:
                            Serialize("Num", packet.UInt32());
                            Serialize("ProtoBuf", ProtoBuf.Entity.Deserialize(packet));
                            break;

                        case Packet.Rust.EntityDestroy:
                            Serialize("UID", packet.UInt32());
                            Serialize("Destroy Mode", packet.UInt8());
                            break;

                        case Packet.Rust.EntityPosition:
                            writer.WritePropertyName("Entity Positions");
                            writer.WriteStartArray();
                            while (packet.unread >= 28L)
                            {
                                writer.WriteStartObject();
                                Serialize("Entity ID", packet.EntityID());
                                Serialize("Position", packet.Vector3());
                                Serialize("Rotation", packet.Vector3());
                                writer.WriteEndObject();
                            }
                            writer.WriteEndArray();
                            break;

                        case Packet.Rust.GiveUserInformation:
                            Serialize("ProtocolVersion", packet.UInt8());
                            Serialize("Steam ID", packet.UInt64());
                            Serialize("Protocol", packet.UInt32());
                            Serialize("OS Name", packet.String());
                            Serialize("Steam Name", packet.String());
                            Serialize("Branch", packet.String());
                            break;

                        case Packet.Rust.GroupChange:
                            Serialize("Entity ID", packet.EntityID());
                            Serialize("Group ID", packet.GroupID());
                            break;

                        case Packet.Rust.GroupDestroy:
                            Serialize("Group ID", packet.GroupID());

                            break;

                        case Packet.Rust.GroupEnter:
                            Serialize("Group ID", packet.GroupID());
                            break;

                        case Packet.Rust.GroupLeave:
                            Serialize("Group ID", packet.GroupID());
                            break;

                        case Packet.Rust.Message:
                            Serialize("String 1 (PlayerName?)", packet.String());
                            Serialize("String 2 (PlayerMsg?)", packet.String());
                            break;

                        case Packet.Rust.RPCMessage:
                            Serialize("UID", packet.UInt32());
                            Serialize("Name ID", packet.UInt32());
                            Serialize("Source Connection", packet.UInt64());
                            break;

                        case Packet.Rust.Ready:
                            Serialize("ProtoBuf", ProtoBuf.ClientReady.Deserialize(packet));
                            break;

                        case Packet.Rust.Tick:
                            Serialize("ProtoBuf", PlayerTick.Deserialize(packet));
                            break;

                        default:
                            break;
                        }
                        writer.WriteEndObject();
                    }
                }

                writer.WriteEndObject();
            }