Skip to content

Commit

Permalink
Fix warnings on latest versions of Everest
Browse files Browse the repository at this point in the history
  • Loading branch information
maddie480 committed Nov 11, 2023
1 parent d745553 commit 26557cf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
14 changes: 11 additions & 3 deletions Entities/FancyTextTutorial.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
using Celeste.Mod.Entities;
using Microsoft.Xna.Framework;
using Monocle;
using MonoMod.RuntimeDetour;
using System;
using System.Linq;
using System.Reflection;

namespace Celeste.Mod.MaxHelpingHand.Entities {
// A tutorial made of fancy text. Because that's how formatted text is called in Celeste.
[CustomEntity("MaxHelpingHand/FancyTextTutorial")]
[Tracked]
public class FancyTextTutorial : Entity {
private static Hook customBirdTutorialTriggerOnEnter = null;

public static void Load() {
On.Celeste.Mod.Entities.CustomBirdTutorialTrigger.OnEnter += onEnterCustomBirdTutorialTrigger;
customBirdTutorialTriggerOnEnter = new Hook(
typeof(CustomBirdTutorialTrigger).GetMethod("OnEnter"),
typeof(FancyTextTutorial).GetMethod("onEnterCustomBirdTutorialTrigger", BindingFlags.NonPublic | BindingFlags.Static));
}

public static void Unload() {
On.Celeste.Mod.Entities.CustomBirdTutorialTrigger.OnEnter -= onEnterCustomBirdTutorialTrigger;
customBirdTutorialTriggerOnEnter?.Dispose();
customBirdTutorialTriggerOnEnter = null;
}

private static void onEnterCustomBirdTutorialTrigger(On.Celeste.Mod.Entities.CustomBirdTutorialTrigger.orig_OnEnter orig, CustomBirdTutorialTrigger self, Player player) {
private static void onEnterCustomBirdTutorialTrigger(Action<CustomBirdTutorialTrigger, Player> orig, CustomBirdTutorialTrigger self, Player player) {
orig(self, player);

// do the same for fancy text tutorial!
Expand Down
2 changes: 1 addition & 1 deletion Entities/ReskinnableCrystalHeart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void Added(Scene scene) {

// despawn if already collected in session and if heart does not end level
// (like vanilla hearts, but this condition is checked in Level.LoadLevel() so we do not get that behavior just by extending HeartGem)
MapMetaModeProperties meta = SceneAs<Level>().Session.MapData.GetMeta();
MapMetaModeProperties meta = SceneAs<Level>().Session.MapData.Meta;
bool heartIsEnd = (meta != null && meta.HeartIsEnd.GetValueOrDefault());
if (SceneAs<Level>().Session.HeartGem && !heartIsEnd) {
RemoveSelf();
Expand Down
21 changes: 15 additions & 6 deletions Module/CustomWipe.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Microsoft.Xna.Framework;
using Celeste.Mod.MaxHelpingHand.Entities;
using Celeste.Mod.Meta;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Monocle;
using MonoMod.RuntimeDetour;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace Celeste.Mod.MaxHelpingHand.Module {
public class CustomWipe : ScreenWipe {
Expand All @@ -12,15 +16,20 @@ public class CustomWipe : ScreenWipe {
private static VertexPositionColor[][] currentWipeIn;
private static VertexPositionColor[][] currentWipeOut;

private static Hook mapMetaApplyTo = null;

public static void Load() {
On.Celeste.Mod.Meta.MapMeta.ApplyTo += onParseScreenWipe;
mapMetaApplyTo = new Hook(
typeof(MapMeta).GetMethod("ApplyTo"),
typeof(CustomWipe).GetMethod("onParseScreenWipe", BindingFlags.NonPublic | BindingFlags.Static));
}

public static void Unload() {
On.Celeste.Mod.Meta.MapMeta.ApplyTo -= onParseScreenWipe;
mapMetaApplyTo.Dispose();
mapMetaApplyTo = null;
}

private static void onParseScreenWipe(On.Celeste.Mod.Meta.MapMeta.orig_ApplyTo orig, Meta.MapMeta self, AreaData area) {
private static void onParseScreenWipe(Action<MapMeta, AreaData> orig, MapMeta self, AreaData area) {
orig(self, area);

if (!string.IsNullOrEmpty(self.Wipe) && self.Wipe.StartsWith("MaxHelpingHand/CustomWipe:")) {
Expand Down Expand Up @@ -55,8 +64,8 @@ private static void onParseScreenWipe(On.Celeste.Mod.Meta.MapMeta.orig_ApplyTo o
};

// let's make sure the wipe is in map metadata because this can get weird.
if (area.GetMeta() != null) {
area.GetMeta().Wipe = self.Wipe;
if (area.Meta != null) {
area.Meta.Wipe = self.Wipe;
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions Module/MaxHelpingHandModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Reflection;
using MonoMod.ModInterop;
using MonoMod.RuntimeDetour;

namespace Celeste.Mod.MaxHelpingHand.Module {
public class MaxHelpingHandModule : EverestModule {
Expand All @@ -24,6 +25,8 @@ public class MaxHelpingHandModule : EverestModule {
public override Type SessionType => typeof(MaxHelpingHandSession);
public MaxHelpingHandSession Session => (MaxHelpingHandSession) _Session;

private static Hook modRegister = null;

public MaxHelpingHandModule() {
Instance = this;
}
Expand Down Expand Up @@ -99,7 +102,10 @@ public override void Load() {
ReversibleRetentionBooster.Load();

Everest.Events.Level.OnLoadBackdrop += onLoadBackdrop;
On.Celeste.Mod.Everest.Register += onModRegister;

modRegister = new Hook(
typeof(Everest).GetMethod("Register"),
typeof(MaxHelpingHandModule).GetMethod("onModRegister", BindingFlags.NonPublic | BindingFlags.Instance), this);

typeof(LuaCutscenesUtils).ModInterop();
}
Expand Down Expand Up @@ -178,7 +184,9 @@ public override void Unload() {
ReversibleRetentionBooster.Unload();

Everest.Events.Level.OnLoadBackdrop -= onLoadBackdrop;
On.Celeste.Mod.Everest.Register -= onModRegister;

modRegister?.Dispose();
modRegister = null;

if (hookedSineParallax) {
unhookSineParallax();
Expand All @@ -195,7 +203,7 @@ public override void LoadContent(bool firstLoad) {
HookMods();
}

private void onModRegister(On.Celeste.Mod.Everest.orig_Register orig, EverestModule module) {
private void onModRegister(Action<EverestModule> orig, EverestModule module) {
orig(module);

if ((bool) contentLoaded.GetValue(null)) {
Expand Down

0 comments on commit 26557cf

Please sign in to comment.