Skip to content

Commit

Permalink
feat: Support GravityHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
WEGFan committed Aug 26, 2022
1 parent 9282de2 commit bb5e9d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Code/Modules/CustomTrail.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Celeste.Mod.Trailine.ThirdParty;
using Microsoft.Xna.Framework;

namespace Celeste.Mod.Trailine.Modules {
Expand Down Expand Up @@ -28,6 +29,9 @@ private static void On_Player_Update(On.Celeste.Player.orig_Update orig, Player
_ => Color.Transparent
};
Vector2 scale = new Vector2(Math.Abs(self.Sprite.Scale.X) * (float)self.Facing, self.Sprite.Scale.Y);
if (GravityHelperImports.IsPlayerInverted?.Invoke() ?? false) {
scale.Y *= -1f;
}
TrailineTrailManager.Add(self, scale, color, Settings.TrailDuration);
}
}
Expand Down
11 changes: 11 additions & 0 deletions Code/ThirdParty/GravityHelperImports.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using MonoMod.ModInterop;

namespace Celeste.Mod.Trailine.ThirdParty {
[ModImportName("GravityHelper")]
public static class GravityHelperImports {

public static Func<bool> IsPlayerInverted;

}
}
4 changes: 4 additions & 0 deletions Code/TrailineModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using System.IO;
using Celeste.Mod.Core;
using Celeste.Mod.Trailine.Modules;
using Celeste.Mod.Trailine.ThirdParty;
using Celeste.Mod.Trailine.UI;
using Celeste.Mod.Trailine.Utils;
using Microsoft.Xna.Framework;
using MonoMod.ModInterop;
using YamlDotNet.Serialization;

namespace Celeste.Mod.Trailine {
Expand All @@ -23,6 +25,8 @@ public TrailineModule() {
public static bool Loaded = false;

public override void Load() {
typeof(GravityHelperImports).ModInterop();

if (Loaded || !Settings.Enabled) {
return;
}
Expand Down

0 comments on commit bb5e9d2

Please sign in to comment.