Exemple #1
0
        public D3Actor(MemoryReader memReader, uint ptr, byte[] data)
        {
            this.Pointer   = ptr;
            this.ActorID   = BitConverter.ToInt32(data, 0);
            this.AcdID     = BitConverter.ToUInt32(data, 4);
            this.ModelName = ProcessUtils.AsciiBytesToString(data, 8, 128);
            this.SnoID     = BitConverter.ToInt32(data, 136);
            this.Direction = new Vector2f(data, 152);
            this.Pos1      = new Vector3f(data, 160);
            this.Unk2      = BitConverter.ToSingle(data, 172);
            this.Pos2      = new Vector3f(data, 176);
            this.WorldID   = BitConverter.ToUInt32(data, 216);
            this.Unk3      = BitConverter.ToUInt32(data, 344);

            // ActorCommonData
            if (this.AcdID != Offsets.INVALID)
            {
                uint acdPtr = memReader.IDToPtr(memReader.pACDs, Offsets.SIZEOF_ACD, this.AcdID);
                if (acdPtr != 0 && acdPtr != Offsets.INVALID)
                {
                    this.Acd = new D3ActorCommonData(memReader, acdPtr, memReader.D3.ReadBytes(acdPtr, Offsets.SIZEOF_ACD));
                }
            }

            // MovementInfo
            uint movementPtr = BitConverter.ToUInt32(data, 896);

            if (movementPtr != 0 && movementPtr != Offsets.INVALID)
            {
                this.MovementInfo = new D3MovementInfo(movementPtr, memReader.D3.ReadBytes(movementPtr, Offsets.SIZEOF_MOVEMENTINFO));
            }
        }
Exemple #2
0
        public Dictionary <int, D3ActorCommonData> GetACDs()
        {
            // Grab the size of the ActorCommonData array
            int arraySize = ReadInt(pACDs + Offsets.ARRAY_SIZE_OFFSET);

            if (arraySize == 0)
            {
                return(new Dictionary <int, D3ActorCommonData>(0));
            }

            uint v0 = ReadUInt(pACDs + Offsets.ARRAY_START_PTR_OFFSET);
            int  v1 = ReadInt(pACDs + Offsets.ARRAY_HASHING_OFFSET);

            Dictionary <int, D3ActorCommonData> acds = new Dictionary <int, D3ActorCommonData>(arraySize);

            for (uint i = 0; i < arraySize; i++)
            {
                uint ptr = ReadUInt(v0 + 4 * (i >> v1)) + Offsets.SIZEOF_ACD * (uint)(i & ((1 << v1) - 1));
                if (ReadUInt(ptr) != Offsets.INVALID)
                {
                    D3ActorCommonData acd = GetACD(ptr);
                    if (acd != null)
                    {
                        acds.Add(acd.AcdID, acd);
                    }
                }
            }

            return(acds);
        }