Beispiel #1
0
        public static object ReadVariable(this ZPackage zp, Type t)
        {
            if (t == typeof(int))
            {
                return(zp.ReadInt());
            }
            if (t == typeof(uint))
            {
                return(zp.ReadUInt());
            }
            if (t == typeof(bool))
            {
                return(zp.ReadBool());
            }
            if (t == typeof(char))
            {
                return(zp.ReadChar());
            }
            if (t == typeof(sbyte))
            {
                return(zp.ReadSByte());
            }
            if (t == typeof(long))
            {
                return(zp.ReadLong());
            }
            if (t == typeof(ulong))
            {
                return(zp.ReadULong());
            }
            if (t == typeof(float))
            {
                return(zp.ReadSingle());
            }
            if (t == typeof(double))
            {
                return(zp.ReadDouble());
            }
            if (t == typeof(string))
            {
                return(zp.ReadString());
            }

            return(null);
        }
Beispiel #2
0
 // Token: 0x06000918 RID: 2328 RVA: 0x0004377C File Offset: 0x0004197C
 public static void Deserialize(ParameterInfo[] paramInfo, ZPackage pkg, ref List <object> parameters)
 {
     for (int i = 1; i < paramInfo.Length; i++)
     {
         ParameterInfo parameterInfo = paramInfo[i];
         if (parameterInfo.ParameterType == typeof(int))
         {
             parameters.Add(pkg.ReadInt());
         }
         else if (parameterInfo.ParameterType == typeof(uint))
         {
             parameters.Add(pkg.ReadUInt());
         }
         else if (parameterInfo.ParameterType == typeof(long))
         {
             parameters.Add(pkg.ReadLong());
         }
         else if (parameterInfo.ParameterType == typeof(float))
         {
             parameters.Add(pkg.ReadSingle());
         }
         else if (parameterInfo.ParameterType == typeof(double))
         {
             parameters.Add(pkg.ReadDouble());
         }
         else if (parameterInfo.ParameterType == typeof(bool))
         {
             parameters.Add(pkg.ReadBool());
         }
         else if (parameterInfo.ParameterType == typeof(string))
         {
             parameters.Add(pkg.ReadString());
         }
         else if (parameterInfo.ParameterType == typeof(ZPackage))
         {
             parameters.Add(pkg.ReadPackage());
         }
         else if (parameterInfo.ParameterType == typeof(List <string>))
         {
             int           num  = pkg.ReadInt();
             List <string> list = new List <string>(num);
             for (int j = 0; j < num; j++)
             {
                 list.Add(pkg.ReadString());
             }
             parameters.Add(list);
         }
         else if (parameterInfo.ParameterType == typeof(Vector3))
         {
             Vector3 vector = new Vector3(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle());
             parameters.Add(vector);
         }
         else if (parameterInfo.ParameterType == typeof(Quaternion))
         {
             Quaternion quaternion = new Quaternion(pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle(), pkg.ReadSingle());
             parameters.Add(quaternion);
         }
         else if (parameterInfo.ParameterType == typeof(ZDOID))
         {
             parameters.Add(pkg.ReadZDOID());
         }
         else if (parameterInfo.ParameterType == typeof(HitData))
         {
             HitData hitData = new HitData();
             hitData.Deserialize(ref pkg);
             parameters.Add(hitData);
         }
     }
 }
Beispiel #3
0
    // Token: 0x06000793 RID: 1939 RVA: 0x0003BE94 File Offset: 0x0003A094
    public void Load(ZPackage pkg, int version)
    {
        this.m_ownerRevision = pkg.ReadUInt();
        this.m_dataRevision  = pkg.ReadUInt();
        this.m_persistent    = pkg.ReadBool();
        this.m_owner         = pkg.ReadLong();
        this.m_timeCreated   = pkg.ReadLong();
        this.m_pgwVersion    = pkg.ReadInt();
        if (version >= 16 && version < 24)
        {
            pkg.ReadInt();
        }
        if (version >= 23)
        {
            this.m_type = (ZDO.ObjectType)pkg.ReadSByte();
        }
        if (version >= 22)
        {
            this.m_distant = pkg.ReadBool();
        }
        if (version < 13)
        {
            pkg.ReadChar();
            pkg.ReadChar();
        }
        if (version >= 17)
        {
            this.m_prefab = pkg.ReadInt();
        }
        this.m_sector   = pkg.ReadVector2i();
        this.m_position = pkg.ReadVector3();
        this.m_rotation = pkg.ReadQuaternion();
        int num = (int)pkg.ReadChar();

        if (num > 0)
        {
            this.InitFloats();
            for (int i = 0; i < num; i++)
            {
                int key = pkg.ReadInt();
                this.m_floats[key] = pkg.ReadSingle();
            }
        }
        else
        {
            this.ReleaseFloats();
        }
        int num2 = (int)pkg.ReadChar();

        if (num2 > 0)
        {
            this.InitVec3();
            for (int j = 0; j < num2; j++)
            {
                int key2 = pkg.ReadInt();
                this.m_vec3[key2] = pkg.ReadVector3();
            }
        }
        else
        {
            this.ReleaseVec3();
        }
        int num3 = (int)pkg.ReadChar();

        if (num3 > 0)
        {
            this.InitQuats();
            for (int k = 0; k < num3; k++)
            {
                int key3 = pkg.ReadInt();
                this.m_quats[key3] = pkg.ReadQuaternion();
            }
        }
        else
        {
            this.ReleaseQuats();
        }
        int num4 = (int)pkg.ReadChar();

        if (num4 > 0)
        {
            this.InitInts();
            for (int l = 0; l < num4; l++)
            {
                int key4 = pkg.ReadInt();
                this.m_ints[key4] = pkg.ReadInt();
            }
        }
        else
        {
            this.ReleaseInts();
        }
        int num5 = (int)pkg.ReadChar();

        if (num5 > 0)
        {
            this.InitLongs();
            for (int m = 0; m < num5; m++)
            {
                int key5 = pkg.ReadInt();
                this.m_longs[key5] = pkg.ReadLong();
            }
        }
        else
        {
            this.ReleaseLongs();
        }
        int num6 = (int)pkg.ReadChar();

        if (num6 > 0)
        {
            this.InitStrings();
            for (int n = 0; n < num6; n++)
            {
                int key6 = pkg.ReadInt();
                this.m_strings[key6] = pkg.ReadString();
            }
        }
        else
        {
            this.ReleaseStrings();
        }
        if (version < 17)
        {
            this.m_prefab = this.GetInt("prefab", 0);
        }
    }
Beispiel #4
0
    // Token: 0x060007D3 RID: 2003 RVA: 0x0003D98C File Offset: 0x0003BB8C
    private void RPC_ZDOData(ZRpc rpc, ZPackage pkg)
    {
        ZDOMan.ZDOPeer zdopeer = this.FindPeer(rpc);
        if (zdopeer == null)
        {
            ZLog.Log("ZDO data from unkown host, ignoring");
            return;
        }
        float    time = Time.time;
        int      num  = 0;
        ZPackage pkg2 = new ZPackage();
        int      num2 = pkg.ReadInt();

        for (int i = 0; i < num2; i++)
        {
            ZDOID id  = pkg.ReadZDOID();
            ZDO   zdo = this.GetZDO(id);
            if (zdo != null)
            {
                zdo.InvalidateSector();
            }
        }
        for (;;)
        {
            ZDOID zdoid = pkg.ReadZDOID();
            if (zdoid.IsNone())
            {
                break;
            }
            num++;
            uint    num3   = pkg.ReadUInt();
            uint    num4   = pkg.ReadUInt();
            long    owner  = pkg.ReadLong();
            Vector3 vector = pkg.ReadVector3();
            pkg.ReadPackage(ref pkg2);
            ZDO  zdo2 = this.GetZDO(zdoid);
            bool flag = false;
            if (zdo2 != null)
            {
                if (num4 <= zdo2.m_dataRevision)
                {
                    if (num3 > zdo2.m_ownerRevision)
                    {
                        zdo2.m_owner          = owner;
                        zdo2.m_ownerRevision  = num3;
                        zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(num4, num3, time);
                        continue;
                    }
                    continue;
                }
            }
            else
            {
                zdo2 = this.CreateNewZDO(zdoid, vector);
                flag = true;
            }
            zdo2.m_ownerRevision = num3;
            zdo2.m_dataRevision  = num4;
            zdo2.m_owner         = owner;
            zdo2.InternalSetPosition(vector);
            zdopeer.m_zdos[zdoid] = new ZDOMan.ZDOPeer.PeerZDOInfo(zdo2.m_dataRevision, zdo2.m_ownerRevision, time);
            zdo2.Deserialize(pkg2);
            if (ZNet.instance.IsServer() && flag && this.m_deadZDOs.ContainsKey(zdoid))
            {
                zdo2.SetOwner(this.m_myid);
                this.DestroyZDO(zdo2);
            }
        }
        this.m_zdosRecv += num;
    }
Beispiel #5
0
    public void Load(ZPackage pkg, int version)
    {
        this.m_ownerRevision = pkg.ReadUInt();
        this.m_dataRevision  = pkg.ReadUInt();
        this.m_persistent    = pkg.ReadBool();
        this.m_owner         = pkg.ReadLong();
        this.m_timeCreated   = pkg.ReadLong();
        this.m_pgwVersion    = pkg.ReadInt();
        if (version >= 16 && version < 24)
        {
            pkg.ReadInt();
        }
        if (version >= 23)
        {
            this.m_type = (ZDO.ObjectType)pkg.ReadSByte();
        }
        if (version >= 22)
        {
            this.m_distant = pkg.ReadBool();
        }
        if (version < 13)
        {
            int num1 = (int)pkg.ReadChar();
            int num2 = (int)pkg.ReadChar();
        }
        if (version >= 17)
        {
            this.m_prefab = pkg.ReadInt();
        }
        this.m_sector   = pkg.ReadVector2i();
        this.m_position = pkg.ReadVector3();
        this.m_rotation = pkg.ReadQuaternion();
        int num3 = (int)pkg.ReadChar();

        if (num3 > 0)
        {
            this.InitFloats();
            for (int index = 0; index < num3; ++index)
            {
                this.m_floats[pkg.ReadInt()] = pkg.ReadSingle();
            }
        }
        else
        {
            this.ReleaseFloats();
        }
        int num4 = (int)pkg.ReadChar();

        if (num4 > 0)
        {
            this.InitVec3();
            for (int index = 0; index < num4; ++index)
            {
                this.m_vec3[pkg.ReadInt()] = pkg.ReadVector3();
            }
        }
        else
        {
            this.ReleaseVec3();
        }
        int num5 = (int)pkg.ReadChar();

        if (num5 > 0)
        {
            this.InitQuats();
            for (int index = 0; index < num5; ++index)
            {
                this.m_quats[pkg.ReadInt()] = pkg.ReadQuaternion();
            }
        }
        else
        {
            this.ReleaseQuats();
        }
        int num6 = (int)pkg.ReadChar();

        if (num6 > 0)
        {
            this.InitInts();
            for (int index = 0; index < num6; ++index)
            {
                this.m_ints[pkg.ReadInt()] = pkg.ReadInt();
            }
        }
        else
        {
            this.ReleaseInts();
        }
        int num7 = (int)pkg.ReadChar();

        if (num7 > 0)
        {
            this.InitLongs();
            for (int index = 0; index < num7; ++index)
            {
                this.m_longs[pkg.ReadInt()] = pkg.ReadLong();
            }
        }
        else
        {
            this.ReleaseLongs();
        }
        int num8 = (int)pkg.ReadChar();

        if (num8 > 0)
        {
            this.InitStrings();
            for (int index = 0; index < num8; ++index)
            {
                this.m_strings[pkg.ReadInt()] = pkg.ReadString();
            }
        }
        else
        {
            this.ReleaseStrings();
        }
        if (version >= 17)
        {
            return;
        }
        this.m_prefab = this.GetInt("prefab", 0);
    }