Example #1
0
    public static Automap Serdes(Automap map, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }
        int length;

        byte[] bytes = null;
        if (s.IsReading())
        {
            map ??= new Automap();
            length = (int)s.BytesRemaining;
        }
        else
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }
            bytes  = map.AsBytes;
            length = bytes.Length;
        }

        bytes = s.Bytes(null, bytes, length);

        if (s.IsReading())
        {
            map.AsBytes = bytes;
        }

        return(map);
    }
Example #2
0
 static void MaybeDestroyAutomap(Automap automap)
 {
     if (GameplayManager.IsMultiplayerActive && Controls.JustPressed(MPAutomap.binding))
     {
         AccessTools.Field(typeof(Automap), "m_state_timer").SetValue(automap, 0.5f);
         automap.m_automap_state = Automap.AutomapState.EXIT;
         UIManager.DestroyType(UIElementType.MAP_HUD, false);
     }
 }
        public RegionViewModel(Region region)
        {
            Rectangle = Automap.Map <RectangleElement>(region);
            Label     = new TextElement();
            Id        = region.Id;
            Name      = region.Name;
            Image     = region.Thumbnail;

            UpdateLabel();
        }
Example #4
0
        public void Init(Automap mapper)
        {
            this.mapper = mapper;
            this.width  = mapper.Cells.GetLength(1);
            this.height = mapper.Cells.GetLength(0);

            // Tile size
            var rt = grid.transform as RectTransform;

            grid.cellSize = new Vector2(rt.rect.width / width, rt.rect.width / width);

            // Image count needed
            ClearOldTiles();
            CreateTiles();
            Render();
        }
        public void Read(Savegame savegame, SavegameInputFiles files, IFileContainer partyTextsContainer,
                         IFileContainer fallbackPartyMemberContainer = null)
        {
            var partyMemberReader = new Characters.PartyMemberReader();
            var chestReader       = new ChestReader();
            var merchantReader    = new MerchantReader();
            var automapReader     = new AutomapReader();

            savegame.PartyMembers.Clear();
            savegame.Chests.Clear();
            savegame.Merchants.Clear();
            savegame.Automaps.Clear();

            foreach (var partyMemberDataReader in files.PartyMemberDataReaders.Files)
            {
                var partyTextFile = partyTextsContainer.Files.ContainsKey(partyMemberDataReader.Key)
                    ? partyTextsContainer.Files[partyMemberDataReader.Key] : null;
                partyMemberDataReader.Value.Position = 0;
                savegame.PartyMembers.Add((uint)partyMemberDataReader.Key,
                                          PartyMember.Load((uint)partyMemberDataReader.Key, partyMemberReader,
                                                           partyMemberDataReader.Value, partyTextFile,
                                                           fallbackPartyMemberContainer?.Files[partyMemberDataReader.Key]));
            }
            foreach (var chestDataReader in files.ChestDataReaders.Files)
            {
                chestDataReader.Value.Position = 0;
                savegame.Chests.Add((uint)chestDataReader.Key, Chest.Load(chestReader, chestDataReader.Value));
            }
            foreach (var merchantDataReader in files.MerchantDataReaders.Files)
            {
                merchantDataReader.Value.Position = 0;
                savegame.Merchants.Add((uint)merchantDataReader.Key, Merchant.Load(merchantReader, merchantDataReader.Value));
            }
            foreach (var automapDataReader in files.AutomapDataReaders.Files)
            {
                automapDataReader.Value.Position = 0;
                savegame.Automaps.Add((uint)automapDataReader.Key, Automap.Load(automapReader, automapDataReader.Value));
            }

            files.SaveDataReader.Position = 0;
            ReadSaveData(savegame, files.SaveDataReader);
        }
Example #6
0
 public void Init()
 {
     Automap.ConfigureAutoMapper();
 }
Example #7
0
 public void ReadAutomap(Automap automap, IDataReader dataReader)
 {
     automap.ExplorationBits = dataReader.ReadToEnd();
 }
        internal ExteriorBlock(State state, BinaryReader reader, BlockArchive.Record record) : base(state, reader)
        {
            this.ChunkCount = reader.ReadByte();
            int modelCount = reader.ReadByte();
            int flatCount  = reader.ReadByte();

            for (int index = 0; index < Chunks.Length; index++)
            {
                Chunks[index] = new ExteriorChunk(this, reader, index);
            }
            for (int index = 0; index < Chunks.Length; index++)
            {
                Chunks[index].building = new Building(null, this, index, reader);
            }
            for (int index = 0; index < Chunks.Length; index++)
            {
                Chunks[index].Unknowns.Add(reader.ReadUInt16());
                Chunks[index].Unknowns.Add(reader.ReadUInt16());
            }

            int[] chunkSizeList = new int[32];
            for (int index = 0; index < chunkSizeList.Length; index++)
            {
                chunkSizeList[index] = reader.ReadInt32();
            }

            U1 = reader.ReadBytes(8);
            for (int y = 0, yCount = Ground.GetLength(1); y < yCount; y++)
            {
                for (int x = 0, xCount = Ground.GetLength(0); x < xCount; x++)
                {
                    Ground[x, y] = new Ground(reader.ReadByte());
                }
            }
            U2 = reader.ReadBytes(256);

            for (int y = 0, yCount = Automap.GetLength(1); y < yCount; y++)
            {
                for (int x = 0, xCount = Automap.GetLength(0); x < xCount; x++)
                {
                    Automap[x, y] = reader.ReadByte();
                }
            }

            string filename = reader.ReadNulTerminatedAsciiString(13);

            if (filename != record.Key)
            {
                throw new Exception();
            }
            for (int index = 0; index < Chunks.Length; index++)
            {
                Chunks[index].LoadFilename(reader);
            }

            for (int index = 0; index < ChunkCount; index++)
            {
                long start = reader.BaseStream.Position;
                Chunks[index].LoadContents(reader);
                int  required = chunkSizeList[index];
                long size     = reader.BaseStream.Position - start;

                if (size == required - 1)
                {
                    reader.ReadByte();
                    size++;
                }

                if (required != size)
                {
                    throw new Exception();
                }
            }
        }
Example #9
0
 public Region(RectangleElement element) : this()
 {
     Automap.Map(element, this);
 }
Example #10
0
 public void WriteAutomap(Automap automap, IDataWriter dataWriter)
 {
     dataWriter.Write(automap.ExplorationBits);
 }