about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/Patches
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-05-25 00:10:57 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-05-25 00:10:57 -0400
commit1ec73259768c9d8ecdf89a9968188d28c9e52808 (patch)
tree8d31dfea7247230457c248cf8180d1c66d5ae02d /AnodyneArchipelago/Patches
parent5d33345b598e2107df3763f09af3a06a84d65a93 (diff)
downloadanodyne-archipelago-1ec73259768c9d8ecdf89a9968188d28c9e52808.tar.gz
anodyne-archipelago-1ec73259768c9d8ecdf89a9968188d28c9e52808.tar.bz2
anodyne-archipelago-1ec73259768c9d8ecdf89a9968188d28c9e52808.zip
Started new main menu
Diffstat (limited to 'AnodyneArchipelago/Patches')
-rw-r--r--AnodyneArchipelago/Patches/StatePatches.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/AnodyneArchipelago/Patches/StatePatches.cs b/AnodyneArchipelago/Patches/StatePatches.cs index f6acc62..4b29295 100644 --- a/AnodyneArchipelago/Patches/StatePatches.cs +++ b/AnodyneArchipelago/Patches/StatePatches.cs
@@ -4,6 +4,10 @@ using AnodyneSharp.States;
4using AnodyneSharp; 4using AnodyneSharp;
5using HarmonyLib; 5using HarmonyLib;
6using System.Reflection; 6using System.Reflection;
7using AnodyneSharp.Drawing.Effects;
8using AnodyneSharp.States.MainMenu;
9using static AnodyneSharp.AnodyneGame;
10using AnodyneSharp.Drawing;
7 11
8namespace AnodyneArchipelago.Patches 12namespace AnodyneArchipelago.Patches
9{ 13{
@@ -16,6 +20,49 @@ namespace AnodyneArchipelago.Patches
16 } 20 }
17 } 21 }
18 22
23 [HarmonyPatch(typeof(AnodyneGame), "SetState")]
24 class SetStatePatch
25 {
26 // Pretty much rewrite this whole method, so that we can swap out some states.
27 static bool Prefix(AnodyneGame __instance, GameState state)
28 {
29 foreach (IFullScreenEffect effect in GlobalState.AllEffects)
30 {
31 effect.Deactivate();
32 }
33
34 State new_state = CreateState(__instance, state);
35
36 if (new_state != null)
37 {
38 new_state.Create();
39
40 MethodInfo setStateMethod = typeof(AnodyneGame).GetMethod("SetState", BindingFlags.NonPublic | BindingFlags.Instance);
41 new_state.ChangeStateEvent = (ChangeState)setStateMethod.CreateDelegate(typeof(ChangeState), __instance);
42 }
43
44 FieldInfo stateField = typeof(AnodyneGame).GetField("_currentState", BindingFlags.NonPublic | BindingFlags.Instance);
45 stateField.SetValue(__instance, new_state);
46
47 return false;
48 }
49
50 static State CreateState(AnodyneGame __instance, GameState state)
51 {
52 switch (state)
53 {
54 case GameState.TitleScreen: return new TitleState();
55 case GameState.MainMenu: return new Menu.MenuState();
56 case GameState.Intro: return new IntroState();
57 case GameState.Game:
58 FieldInfo cameraField = typeof(AnodyneGame).GetField("_camera", BindingFlags.NonPublic | BindingFlags.Instance);
59 return new PlayState((Camera)cameraField.GetValue(__instance));
60 case GameState.Credits: return new CreditsState();
61 default: return null;
62 }
63 }
64 }
65
19 [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))] 66 [HarmonyPatch(typeof(PlayState), nameof(PlayState.Create))]
20 class PlayStateCreatePatch 67 class PlayStateCreatePatch
21 { 68 {