private void B_ReplaceVillager_Click(object sender, EventArgs e) { if (!Clipboard.ContainsText()) { WinFormsUtil.Error(MessageStrings.MsgVillagerReplaceNoText); return; } var internalName = Clipboard.GetText(); if (!VillagerResources.IsVillagerDataKnown(internalName)) { internalName = GameInfo.Strings.VillagerMap.FirstOrDefault(z => string.Equals(z.Value, internalName, StringComparison.InvariantCultureIgnoreCase)).Key; if (internalName == default) { WinFormsUtil.Error(string.Format(MessageStrings.MsgVillagerReplaceUnknownName, internalName)); return; } } var index = VillagerIndex; var villager = Villagers[index]; if (villager is not Villager2 v2) { WinFormsUtil.Error(MessageStrings.MsgVillagerReplaceOutdatedSaveFormat); return; } var houses = SAV.GetVillagerHouses(); var houseIndex = Array.FindIndex(houses, z => z.NPC1 == index); var exist = new VillagerInfo(v2, houses[houseIndex]); var replace = VillagerSwap.GetReplacementVillager(exist, internalName); var nh = new VillagerHouse(replace.House); SAV.SetVillagerHouse(nh, houseIndex); var nv = new Villager2(replace.Villager); LoadVillager(Villagers[index] = nv); System.Media.SystemSounds.Asterisk.Play(); }
public Villager(Tile currentTile, string name, float age) { this.CurrentTile = currentTile; this.v_info = new VillagerInfo(name, age); }
public Villager(Tile currentTile, VillagerInfo info) { this.CurrentTile = currentTile; this.v_info = info; }