-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
126 lines (105 loc) · 3.4 KB
/
Game.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
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
using CopperDevs.DearImGui;
using CopperDevs.DearImGui.Renderer.Raylib;
using CopperDevs.DearImGui.Renderer.Raylib.Raylib_CSharp;
using CopperDevs.Logger;
using depression.ImGui;
using depression.Managers;
using depression.Scenes;
using Raylib_CSharp;
using Raylib_CSharp.Windowing;
using Riptide.Utils;
using Sparkle.CSharp;
using Sparkle.CSharp.Logging;
using SparkleLogger = Sparkle.CSharp.Logging.Logger;
using Sparkle.CSharp.Registries;
using Sparkle.CSharp.Scenes;
namespace depression;
public class Game : Sparkle.CSharp.Game
{
public Game(GameSettings settings, bool isServer = false) : base(settings)
{
SparkleLogger.Message += Utility.CustomLog;
}
protected override void Init()
{
base.Init();
CopperImGui.Setup<RlImGuiRenderer<RlImGuiBinding>>(true, false);
CopperImGui.ShowDearImGuiAboutWindow = false;
CopperImGui.ShowDearImGuiDemoWindow = false;
CopperImGui.ShowDearImGuiMetricsWindow = false;
CopperImGui.ShowDearImGuiDebugLogWindow = false;
CopperImGui.ShowDearImGuiIdStackToolWindow = false;
Utility.SetWindowStyling();
SceneManager.SetScene(new Empty());
}
protected override void OnRun()
{
base.OnRun();
RegistryManager.Add(new ContentRegistry());
if (Program.Version.Major <= 1)
{
Log.Warning("You are using a alpha branch! v" + Program.Version);
}
RiptideLogger.Initialize(s => Log.Debug(s),
s => Log.Network(s),
s => Log.Warning(s),
s => Log.Error(s), false);
DiscordManager.Client.OnReady += (sender, e) =>
{
Logger.Info($"Received Ready from user {e.User.Username}");
};
DiscordManager.Client.OnPresenceUpdate += (sender, e) =>
{
Logger.Info($"Received Update! {e.Presence}");
};
}
protected override void Draw()
{
base.Draw();
NetworkManager.UpdateHandlers();
CopperImGui.Render();
Window.SetTitle($"{Settings.Title} | Scene: {(SceneManager.ActiveScene != null ? SceneManager.ActiveScene.Name : "???")} [FPS: {Time.GetFPS()}]");
}
protected override void FixedUpdate()
{
base.FixedUpdate();
if (NetworkManager.CurrentClient != null ||
NetworkManager.CurrentServer != null)
{
if (SceneManager.ActiveScene?.Name == "Test")
{
CopperImGui.ShowWindow<NetworkPanel>();
CopperImGui.HideWindow<MainMenu>();
}
else
{
SceneManager.SetScene(new Test());
}
}
else
{
if (SceneManager.ActiveScene?.Name == "Empty")
{
CopperImGui.ShowWindow<MainMenu>();
CopperImGui.HideWindow<NetworkPanel>();
}
else
{
SceneManager.SetScene(new Empty());
}
}
}
protected override void OnClose()
{
base.OnClose();
CopperImGui.Shutdown();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
NetworkManager.CurrentServer?.Stop();
NetworkManager.CurrentClient?.Disconnect();
DiscordManager.Client.Dispose();
Environment.Exit(0);
}
}