Skip to content

Commit

Permalink
Add LoadoutSwitchWithoutSSC
Browse files Browse the repository at this point in the history
  • Loading branch information
sgkoishi committed Jan 3, 2024
1 parent 1dd1393 commit 78b914c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Core/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ public record class MitigationSettings
/// </summary>
public Optional<bool> AllowCrossJourney = Optional.Default(false);

/// <summary>
/// Loadout switch is kind of broken since it interacts with the SSC even when it's disabled.
/// </summary>
public Optional<bool> LoadoutSwitchWithoutSSC = Optional.Default(true, true);

public enum DisabledDamageAction
{
AsIs,
Expand Down
6 changes: 6 additions & 0 deletions Core/Mitigations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -702,4 +702,10 @@ private void GDHook_Mitigation_PlayerBuffUpdate(object? sender, TShockAPI.GetDat
}
args.Data.Position = currentPosition;
}

private bool Detour_Mitigation_HandleSyncLoadout(Func<TShockAPI.GetDataHandlerArgs, bool> orig, TShockAPI.GetDataHandlerArgs args)
{
var mitigation = this.config.Mitigation.Value;
return (mitigation.DisableAllMitigation || !mitigation.LoadoutSwitchWithoutSSC) && orig(args);
}
}
6 changes: 6 additions & 0 deletions Core/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public Plugin(Main game) : base(game)
.GetMethod("AttemptConfigUpgrade", _bfany),
this.Detour_Mitigation_ConfigUpdate
);
this.Detour(
nameof(this.Detour_Mitigation_HandleSyncLoadout),
typeof(TShockAPI.GetDataHandlers)
.GetMethod("HandleSyncLoadout", _bfany),
this.Detour_Mitigation_HandleSyncLoadout
);
}

public event Action<Plugin>? OnConfigLoad;
Expand Down

0 comments on commit 78b914c

Please sign in to comment.