Beispiel #1
0
        public Town()
        {
            var save    = MainSaveFile.Singleton();
            var offsets = MainOffsets.GetOffsets(save.GetRevision());

            // Load Town Data
            TownId = save.ReadStruct <TownID>(offsets.Offset_TownId);

            // Load Villagers
            for (var i = 0; i < 10; i++)
            {
                Villagers[i] = new Villager(i);
            }

            // Load Patterns
            for (var i = 0; i < 50; i++)
            {
                Patterns[i] = new DesignPattern(i);
            }

            // Load Buildings
            for (var i = 0; i < 46; i++)
            {
                Buildings[i] = new Building(i);
            }
        }
Beispiel #2
0
        public Town(MainSaveFile saveFile)
        {
            SaveFile = saveFile;
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            // Load Town Data
            TownId = SaveFile.ReadStruct <TownID>(offsets.Offset_TownId);

            // Load Villagers
            for (var i = 0; i < 10; i++)
            {
                Villagers[i] = new Villager(saveFile, i);
            }

            // Load Patterns
            for (var i = 0; i < 50; i++)
            {
                Patterns[i] = new DesignPattern(saveFile, i);
            }

            // Load Buildings
            for (var i = 0; i < 46; i++)
            {
                Buildings[i] = new Building(saveFile, i);
            }

            StalkMarket = new StalkMarket(SaveFile);
        }
Beispiel #3
0
        public Villager(ISaveFile saveFile, int idx)
        {
            SaveFile = saveFile;
            Index    = idx;

            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            Offset = offsets.Offset_Vilagers + idx * offsets.Villager_Size;

            Species     = SaveFile.ReadU8(Offset + offsets.Villager_Species);
            VariantIdx  = SaveFile.ReadU8(Offset + offsets.Villager_Variant);
            Personality = SaveFile.ReadU8(Offset + offsets.Villager_Personality);
            Catchphrase = SaveFile.ReadString(Offset + offsets.Villager_Catchphrase, offsets.Villager_CatchphraseLength); // Not sure about the size.

            var ftr = new Item[offsets.Villager_FurnitureCount];

            for (var i = 0; i < ftr.Length; i++)
            {
                ftr[i] = new Item(SaveFile, Offset + offsets.Villager_Furniture + i * 0x2C);
            }
            Furniture = new ItemCollection(ftr);

            Wallpaper = new ItemCollection(new Item[1] {
                new Item(SaveFile, Offset + offsets.Villager_Wallpaper)
            });
            Flooring = new ItemCollection(new Item[1] {
                new Item(SaveFile, Offset + offsets.Villager_Flooring)
            });
        }
Beispiel #4
0
        public void Save(ISaveFile saveFile, int index)
        {
            var offsets = MainOffsets.GetOffsets(saveFile.GetRevision());

            if (index >= offsets.Building_Count)
            {
                throw new IndexOutOfRangeException("Index was greater than the number of building slots!");
            }
            saveFile.WriteStruct(offsets.Offset_Buildings + index * 0x14, this);
        }
Beispiel #5
0
        public Building(ISaveFile saveFile, int index)
        {
            var offsets = MainOffsets.GetOffsets(saveFile.GetRevision());

            if (index >= offsets.Building_Count)
            {
                throw new IndexOutOfRangeException("Index was greater than the number of building slots!");
            }
            this = saveFile.ReadStruct <Building>(offsets.Offset_Buildings + index * 0x14);
        }
Beispiel #6
0
        public void Save()
        {
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            SaveFile.WriteString(Offset + offsets.Pattern_Name, Name, 20);
            SaveFile.WriteStruct(Offset + offsets.Pattern_PersonalID, PersonalID);

            for (int i = 0; i < 15; i++)
            {
                SaveFile.WriteStruct(Offset + offsets.Pattern_Palette + i * 3, Palette[i]);
            }

            SaveFile.WriteArray(Offset + offsets.Pattern_ImageData, Pixels);
        }
Beispiel #7
0
        public void Save()
        {
            var save    = MainSaveFile.Singleton();
            var offsets = MainOffsets.GetOffsets(save.GetRevision());

            save.WriteU8(Offset + offsets.Villager_Species, Species);
            save.WriteU8(Offset + offsets.Villager_Variant, VariantIdx);
            save.WriteU8(Offset + offsets.Villager_Personality, Personality);
            save.WriteString(Offset + offsets.Villager_Catchphrase, Catchphrase, 12);

            for (var i = 0; i < Furniture.Count; i++)
            {
                Furniture[i].Save(save, Offset + offsets.Villager_Furniture + i * 0x2C);
            }
        }
Beispiel #8
0
        public void Save()
        {
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            SaveFile.WriteU8(Offset + offsets.Villager_Species, Species);
            SaveFile.WriteU8(Offset + offsets.Villager_Variant, VariantIdx);
            SaveFile.WriteU8(Offset + offsets.Villager_Personality, Personality);
            SaveFile.WriteString(Offset + offsets.Villager_Catchphrase, Catchphrase, 12);

            for (var i = 0; i < Furniture.Count; i++)
            {
                Furniture[i].Save(SaveFile, Offset + offsets.Villager_Furniture + i * 0x2C);
            }
            Wallpaper[0].Save(SaveFile, Offset + offsets.Villager_Wallpaper);
            Flooring[0].Save(SaveFile, Offset + offsets.Villager_Flooring);
        }
Beispiel #9
0
        public void SetIsMovingOut(bool movingOut)
        {
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());
            var flags   = SaveFile.ReadU8(Offset + offsets.Villager_StateFlags);

            if (movingOut)
            {
                flags |= (byte)offsets.Villager_StateFlagMovingOut;
            }
            else
            {
                flags &= (byte)~offsets.Villager_StateFlagMovingOut;
            }
            SaveFile.WriteU8(Offset + offsets.Villager_StateFlags, flags);
            // TODO: StateFlags + 0x10 always? changes from 0x0A => 0x00 when moving out. Not sure if that's needed.
        }
Beispiel #10
0
        public DesignPattern(ISaveFile saveFile, int idx)
        {
            SaveFile = saveFile;
            Index    = idx;
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            Offset = offsets.Offset_Patterns + idx * offsets.Pattern_Size;

            Name       = SaveFile.ReadString(Offset + offsets.Pattern_Name, 20);
            PersonalID = SaveFile.ReadStruct <PersonalID>(Offset + offsets.Pattern_PersonalID);

            for (int i = 0; i < 15; i++)
            {
                Palette[i] = new DesignColor(saveFile, Offset + offsets.Pattern_Palette + i * 3);
            }

            Pixels = SaveFile.ReadArray <byte>(Offset + offsets.Pattern_ImageData, Pixels.Length);
        }
Beispiel #11
0
        public Villager(int idx)
        {
            Index = idx;
            var save    = MainSaveFile.Singleton();
            var offsets = MainOffsets.GetOffsets(save.GetRevision());

            Offset = offsets.Offset_Vilagers + idx * offsets.Villager_Size;

            Species     = save.ReadU8(Offset + offsets.Villager_Species);
            VariantIdx  = save.ReadU8(Offset + offsets.Villager_Variant);
            Personality = save.ReadU8(Offset + offsets.Villager_Personality);
            Catchphrase = save.ReadString(Offset + offsets.Villager_Catchphrase, offsets.Villager_CatchphraseLength); // Not sure about the size.

            var ftr = new Item[offsets.Villager_FurnitureCount];

            for (var i = 0; i < ftr.Length; i++)
            {
                ftr[i] = new Item(save, Offset + offsets.Villager_Furniture + i * 0x2C);
            }
            Furniture = new ItemCollection(ftr);
        }
Beispiel #12
0
        public bool IsMovingOut()
        {
            var offsets = MainOffsets.GetOffsets(SaveFile.GetRevision());

            return((SaveFile.ReadU8(Offset + offsets.Villager_StateFlags) & offsets.Villager_StateFlagMovingOut) != 0);
        }
Beispiel #13
0
        public StalkMarket(ISaveFile saveFile)
        {
            var offsets = MainOffsets.GetOffsets(saveFile.GetRevision());

            this = saveFile.ReadStruct <StalkMarket>(offsets.Offset_Turnips);
        }