Skip to content

Commit

Permalink
v1.8.8 release
Browse files Browse the repository at this point in the history
  • Loading branch information
LozenChen committed Nov 28, 2023
1 parent f983173 commit ecbe18b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 54 deletions.
9 changes: 8 additions & 1 deletion Source/Entities/PauseUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ public PauseUpdateComponent() : base(true, false){
[Initialize]

public static void Initialize() {
levelPauseTags = (int)Tags.FrozenUpdate | (int)Tags.PauseUpdate | (int)Tags.TransitionUpdate;
try {
levelPauseTags = (int)Tags.FrozenUpdate | (int)Tags.PauseUpdate | (int)Tags.TransitionUpdate;
}
catch {
// idk, but there's such bug report
levelPauseTags = 0;
Logger.Log(LogLevel.Info, "TAS Helper", "An error occurred when PauseUpdater initializes!");
}
}

[Load]
Expand Down
28 changes: 28 additions & 0 deletions Source/TinySRT/ExtraSlActions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Celeste.Mod.SpeedrunTool.SaveLoad;
using Celeste.Mod.TASHelper.Entities;
using Celeste.Mod.TASHelper.Module.Menu;
using Celeste.Mod.TASHelper.Utils;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Monocle;
Expand Down Expand Up @@ -30,6 +31,9 @@ public static void Load() {
TH_Actions.Add(TasModSL.Create());
// tas mod already adds to SRT itself
TH_Actions.Add(TasHelperSL.Create());

//TH_Actions.Add(GravityHelperSL.Create());

SRT_Actions.Add(TasHelperSL.CreateSRT());
foreach (TH action in TH_Actions) {
TH.Add(action);
Expand Down Expand Up @@ -230,3 +234,27 @@ public static SRT CreateSRT() {
);
}
}

internal static class GravityHelperSL {

public static bool Installed = false;

public static object PlayerGravityComponent;
public static TH Create() {
Installed = ModUtils.GetType("GravityHelper", "Celeste.Mod.GravityHelper.GravityHelperModule")?.GetPropertyInfo("PlayerComponent") is not null;
TH.SlAction save = (_, _) => {
if (Installed) {
PlayerGravityComponent = ModUtils.GetType("GravityHelper", "Celeste.Mod.GravityHelper.GravityHelperModule").GetPropertyValue<object>("PlayerComponent").TH_DeepCloneShared();
}
};
TH.SlAction load = (_, _) => {
if (Installed) {
ModUtils.GetType("GravityHelper", "Celeste.Mod.GravityHelper.GravityHelperModule").SetPropertyValue("PlayerComponent", PlayerGravityComponent);
}
};
Action clear = () => {
PlayerGravityComponent = null;
};
return new TH(save, load, clear, null, null);
}
}
50 changes: 0 additions & 50 deletions Source/TinySRT/SlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,56 +59,6 @@ public static void AddAction() {
}
}

internal static class TH_StrawberryJamUtils {
public static float currentOldFreezeTimer;

public static float? savedOldFreezeTimer;

public static float? loadOldFreezeTimer;

public static readonly Lazy<MethodInfo> EngineUpdate = new Lazy<MethodInfo>(() => ModUtils.GetType("StrawberryJam2021", "Celeste.Mod.StrawberryJam2021.Entities.WonkyCassetteBlockController")?.GetMethodInfo("Engine_Update"));

public static bool hooked;

[Initialize]
public static void Initialize() {
EngineUpdate.Value?.IlHook((cursor, _) => {
int localIndex = 0;
if (cursor.TryGotoNext(MoveType.Before, (Instruction i) => i.MatchLdsfld<Engine>("FreezeTimer"), (Instruction i) => i.MatchStloc(out localIndex))) {
cursor.Index++;
cursor.Emit(OpCodes.Dup).Emit(OpCodes.Stsfld, typeof(TH_StrawberryJamUtils).GetFieldInfo(nameof(currentOldFreezeTimer)));
if (cursor.TryGotoNext(MoveType.After, (Instruction i) => i.MatchLdloc(localIndex))) {
cursor.EmitDelegate<Func<float, float>>(RestoreOldFreezeTimer);
hooked = true;
}
}
});
}

public static float RestoreOldFreezeTimer(float oldFreezeTimer) {
float? num = loadOldFreezeTimer;
if (num.HasValue) {
float valueOrDefault = num.GetValueOrDefault();
loadOldFreezeTimer = null;
return valueOrDefault;
}

return oldFreezeTimer;
}

public static void AddSupport() {
if (hooked) {
TH.SafeAdd(delegate {
savedOldFreezeTimer = currentOldFreezeTimer;
}, delegate {
loadOldFreezeTimer = savedOldFreezeTimer;
}, delegate {
savedOldFreezeTimer = null;
});
}
}
}

internal static class TH_FrostHelperUtils {
public static readonly Lazy<Type> AttachedDataHelperType = new Lazy<Type>(() => ModUtils.GetType("FrostHelper", "FrostHelper.Helpers.AttachedDataHelper"));

Expand Down
1 change: 0 additions & 1 deletion Source/TinySRT/TH_SaveLoadAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ public static void InitActions() {

SupportCommunalHelper();
SupportBrokemiaHelper();
TH_StrawberryJamUtils.AddSupport();
TH_FrostHelperUtils.SupportFrostHelper();
SupportVivHelper();

Expand Down
2 changes: 1 addition & 1 deletion Source/Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static T GetPropertyValue<T>(this object obj, string name) {
}
}

public static T GetPropertyValue<T>(Type type, string name) {
public static T GetPropertyValue<T>(this Type type, string name) {
object result = type.GetPropertyInfo(name)?.GetValue(null, null);
if (result == null) {
return default;
Expand Down
3 changes: 3 additions & 0 deletions Source/Utils/ModUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static Assembly GetAssembly(string modName) {
public static bool IsaGrabBagInstalled = false;

public static bool SpeedrunToolInstalled = false;

public static bool GravityHelperInstalled = false;
public static bool UpsideDown => ExtendedVariantsUtils.UpsideDown;
public static void InitializeAtFirst() {
FrostHelperInstalled = IsInstalled("FrostHelper");
Expand All @@ -59,6 +61,7 @@ public static void InitializeAtFirst() {
BrokemiaHelperInstalled = IsInstalled("BrokemiaHelper");
IsaGrabBagInstalled = IsInstalled("IsaGrabBag");
SpeedrunToolInstalled = IsInstalled("SpeedrunTool");
GravityHelperInstalled = IsInstalled("GravityHelper");
// we actually also assume they are in enough late version
// so all entities mentioned in corresponding hooks do exist
}
Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: TASHelper
Version: 1.8.7
Version: 1.8.8
DLL: bin/Release/net4.5.2/TASHelper.dll
Dependencies:
- Name: Everest
Expand Down

0 comments on commit ecbe18b

Please sign in to comment.