Example #1
0
            public static AStarSquare Read(byte[] data, int offset)
            {
                var template = new AStarSquare();

                template.VTable = BitConverter.ToUInt32(data, offset + 0x0);
                template.X      = BitConverter.ToUInt32(data, offset + 0x4);
                template.Y      = BitConverter.ToUInt32(data, offset + 0x8);
                return(template);
            }
Example #2
0
        public static Square Read(byte[] data, int offset, ProcessMemory memory)
        {
            // 1.0.3.1 (hotfix)
            var square = new Square();

            square.Tile        = (Tile)data[offset + 0x00];
            square.Room        = data[offset + 0x01];
            square.Unknown02   = BitConverter.ToUInt16(data, offset + 0x02);
            square.Unknown04   = BitConverter.ToUInt32(data, offset + 0x04);
            square.Unknown08   = data[offset + 0x08];
            square.Unknown0C   = BitConverter.ToUInt32(data, offset + 0x0C);
            square.Unknown10   = BitConverter.ToUInt32(data, offset + 0x10);
            square.Unknown14   = BitConverter.ToUInt32(data, offset + 0x14);
            square.Unknown18   = BitConverter.ToUInt32(data, offset + 0x18);
            square.Unknown1C   = BitConverter.ToUInt32(data, offset + 0x1C);
            square.Unknown20   = BitConverter.ToUInt32(data, offset + 0x20);
            square.Unknown24   = BitConverter.ToUInt32(data, offset + 0x24);
            square.Unknown28   = BitConverter.ToUInt32(data, offset + 0x28);
            square.Effects     = StdList.Read(data, offset + 0x2C, memory);
            square.Mines       = StdList.Read(data, offset + 0x38, memory);
            square.Objects     = StdList.Read(data, offset + 0x44, memory);
            square.Pathfinding = AStarSquare.Read(data, offset + 0x50);

            if (square.Unknown02 != 0)
            {
                throw new FormatException();
            }

            square.HasDredmorStatue = false;
            square.HasUberChest     = false;
            square.BossMonsterName  = null;
            square.QuestItemName    = null;

            foreach (var element in square.Objects.Elements)
            {
                var objectType = (ClassVTableAddress)memory.ReadU32(element);
                switch (objectType)
                {
                case ClassVTableAddress.DredmorStatue:
                {
                    square.HasDredmorStatue = true;
                    break;
                }

                case ClassVTableAddress.UberChest:
                {
                    square.HasUberChest = true;
                    break;
                }

                case ClassVTableAddress.Monster:
                {
                    if (square.BossMonster.HasValue == false)
                    {
                        if (memory.ReadU32(element + 0x11C) == 1)
                        {
                            square.BossMonster     = element;
                            square.BossMonsterName = StdString.Read(memory, element + 0x434);
                        }

                        /*
                         * else
                         * {
                         *  var templatePointer = memory.ReadU32(element + 0x388);
                         *  if (templatePointer == 0)
                         *  {
                         *      name = "Monster";
                         *  }
                         *  else
                         *  {
                         *      name = StdString.Read(memory, templatePointer + 0x64);
                         *  }
                         * }
                         */
                    }

                    break;
                }

                case ClassVTableAddress.Misc:
                {
                    if (square.QuestItem.HasValue == false)
                    {
                        // quest item
                        if (memory.ReadU32(element + 0x6C) == 3)
                        {
                            square.QuestItem     = element;
                            square.QuestItemName = StdString.Read(memory, element + 0x254);
                        }
                    }

                    break;
                }
                }
            }

            return(square);
        }