forked from kwsch/NHSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVillagerSwap.cs
33 lines (28 loc) · 1.03 KB
/
VillagerSwap.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using NHSE.Core;
namespace NHSE.Villagers
{
public static class VillagerSwap
{
public static VillagerData GetReplacementVillager(VillagerInfo exist, string newVillager, bool prepMoveOut = false)
{
var replace = VillagerResources.GetVillager(newVillager);
return AdaptVillager(exist, replace, prepMoveOut);
}
private static VillagerData AdaptVillager(VillagerInfo exist, VillagerData replace, bool prepMoveOut = false)
{
var ov = exist.Villager;
var oh = exist.House;
var nv = new Villager2(replace.Villager);
_ = new VillagerHouse1(replace.House) {NPC1 = oh.NPC1, NPC2 = oh.NPC2, BuildPlayer = oh.BuildPlayer};
// Copy Memories
var om = nv.GetMemory(0);
var nm = ov.GetMemory(0);
nm.PlayerId = om.PlayerId;
nv.SetMemory(nm, 0);
if (!prepMoveOut)
return replace;
nv.MovingOut = true;
return replace;
}
}
}