-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathRitualSession.cs
87 lines (74 loc) · 1.85 KB
/
RitualSession.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
using Multiplayer.API;
using RimWorld;
using Verse;
namespace Multiplayer.Client.Persistent;
public class RitualSession : SemiPersistentSession
{
public Map map;
public RitualData data;
public override Map Map => map;
public RitualSession(Map map) : base(map)
{
this.map = map;
}
public RitualSession(Map map, RitualData data) : this(map)
{
this.data = data;
this.data.assignments.session = this;
}
[SyncMethod]
public void Remove()
{
map.MpComp().sessionManager.RemoveSession(this);
}
[SyncMethod]
public void Start()
{
if (data.action != null && data.action(data.assignments))
Remove();
}
public void OpenWindow(bool sound = true)
{
var dialog = new RitualBeginProxy(
data.assignments,
data.ritualLabel,
data.ritual,
data.target,
map,
data.action,
data.organizer,
data.obligation,
null,
data.confirmText,
null,
null,
data.outcome,
data.extraInfos,
null
);
if (!sound)
dialog.soundAppear = null;
Find.WindowStack.Add(dialog);
}
public override void Sync(SyncWorker sync)
{
if (sync.isWriting)
{
sync.Write(data);
}
else
{
data = sync.Read<RitualData>();
data.assignments.session = this;
}
}
public override bool IsCurrentlyPausing(Map map) => map == this.map;
public override FloatMenuOption GetBlockingWindowOptions(ColonistBar.Entry entry)
{
return new FloatMenuOption("MpRitualSession".Translate(), () =>
{
SwitchToMapOrWorld(entry.map);
OpenWindow();
});
}
}