Moved Nerf Expert Debuffs code to a ModSystem

This commit is contained in:
ben-tk committed 2022-09-30 15:55:02 -04:00
1 parent 2f3e61be9f
commit fae038ea38
2 files changed
+42 -30

No files matched your search

-30
View File
@@ -82,36 +82,6 @@ namespace CalamityMod.CalPlayer
if (fearmongerRegenFrames > 0)
fearmongerRegenFrames--;
// Reduce the expert+ debuff time multiplier to the normal mode multiplier
// TODO -- This should be a ModSystem, why is this in CalamityPlayer
if (CalamityConfig.Instance.NerfExpertDebuffs)
{
var copy = Main.RegisteredGameModes[GameModeID.Expert];
copy.DebuffTimeMultiplier = 1f;
Main.RegisteredGameModes[GameModeID.Expert] = copy;
copy = Main.RegisteredGameModes[GameModeID.Master];
copy.DebuffTimeMultiplier = 1f;
Main.RegisteredGameModes[GameModeID.Master] = copy;
// NOTE -- While this may seem at a glance to be redundant and nonsensical, the underlying setter for this property is what causes the game mode properties to
// be refreshed and copied from RegisteredGameModes. Without this, the above behavior is not reflected ingame, as GameModeData is a value type, not a reference type.
Main.GameMode = Main.GameMode;
}
// If people want to suffer, let them suffer
else
{
var copy = Main.RegisteredGameModes[GameModeID.Expert];
copy.DebuffTimeMultiplier = 2f;
Main.RegisteredGameModes[GameModeID.Expert] = copy;
copy = Main.RegisteredGameModes[GameModeID.Master];
copy.DebuffTimeMultiplier = 2.5f;
Main.RegisteredGameModes[GameModeID.Master] = copy;
Main.GameMode = Main.GameMode;
}
// Go through the old positions for the player.
for (int i = Player.Calamity().OldPositions.Length - 1; i > 0; i--)
{
+42
View File
@@ -0,0 +1,42 @@
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Systems
{
public class NerfExpertDebuffsSystem : ModSystem
{
public override void PostUpdateTime()
{
// Reduce the expert+ debuff time multiplier to the normal mode multiplier
if (CalamityConfig.Instance.NerfExpertDebuffs)
{
var copy = Main.RegisteredGameModes[GameModeID.Expert];
copy.DebuffTimeMultiplier = 1f;
Main.RegisteredGameModes[GameModeID.Expert] = copy;
copy = Main.RegisteredGameModes[GameModeID.Master];
copy.DebuffTimeMultiplier = 1f;
Main.RegisteredGameModes[GameModeID.Master] = copy;
// NOTE -- While this may seem at a glance to be redundant and nonsensical, the underlying setter for this property is what causes the game mode properties to
// be refreshed and copied from RegisteredGameModes. Without this, the above behavior is not reflected ingame, as GameModeData is a value type, not a reference type.
Main.GameMode = Main.GameMode;
}
// If people want to suffer, let them suffer
else
{
var copy = Main.RegisteredGameModes[GameModeID.Expert];
copy.DebuffTimeMultiplier = 2f;
Main.RegisteredGameModes[GameModeID.Expert] = copy;
copy = Main.RegisteredGameModes[GameModeID.Master];
copy.DebuffTimeMultiplier = 2.5f;
Main.RegisteredGameModes[GameModeID.Master] = copy;
Main.GameMode = Main.GameMode;
}
}
}
}