-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathFactionWorldData.cs
92 lines (74 loc) · 3.08 KB
/
FactionWorldData.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using RimWorld;
using Verse;
namespace Multiplayer.Client;
public class FactionWorldData : IExposable
{
public int factionId;
public ResearchManager researchManager;
public OutfitDatabase outfitDatabase;
public DrugPolicyDatabase drugPolicyDatabase;
public FoodRestrictionDatabase foodRestrictionDatabase;
public PlaySettings playSettings;
public History history;
public Storyteller storyteller;
public StoryWatcher storyWatcher;
public FactionWorldData() { }
public void ExposeData()
{
Scribe_Values.Look(ref factionId, "factionId");
Scribe_Deep.Look(ref researchManager, "researchManager");
Scribe_Deep.Look(ref drugPolicyDatabase, "drugPolicyDatabase");
Scribe_Deep.Look(ref outfitDatabase, "outfitDatabase");
Scribe_Deep.Look(ref foodRestrictionDatabase, "foodRestrictionDatabase");
Scribe_Deep.Look(ref playSettings, "playSettings");
Scribe_Deep.Look(ref history, "history");
Scribe_Deep.Look(ref storyteller, "storyteller");
Scribe_Deep.Look(ref storyWatcher, "storyWatcher");
if (Scribe.mode == LoadSaveMode.LoadingVars)
{
history ??= new History();
storyteller ??= new Storyteller(Find.Storyteller.def, Find.Storyteller.difficultyDef,
Find.Storyteller.difficulty);
storyWatcher ??= new StoryWatcher();
}
}
public void ReassignIds()
{
foreach (DrugPolicy p in drugPolicyDatabase.policies)
p.id = Find.UniqueIDsManager.GetNextThingID();
foreach (ApparelPolicy o in outfitDatabase.outfits)
o.id = Find.UniqueIDsManager.GetNextThingID();
foreach (FoodPolicy o in foodRestrictionDatabase.foodRestrictions)
o.id = Find.UniqueIDsManager.GetNextThingID();
}
public static FactionWorldData New(int factionId)
{
return new FactionWorldData()
{
factionId = factionId,
researchManager = new ResearchManager(),
drugPolicyDatabase = new DrugPolicyDatabase(),
outfitDatabase = new OutfitDatabase(),
foodRestrictionDatabase = new FoodRestrictionDatabase(),
playSettings = new PlaySettings(),
history = new History(),
storyteller = new Storyteller(Find.Storyteller.def, Find.Storyteller.difficultyDef, Find.Storyteller.difficulty),
storyWatcher = new StoryWatcher()
};
}
public static FactionWorldData FromCurrent(int factionId)
{
return new FactionWorldData()
{
factionId = factionId == int.MinValue ? Faction.OfPlayer.loadID : factionId,
researchManager = Find.ResearchManager,
drugPolicyDatabase = Current.Game.drugPolicyDatabase,
outfitDatabase = Current.Game.outfitDatabase,
foodRestrictionDatabase = Current.Game.foodRestrictionDatabase,
playSettings = Current.Game.playSettings,
history = Find.History,
storyteller = Find.Storyteller,
storyWatcher = Find.StoryWatcher
};
}
}