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); } }
public Player(int idx, PersonalSaveFile personalSave) { _personalFile = personalSave; var offsets = PersonalOffsets.GetOffsets(MainSaveFile.Singleton().GetRevision()); Index = idx; PersonalId = new PersonalID(personalSave, offsets.PersonalId); Wallet = new EncryptedInt32(personalSave, offsets.Wallet); Bank = new EncryptedInt32(personalSave, offsets.Bank); NookMiles = new EncryptedInt32(personalSave, offsets.NookMiles); // TODO: This should be refactored to detect the "expanded pockets" state var pockets = new Item[40]; for (var i = 0; i < 20; i++) { pockets[i] = new Item(personalSave, offsets.Pockets + 0xB8 + i * 8); pockets[i + 20] = new Item(personalSave, offsets.Pockets + i * 8); } Pockets = new ItemCollection(pockets); var storage = new Item[5000]; for (var i = 0; i < 5000; i++) { storage[i] = new Item(personalSave, offsets.Storage + i * 8); } Storage = new ItemCollection(storage); }
public DesignColor(int offset) { var save = MainSaveFile.Singleton(); R = save.ReadU8(offset + 0); G = save.ReadU8(offset + 1); B = save.ReadU8(offset + 2); }
public void Save() { var save = MainSaveFile.Singleton(); var offsets = GetOffsetsFromRevision(); save.WriteU8(Offset + offsets.Species, Species); save.WriteU8(Offset + offsets.Variant, VariantIdx); save.WriteU8(Offset + offsets.Personality, Personality); save.WriteString(Offset + offsets.Catchphrase, Catchphrase, 12); }
public Villager(int idx) { var save = MainSaveFile.Singleton(); var offsets = GetOffsetsFromRevision(); var villagerOffset = offsets.BaseOffset + idx * offsets.Size; Species = save.ReadU8(villagerOffset + offsets.Species); VariantIdx = save.ReadU8(villagerOffset + offsets.Variant); Personality = save.ReadU8(villagerOffset + offsets.Personality); Catchphrase = save.ReadString(villagerOffset + offsets.Catchphrase, 12); // Not sure about the size. }
public void Save(int index) { var save = MainSaveFile.Singleton(); var offsets = MainOffsets.GetOffsets(save.GetRevision()); if (index >= offsets.Building_Count) { throw new IndexOutOfRangeException("Index was greater than the number of building slots!"); } save.WriteStruct(offsets.Offset_Buildings + index * 0x14, this); }
public void Save() { var save = MainSaveFile.Singleton(); var offsets = MainOffsets.GetOffsets(save.GetRevision()); save.WriteString(Offset + offsets.Pattern_Name, Name, 20); save.WriteStruct(Offset + offsets.Pattern_PersonalID, PersonalID); for (int i = 0; i < 15; i++) { save.WriteStruct(Offset + offsets.Pattern_Palette + i * 3, Palette[i]); } save.WriteArray(Offset + offsets.Pattern_ImageData, Pixels); }
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); } }
public void Save() { var save = MainSaveFile.Singleton(); var offsets = GetOffsetsFromRevision(); save.WriteString(Offset + offsets.Name, this.Name, 20); save.WriteStruct <PersonalID>(Offset + offsets.PersonalID, this.PersonalID); for (int i = 0; i < 15; i++) { save.WriteU8(Offset + offsets.Palette + i * 3 + 0, this.Palette[i].R); save.WriteU8(Offset + offsets.Palette + i * 3 + 1, this.Palette[i].G); save.WriteU8(Offset + offsets.Palette + i * 3 + 2, this.Palette[i].B); } save.WriteArray <byte>(Offset + offsets.Image, this.Pixels); }
public DesignPattern(int idx) { Index = idx; var save = MainSaveFile.Singleton(); var offsets = GetOffsetsFromRevision(); Offset = offsets.BaseOffset + idx * offsets.Size; Name = save.ReadString(Offset + offsets.Name, 20); PersonalID = save.ReadStruct <PersonalID>(Offset + offsets.PersonalID); for (int i = 0; i < 15; i++) { Palette[i] = new DesignColor(Offset + offsets.Palette + i * 3); } this.Pixels = save.ReadArray <byte>(Offset + offsets.Image, this.Pixels.Length); }
public DesignPattern(int idx) { Index = idx; var save = MainSaveFile.Singleton(); var offsets = MainOffsets.GetOffsets(save.GetRevision()); Offset = offsets.Offset_Patterns + idx * offsets.Pattern_Size; Name = save.ReadString(Offset + offsets.Pattern_Name, 20); PersonalID = save.ReadStruct <PersonalID>(Offset + offsets.Pattern_PersonalID); for (int i = 0; i < 15; i++) { Palette[i] = new DesignColor(Offset + offsets.Pattern_Palette + i * 3); } Pixels = save.ReadArray <byte>(Offset + offsets.Pattern_ImageData, Pixels.Length); }
public void Save() { var offsets = PersonalOffsets.GetOffsets(MainSaveFile.Singleton().GetRevision()); _personalFile.WriteStruct(offsets.PersonalId, PersonalId); Wallet.Write(_personalFile, offsets.Wallet); Bank.Write(_personalFile, offsets.Bank); NookMiles.Write(_personalFile, offsets.NookMiles); for (var i = 0; i < 20; i++) { Pockets[i].Save(_personalFile, offsets.Pockets + 0xB8 + i * 8); Pockets[i + 20].Save(_personalFile, offsets.Pockets + i * 8); } for (var i = 0; i < 5000; i++) { Storage[i].Save(_personalFile, offsets.Storage + i * 8); } }
public Villager(int idx) { Index = idx; var save = MainSaveFile.Singleton(); var offsets = GetOffsetsFromRevision(); Offset = offsets.BaseOffset + idx * offsets.Size; Species = save.ReadU8(Offset + offsets.Species); VariantIdx = save.ReadU8(Offset + offsets.Variant); Personality = save.ReadU8(Offset + offsets.Personality); Catchphrase = save.ReadString(Offset + offsets.Catchphrase, 12); // Not sure about the size. var ftr = new Item[16]; for (var i = 0; i < 16; i++) { ftr[i] = new Item(save, Offset + offsets.Furniture + i * 0x2C); } Furniture = new ItemCollection(ftr); }
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); }
public void Save() { var save = MainSaveFile.Singleton(); var offsets = this.IsPro ? GetProDesignOffsetsFromRevision() : GetOffsetsFromRevision(); save.WriteString(Offset + offsets.Name, this.Name, 20); save.WriteStruct <PersonalID>(Offset + offsets.PersonalID, this.PersonalID); for (int i = 0; i < 15; i++) { save.WriteU8(Offset + offsets.Palette + i * 3 + 0, this.Palette[i].R); save.WriteU8(Offset + offsets.Palette + i * 3 + 1, this.Palette[i].G); save.WriteU8(Offset + offsets.Palette + i * 3 + 2, this.Palette[i].B); } if (this.Type == TypeEnum.SimplePattern) { save.WriteArray <byte>(Offset + offsets.Image, this.Pixels); } else { var pixels = new byte[this.Width / 2 * this.Height]; for (int y = 0; y < this.Height; y++) { for (int x = 0; x < this.Width / 2; x++) { /*var offset = (x > this.Width / 4 ? 0x200 : 0x0) + (y > this.Height / 2 ? 0x400 : 0x0); * this.Pixels[x + y * this.Width / 2] = pixels[offset + x % (this.Width / 4) + (y % (this.Height / 2)) * (this.Width / 4)];*/ var offset = (x >= this.Width / 4 ? 0x200 : 0x0) + (y >= this.Height / 2 ? 0x400 : 0x0); pixels[offset + x % (this.Width / 4) + (y % (this.Height / 2)) * (this.Width / 4)] = this.Pixels[x + y * this.Width / 2]; } } save.WriteArray <byte>(Offset + offsets.Image, pixels); //save.WriteU8(Offset + offsets.Type, (byte) this.Type); save.WriteU8(Offset + offsets.Type, (byte)this.Type); } }
public DesignPattern(int idx, bool proDesign = false) { IsPro = proDesign; Index = idx; var save = MainSaveFile.Singleton(); var offsets = proDesign ? GetProDesignOffsetsFromRevision() : GetOffsetsFromRevision(); Offset = offsets.BaseOffset + idx * offsets.Size; Type = (TypeEnum)save.ReadU8(Offset + offsets.Type); Name = save.ReadString(Offset + offsets.Name, 20); PersonalID = save.ReadStruct <PersonalID>(Offset + offsets.PersonalID); for (int i = 0; i < 15; i++) { Palette[i] = new DesignColor(Offset + offsets.Palette + i * 3); } if (this.Type == TypeEnum.SimplePattern) { this.Pixels = save.ReadArray <byte>(Offset + offsets.Image, (this.Width / 2) * this.Height); } else { // create one big picture var pixels = save.ReadArray <byte>(Offset + offsets.Image, (this.Width / 2) * this.Height); this.Pixels = new byte[this.Width / 2 * this.Height]; for (int y = 0; y < this.Height; y++) { for (int x = 0; x < this.Width / 2; x++) { var offset = (x >= this.Width / 4 ? 0x200 : 0x0) + (y >= this.Height / 2 ? 0x400 : 0x0); this.Pixels[x + y * this.Width / 2] = pixels[offset + x % (this.Width / 4) + (y % (this.Height / 2)) * (this.Width / 4)]; } } } }
private static Offsets GetOffsetsFromRevision() => VillagerOffsetsByRevision[MainSaveFile.Singleton().GetRevision()];
private static Offsets GetOffsetsFromRevision() => DesignPatternOffsetsByRevision[MainSaveFile.Singleton().GetRevision()];
public Item(int offset) : this(MainSaveFile.Singleton().ReadU16(offset + 0), MainSaveFile.Singleton().ReadU16(offset + 2), MainSaveFile.Singleton().ReadU16(offset + 4), MainSaveFile.Singleton().ReadU16(offset + 6)) { }
public DesignColor(int offset) { this = MainSaveFile.Singleton().ReadStruct <DesignColor>(offset); }