-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMod.cs
More file actions
76 lines (63 loc) · 2.08 KB
/
Mod.cs
File metadata and controls
76 lines (63 loc) · 2.08 KB
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
using System.Collections;
using System.Collections.Generic;
using MelonLoader;
using StreamSurfers.TwitchIntegration;
[assembly: HarmonyDontPatchAll]
[assembly: MelonInfo(typeof(StreamSurfers.Mod), "StreamSurfers", "1.0.2", "ReservedKeyword")]
[assembly: MelonGame("CayPlay", "WaterparkSimulator")]
[assembly: MelonColor(1, 0, 158, 196)]
namespace StreamSurfers
{
public class Mod : MelonMod
{
public static Mod Instance { get; private set; }
public ModConfig ModConfig { get; private set; }
public ChatterManager ChatterManager { get; private set; }
public Dictionary<ulong, string> ChattersInPark { get; private set; }
private HarmonyLib.Harmony harmony;
private void ClearChattersInPark()
{
LogMsg($"New in-game day! All chatters cleared from in-game park cache!");
ChattersInPark.Clear();
}
private void LogMsg(string msg)
{
LoggerInstance.Msg($"[{nameof(Mod)}] {msg}");
}
public override void OnInitializeMelon()
{
Instance = this;
ChattersInPark = [];
ModConfig = new();
if (!ModConfig.IsEnabled)
{
LoggerInstance.Msg("Plugin disabled in configuration file, won't proceed...");
return;
}
// Setup Twitch chatter integration
ChatterManager = new(this, ModConfig);
ChatterManager.Connect();
// Setup Harmony patches
harmony = new(Constants.ToHarmonyID());
harmony.PatchAll();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
if (sceneName == Constants.GAMEPLAY_SCENE_NAME)
{
LogMsg("GameplayScene loaded! Starting coroutine, subscribing to OnNewDayStarted event.");
MelonCoroutines.Start(WaitForGameManagerAndSubscribe());
}
}
private IEnumerator WaitForGameManagerAndSubscribe()
{
// Wait for the GameManager instance to be ready
while (GameManager.rzy == null)
{
yield return null;
}
GameManager.rzy.OnNewDayStarted.AddListener(ClearChattersInPark);
LogMsg("Successfully subscribed to OnNewDayStarted event!");
}
}
}