-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNeonNetwork.cs
More file actions
154 lines (128 loc) · 5.79 KB
/
NeonNetwork.cs
File metadata and controls
154 lines (128 loc) · 5.79 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using MelonLoader;
using UnityEngine;
using NeonNetwork.Objects;
using System.Collections;
using System;
using System.IO;
using NeonNetwork.Objects.Popups;
using Steamworks;
using NeonNetwork.Online;
using NeonNetwork.Objects.SidePanel;
using NeonNetwork.Objects.Other;
using NeonNetwork.Resources;
using System.Runtime.CompilerServices;
using System.Reflection;
namespace NeonNetwork
{
internal class NeonNetwork : MelonMod
{
internal static AssetBundle bundle;
internal static NeonNetwork instance;
internal static Transform nnMMHolder;
internal static Transform nnHolder;
internal static bool connected = false;
internal static bool logged = false;
internal static string Version => instance.MelonAssembly.Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
#if DEBUG
internal static bool DEBUG { get { return Settings.debug.Value; } }
#else
internal const bool DEBUG = false;
#endif
public override void OnInitializeMelon()
{
instance = this;
Logger.Msg($"Version {Version}");
#if DEBUG
NeonLite.Modules.Anticheat.Register(MelonAssembly);
#endif
NeonLite.NeonLite.LoadModules(MelonAssembly);
NeonLite.Patching.AddPatch(typeof(MainMenu), "SetState", Init, NeonLite.Patching.PatchTarget.Prefix);
Settings.Register();
}
public override void OnLateInitializeMelon()
{
GameObject obj = new("NeonNetwork");
UnityEngine.Object.DontDestroyOnLoad(obj);
obj.transform.position = new Vector3(0, -1000, 0);
obj.transform.localScale = Vector3.one;
nnHolder = obj.transform;
bundle = AssetBundle.LoadFromMemory(Resources.r.assetbundle);
}
public override void OnUpdate()
{
Rooms.Tick();
if (nnMMHolder)
{
var cg = nnMMHolder.GetComponent<CanvasGroup>();
cg.alpha = Settings.hidden.Value ? 0 : 1;
cg.interactable = cg.blocksRaycasts = !Settings.hidden.Value;
}
}
public static MelonLogger.Instance Logger => instance.LoggerInstance;
public static void Init(MainMenu.State newState)
{
if (newState != MainMenu.State.Title)
return;
instance.Initialize();
NeonLite.Patching.RemovePatch(typeof(MainMenu), "SetState", Init);
}
public void Initialize()
{
//yield return new WaitForSeconds(0.5f);
Logger.Msg("Starting NeonNetwork..");
GameObject obj = new("NeonNetwork", typeof(CanvasGroup));
//obj.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceCamera;
obj.transform.SetParent(MainMenu.Instance().transform.Find("Canvas"), false);
obj.transform.localScale = Vector3.one;
nnMMHolder = obj.transform;
//Encryption.Setup();
//yield return new WaitForSeconds(0.25f);
Objects.Other.Version.Setup();
StatusHandler.Setup();
RenderLoadIcon.Setup();
Popup.Setup();
RaceSidebar.Setup();
SidePanel.Setup();
//Loading.Show("Connecting...", null);
Online.Online.Setup();
//yield return new WaitForSeconds(0.25f);
Rooms.Setup();
// ROOMS RELEASE
// TODO: beh. temporary
Online.Online.Invoke();
//yield return null;
}
}
internal static class Settings
{
public const string h = "NeonNetwork";
public static MelonPreferences_Entry<bool> debug;
public static MelonPreferences_Entry<bool> hasSetup;
public static MelonPreferences_Entry<Color> ghostColor;
public static MelonPreferences_Entry<Color> ghostColorS;
public static MelonPreferences_Entry<Color> inColor;
public static MelonPreferences_Entry<Color> inColorS;
public static MelonPreferences_Entry<bool> hidden;
public static MelonPreferences_Entry<bool> hiddenLB;
public static MelonPreferences_Entry<bool> autoJoin;
public static MelonPreferences_Entry<bool> autoJoinF;
public static void Register()
{
NeonLite.Settings.AddHolder(h);
autoJoin = NeonLite.Settings.Add(h, "Rooms", "autoJoin", "Public auto-room popup", null, true);
autoJoinF = NeonLite.Settings.Add(h, "Rooms", "autoJoinForce", "Actually auto-join the auto-room", null, false, true);
debug = NeonLite.Settings.Add(h, "Misc", "debug", "Debug Mode", null, false, true);
hasSetup = NeonLite.Settings.Add(h, "Misc", "hasSetup", "Completed Setup", null, false, true);
ghostColor = NeonLite.Settings.Add(h, "Misc", "mainColor", "Main Ghost Color", null, Color.white);
ghostColor.OnEntryValueChanged.Subscribe((before, after) => Rooms.SetColor());
ghostColorS = NeonLite.Settings.Add(h, "Misc", "subColor", "Secondary Ghost Color", null, Color.white);
ghostColorS.OnEntryValueChanged.Subscribe((before, after) => Rooms.SetColor());
inColor = NeonLite.Settings.Add(h, "Misc", "inmainColor", "Main In-ghost Color", null, Color.white);
inColor.OnEntryValueChanged.Subscribe((before, after) => Rooms.SetColor());
inColorS = NeonLite.Settings.Add(h, "Misc", "insubColor", "Secondary In-ghost Color", null, Color.white);
inColorS.OnEntryValueChanged.Subscribe((before, after) => Rooms.SetColor());
hidden = NeonLite.Settings.Add(h, "Misc", "hidden", "Hide UI", null, false);
hiddenLB = NeonLite.Settings.Add(h, "Misc", "hiddenLB", "Hide Duel Leaderboard until Finish", null, false);
}
}
}