-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMain.cs
More file actions
83 lines (74 loc) · 2.14 KB
/
Main.cs
File metadata and controls
83 lines (74 loc) · 2.14 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
77
78
79
80
81
82
83
using System.Linq;
using System.IO;
using UnityModManagerNet;
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
namespace ProceduralSkyMod
{
public class Main
{
public static bool enabled;
public static bool initialized;
public static Settings settings;
public static string ModPath { get; private set; }
public static string ModVersion { get => JsonUtility.FromJson<UnityModManagerNet.UnityModManager.ModInfo>(File.ReadAllText(Path.Combine(ModPath, "Info.json"))).Version; }
static bool Load (UnityModManager.ModEntry modEntry)
{
try { settings = Settings.Load<Settings>(modEntry); } catch { }
if (DvTimeAdapter.Available)
{
RedworkDE.DvTime.TimeUpdater.RegisterTimeSource += DvTimeAdapter.InstallProSkyTimeSource;
}
ModPath = modEntry.Path;
modEntry.OnToggle = OnToggle;
modEntry.OnGUI = OnGUI;
modEntry.OnSaveGUI = OnSaveGUI;
return true; // If false the mod will show an error
}
static void OnGUI (UnityModManager.ModEntry modEntry)
{
settings.Draw(modEntry);
}
static void OnSaveGUI (UnityModManager.ModEntry modEntry)
{
settings.Save(modEntry);
}
static bool OnToggle (UnityModManager.ModEntry modEntry, bool value)
{
if (value) Run(modEntry);
else Stop(modEntry);
enabled = value;
return true; // If true, the mod will switch the state. If not, the state will not change.
}
static void Run (UnityModManager.ModEntry modEntry)
{
#if DEBUG
Debug.Log(">>> >>> >>> Cybex_ProceduralSkyMod : Run Mod...");
#endif
modEntry.OnUpdate = OnUpdate;
}
static void Stop (UnityModManager.ModEntry modEntry)
{
#if DEBUG
Debug.Log(">>> >>> >>> Cybex_ProceduralSkyMod : Stop Mod...");
#endif
initialized = false;
}
static void OnUpdate (UnityModManager.ModEntry modEntry, float delta)
{
if (!initialized)
{
if (LoadingScreenManager.IsLoading || !WorldStreamingInit.IsLoaded ||
!SingletonBehaviour<Inventory>.Instance) return;
else
{
ProceduralSkyInitializer initializer = new ProceduralSkyInitializer();
initializer.Init();
initialized = true;
modEntry.OnUpdate = null;
}
}
}
}
}