Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 86a72fc

Browse files
committed
Merge branch 'master' into developer
2 parents ed2b284 + 32b5d08 commit 86a72fc

5 files changed

Lines changed: 548 additions & 3 deletions

File tree

ModLoader/Helper.cs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using UnityEngine;
7+
using UnityEngine.SceneManagement;
8+
9+
namespace ModLoader
10+
{
11+
public class Helper : MonoBehaviour
12+
{
13+
public static Helper instance;
14+
15+
// Events
16+
/// <summary>
17+
/// Fired every frame in the Base Scene
18+
/// </summary>
19+
public static event EventHandler OnUpdateBaseScene;
20+
/// <summary>
21+
/// Fired every frame in the Home Scene
22+
/// </summary>
23+
public static event EventHandler OnUpdateHomeScene;
24+
/// <summary>
25+
/// Fired every frame in the Build Scene
26+
/// </summary>
27+
public static event EventHandler OnUpdateBuildScene;
28+
/// <summary>
29+
/// Fired every frame in the World Scene
30+
/// </summary>
31+
public static event EventHandler OnUpdateWorldScene;
32+
33+
/// <summary>
34+
/// Fired when the Base Scene (the first scene when game loads) is loaded
35+
/// </summary>
36+
public static event EventHandler OnBaseSceneLoaded;
37+
/// <summary>
38+
/// Fired when the start menu scene loaded -> After player has gone to another scene and come back
39+
/// </summary>
40+
public static event EventHandler OnHomeSceneLoaded;
41+
/// <summary>
42+
/// Fired when the Build Scene is loaded
43+
/// </summary>
44+
public static event EventHandler OnBuildSceneLoaded;
45+
/// <summary>
46+
/// Fired when the World Scene is Loaded
47+
/// </summary>
48+
public static event EventHandler OnWorldSceneLoaded;
49+
50+
51+
// Variables
52+
public static scene currentScene;
53+
54+
private void Awake()
55+
{
56+
instance = this;
57+
SceneManager.sceneLoaded += OnSceneLoaded;
58+
}
59+
60+
/// <summary>
61+
/// Fire all of the OnUpdate Events
62+
/// </summary>
63+
private void Update()
64+
{
65+
switch (currentScene)
66+
{
67+
case scene.Base:
68+
OnUpdateBaseScene?.Invoke(this, EventArgs.Empty);
69+
break;
70+
71+
case scene.Home:
72+
OnUpdateHomeScene?.Invoke(this, EventArgs.Empty);
73+
break;
74+
75+
case scene.Build:
76+
OnUpdateBuildScene?.Invoke(this, EventArgs.Empty);
77+
break;
78+
79+
case scene.World:
80+
OnUpdateWorldScene?.Invoke(this, EventArgs.Empty);
81+
break;
82+
}
83+
}
84+
85+
/// <summary>
86+
/// Fire all of the OnSceneLoaded Events
87+
/// </summary>
88+
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
89+
{
90+
switch (scene.name)
91+
{
92+
case "Base_PC":
93+
currentScene = ModLoader.scene.Base;
94+
OnBaseSceneLoaded?.Invoke(this, EventArgs.Empty);
95+
break;
96+
97+
case "Home_PC":
98+
currentScene = ModLoader.scene.Home;
99+
OnHomeSceneLoaded?.Invoke(this, EventArgs.Empty);
100+
break;
101+
102+
case "Build_PC":
103+
currentScene = ModLoader.scene.Build;
104+
OnBuildSceneLoaded?.Invoke(this, EventArgs.Empty);
105+
break;
106+
107+
case "World_PC":
108+
currentScene = ModLoader.scene.World;
109+
OnWorldSceneLoaded?.Invoke(this, EventArgs.Empty);
110+
break;
111+
}
112+
}
113+
}
114+
115+
public enum scene
116+
{
117+
Base,
118+
Home,
119+
Build,
120+
World
121+
}
122+
}

ModLoader/Loader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace ModLoader
1313
{
1414
/// <summary>
15-
/// This is the main class of ModLoader. this class is injected into the game whit Unity Doorstop injector.
15+
/// This is the main class of ModLoader. this class is injected into the game with Unity Doorstop injector.
1616
/// </summary>
1717
public class Loader : MonoBehaviour
1818
{

ModLoader/ModLoader.csproj

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>ModLoader</RootNamespace>
1212
<AssemblyName>ModLoader</AssemblyName>
13-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
<Deterministic>true</Deterministic>
1616
<NuGetPackageImportStamp>
1717
</NuGetPackageImportStamp>
18+
1819
</PropertyGroup>
1920
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2021
<DebugSymbols>true</DebugSymbols>
@@ -79,9 +80,22 @@
7980
<Reference Include="UnityEngine.UIModule">
8081
<HintPath>..\Dependencies\UnityEngine.UIModule.dll</HintPath>
8182
</Reference>
83+
<Reference Include="UnityEngine.IMGUIModule">
84+
<HintPath>..\..\..\My Mods\References\Assemby-CSharp\UnityEngine.IMGUIModule.dll</HintPath>
85+
</Reference>
86+
<Reference Include="UnityEngine.TextRenderingModule">
87+
<HintPath>..\..\..\My Mods\References\Assemby-CSharp\UnityEngine.TextRenderingModule.dll</HintPath>
88+
</Reference>
89+
<Reference Include="UnityEngine.UI">
90+
<HintPath>..\..\..\My Mods\References\Assemby-CSharp\UnityEngine.UI.dll</HintPath>
91+
</Reference>
92+
<Reference Include="UnityEngine.UIModule">
93+
<HintPath>..\..\..\My Mods\References\Assemby-CSharp\UnityEngine.UIModule.dll</HintPath>
94+
</Reference>
8295
</ItemGroup>
8396
<ItemGroup>
8497
<Compile Include="ConsoleGUI.cs" />
98+
<Compile Include="Helper.cs" />
8599
<Compile Include="Loader.cs" />
86100
<Compile Include="Console.cs" />
87101
<Compile Include="Patcher.cs" />

0 commit comments

Comments
 (0)