From 9b76ff33dced6f575484eedfd5cb3e12aba7cf84 Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Mon, 13 Jun 2022 16:16:22 -0400 Subject: [PATCH] Added a huge amount of TODOs for ModSystem de-godclassing --- Balancing/BalancingChangesManager.cs | 1 + CalPlayer/Dashes/PlayerDashManager.cs | 1 + CalamityLists.cs | 1 + CalamityMod.cs | 15 +++++++++++++-- Cooldowns/CooldownRegistry.cs | 1 + DataStructures/Attunement.cs | 1 + DataStructures/NPCStats.cs | 1 + Effects/CalamityShaders.cs | 1 + Events/BossRushEvent.cs | 1 + ILEditing/ILChangesLoading.cs | 1 + Items/CalamityGlobalItemTweaks.cs | 2 ++ .../VanillaArmorChangeManager.cs | 3 ++- Particles/FusableParticleManager.cs | 2 ++ Particles/GeneralParticleHandler.cs | 1 + .../BaseProjectiles/BaseIdleHoldoutProjectile.cs | 2 ++ Schematics/SchematicManager.cs | 1 + Systems/SpeedrunTimerStoppingSystem.cs | 1 + UI/AstralArcanumUI.cs | 1 + UI/CalamitasEnchantments/EnchantmentManager.cs | 1 + UI/ChargeMeterUI.cs | 1 + UI/InvasionProgressUIManager.cs | 3 ++- UI/PopupGUIManager.cs | 3 ++- UI/RipperUI.cs | 1 + UI/SpeedrunTimerUI.cs | 1 + UI/StealthUI.cs | 1 + Utilities/CalamityRecipes.cs | 1 + Utilities/TileFraming.cs | 2 ++ Waters/CustomLavaManagement.cs | 1 + World/DraedonStructures.cs | 1 + 29 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 4a7b99e0b1..7bbe75d4cd 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -20,6 +20,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod.Balancing { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class BalancingChangesManager { internal static List UniversalBalancingChanges = null; diff --git a/CalPlayer/Dashes/PlayerDashManager.cs b/CalPlayer/Dashes/PlayerDashManager.cs index ba201a57c1..c0f3f54b0b 100644 --- a/CalPlayer/Dashes/PlayerDashManager.cs +++ b/CalPlayer/Dashes/PlayerDashManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; namespace CalamityMod.CalPlayer.Dashes { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class PlayerDashManager { internal static Dictionary DashIdentificationTable = new(); diff --git a/CalamityLists.cs b/CalamityLists.cs index b01d8862a0..87956e9fbb 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -75,6 +75,7 @@ using static Terraria.ModLoader.ModContent; namespace CalamityMod { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class CalamityLists { public static IList donatorList; diff --git a/CalamityMod.cs b/CalamityMod.cs index f8ecb74332..e3ce48e267 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -74,7 +74,9 @@ namespace CalamityMod { public class CalamityMod : Mod { - // CONSIDER -- I have been advised by Jopo that Mods should never contain static variables + // TODO -- A huge amount of random floating variables exist here. + // These should all be moved to other files, whether that's CalamityLists or brand new ModSystems. + // It is best to have a ton of small ModSystems. // Boss Spawners public static int ghostKillCount = 0; @@ -117,8 +119,11 @@ namespace CalamityMod public static int[] holyEnemyImmunities = new int[4] { BuffID.OnFire, BuffID.OnFire3, ModContent.BuffType(), ModContent.BuffType() }; internal static CalamityMod Instance; + + // TODO -- Mod references should be contained in a ModSystem (example name "ModLoadedChecker") internal Mod musicMod = null; // This is Calamity's official music mod, CalamityModMusic internal bool MusicAvailable => !(musicMod is null); + internal Mod ancientsAwakened = null; internal Mod bossChecklist = null; internal Mod census = null; @@ -144,7 +149,7 @@ namespace CalamityMod manaOriginal = TextureAssets.Mana; carpetOriginal = TextureAssets.FlyingCarpet; - // Apply IL edits instantly afterwards. + // Apply IL edits as soon as possible. ILChanges.Load(); // If any of these mods aren't loaded, it will simply keep them as null. @@ -198,6 +203,7 @@ namespace CalamityMod CooldownRegistry.Load(); BossRushEvent.Load(); + // TODO -- As ModBossBarStyle is a ModType, its Load function does not need to be called directly here. BossHealthBarManager.Load(this); DraedonStructures.Load(); EnchantmentManager.LoadAllEnchantments(); @@ -219,6 +225,7 @@ namespace CalamityMod { AstralSky = ModContent.Request("CalamityMod/ExtraTextures/AstralSky", AssetRequestMode.ImmediateLoad).Value; + // TODO -- Sky shaders should probably be loaded in a ModSystem Filters.Scene["CalamityMod:DevourerofGodsHead"] = new Filter(new DoGScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.1f, 1.0f).UseOpacity(0.5f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:DevourerofGodsHead"] = new DoGSky(); @@ -271,6 +278,8 @@ namespace CalamityMod ChargeMeterUI.Load(); AstralArcanumUI.Load(this); + // TODO -- Is this not possible to place in ModNPC.Load or ModNPC.SetStaticDefaults ? + // Centralizing head texture registration like this seems absurdly stiff Apollo.LoadHeadIcons(); Artemis.LoadHeadIcons(); DevourerofGodsHead.LoadHeadIcons(); @@ -285,6 +294,8 @@ namespace CalamityMod ThanatosBody2.LoadHeadIcons(); ThanatosTail.LoadHeadIcons(); + // TODO -- Is this not possible to place in ModItem.Load or ModItem.SetStaticDefaults ? + // Centralizing hair dye shaders like this seems absurdly stiff GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(139, 205, 255), ((float)player.wingTime / (float)player.wingTimeMax)))); diff --git a/Cooldowns/CooldownRegistry.cs b/Cooldowns/CooldownRegistry.cs index 76328fbcad..e8b078d334 100644 --- a/Cooldowns/CooldownRegistry.cs +++ b/Cooldowns/CooldownRegistry.cs @@ -6,6 +6,7 @@ using Terraria.ModLoader.Core; namespace CalamityMod.Cooldowns { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class CooldownRegistry { // Indexed by ushort netID. Contains every registered cooldown. diff --git a/DataStructures/Attunement.cs b/DataStructures/Attunement.cs index 7c69e90b33..ddb83e0ca1 100644 --- a/DataStructures/Attunement.cs +++ b/DataStructures/Attunement.cs @@ -18,6 +18,7 @@ namespace CalamityMod.DataStructures Phoenix, Aries, Polaris, Andromeda //Galaxia } + // TODO -- Attunements should be managed by an Attunement ModSystem public abstract class Attunement { public static Attunement[] attunementArray; diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 6e84e3521c..1a6bf73040 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -41,6 +41,7 @@ using CalamityMod.NPCs.AcidRain; namespace CalamityMod { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static partial class NPCStats { private const double ExpertContactVanillaMultiplier = 2D; diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 553b0d522d..5ad4d373db 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -7,6 +7,7 @@ using Terraria.Graphics.Shaders; namespace CalamityMod.Effects { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class CalamityShaders { public static Effect AstralFogShader; diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 0a9968e5b3..f129dc7317 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -39,6 +39,7 @@ using Terraria.DataStructures; namespace CalamityMod.Events { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class BossRushEvent { public enum TimeChangeContext diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index c73157c015..5d43a38f81 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -8,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.ILEditing { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public partial class ILChanges { /// diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index d39efe5028..b6318a102d 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -7,6 +7,8 @@ using Terraria.ModLoader; namespace CalamityMod.Items { + // TODO -- The item tweaks database and functions should be stored in a ModSystem. + // ApplyTweaks(ref Item item) would be the one exposed function, which CalamityGlobalItem would call in SetDefaults. public partial class CalamityGlobalItem : GlobalItem { #region Database and Initialization diff --git a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs index 8708ebc62a..9de535f8ee 100644 --- a/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs +++ b/Items/VanillaArmorChanges/VanillaArmorChangeManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; @@ -7,6 +7,7 @@ using Terraria.ID; namespace CalamityMod.Items.VanillaArmorChanges { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class VanillaArmorChangeManager { internal static List ArmorChanges; diff --git a/Particles/FusableParticleManager.cs b/Particles/FusableParticleManager.cs index b8c3f171e1..50989324a8 100644 --- a/Particles/FusableParticleManager.cs +++ b/Particles/FusableParticleManager.cs @@ -16,6 +16,8 @@ namespace CalamityMod.Particles // As such, it is littered with many netMode checks. While some may be overprotective in their nature it is critical that // failsafes exist there, as visual failures tend to result in engine crashes, which will kill a lot of MP servers. // If someone other than me for any reason attempts to notably expand upon this system you must keep this in mind. -Dominic + + // TODO -- This can be made into a ModSystem. Its main thread load dependency with render targets is safe to put in OnModLoad. public static class FusableParticleManager { internal static List ParticleSets = new List(); diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 1c113bd1bc..827da34280 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -11,6 +11,7 @@ using Terraria.ModLoader.Core; namespace CalamityMod.Particles { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class GeneralParticleHandler { private static List particles; diff --git a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs index 977a39de53..b8e90601eb 100644 --- a/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseIdleHoldoutProjectile.cs @@ -17,6 +17,8 @@ namespace CalamityMod.Projectiles.BaseProjectiles public abstract int IntendedProjectileType { get; } public static Dictionary ItemProjectileRelationship = new(); + // TODO -- There is no reason this load hook should need to be called from CalamityMod. + // All subclasses of this should be ILoadable and should load themselves. public static void LoadAll() { ItemProjectileRelationship = new Dictionary(); diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index 95a0bbb3e0..fb4db262ff 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Schematics { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class SchematicManager { internal const string RustedWorkshopKey = "Rusted Workshop"; diff --git a/Systems/SpeedrunTimerStoppingSystem.cs b/Systems/SpeedrunTimerStoppingSystem.cs index c67b0b3911..0923a54879 100644 --- a/Systems/SpeedrunTimerStoppingSystem.cs +++ b/Systems/SpeedrunTimerStoppingSystem.cs @@ -2,6 +2,7 @@ namespace CalamityMod.Systems { + // TODO -- Expand this ModSystem to contain the Speedrun Timer itself, as well as the UI. public class SpeedrunTimerStoppingSystem : ModSystem { public override void PreSaveAndQuit() => CalamityMod.SpeedrunTimer?.Stop(); diff --git a/UI/AstralArcanumUI.cs b/UI/AstralArcanumUI.cs index b614015ea1..f86695a739 100644 --- a/UI/AstralArcanumUI.cs +++ b/UI/AstralArcanumUI.cs @@ -10,6 +10,7 @@ using ReLogic.Content; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class AstralArcanumUI { enum CircleStyle diff --git a/UI/CalamitasEnchantments/EnchantmentManager.cs b/UI/CalamitasEnchantments/EnchantmentManager.cs index 2871dc1ac5..dc0631ac55 100644 --- a/UI/CalamitasEnchantments/EnchantmentManager.cs +++ b/UI/CalamitasEnchantments/EnchantmentManager.cs @@ -13,6 +13,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI.CalamitasEnchants { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class EnchantmentManager { internal const int ClearEnchantmentID = -18591774; diff --git a/UI/ChargeMeterUI.cs b/UI/ChargeMeterUI.cs index b6ea73e722..064decaeeb 100644 --- a/UI/ChargeMeterUI.cs +++ b/UI/ChargeMeterUI.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class ChargeMeterUI { // These values were handpicked on a 1080p screen by Ozzatron. Please disregard the bizarre precision. diff --git a/UI/InvasionProgressUIManager.cs b/UI/InvasionProgressUIManager.cs index 3081d57271..b673f5b890 100644 --- a/UI/InvasionProgressUIManager.cs +++ b/UI/InvasionProgressUIManager.cs @@ -1,10 +1,11 @@ -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class InvasionProgressUIManager { private static readonly List gUIs = new List(); diff --git a/UI/PopupGUIManager.cs b/UI/PopupGUIManager.cs index 513378c193..61c72bbf6e 100644 --- a/UI/PopupGUIManager.cs +++ b/UI/PopupGUIManager.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; @@ -6,6 +6,7 @@ using Terraria; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class PopupGUIManager { private static readonly List gUIs = new List(); diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index d7d4c944ea..1d5f7e7ff0 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -11,6 +11,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class RipperUI { // These values were handpicked on a 1080p screen by Ozzatron. Please disregard the bizarre precision. diff --git a/UI/SpeedrunTimerUI.cs b/UI/SpeedrunTimerUI.cs index eed608a72f..8cd76263fb 100644 --- a/UI/SpeedrunTimerUI.cs +++ b/UI/SpeedrunTimerUI.cs @@ -32,6 +32,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { + // TODO -- Combine with SpeedrunTimerStoppingSystem, which should be renamed and call the UI draw code in this file. public class SpeedrunTimerUI { // These values put the Speedrun Timer roughly at the top center of a 1080p screen. diff --git a/UI/StealthUI.cs b/UI/StealthUI.cs index d6f81d3296..4d43be5df0 100644 --- a/UI/StealthUI.cs +++ b/UI/StealthUI.cs @@ -9,6 +9,7 @@ using Terraria.ModLoader; namespace CalamityMod.UI { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public class StealthUI { // These values were handpicked on a 1080p screen by Ozzatron. Please disregard the bizarre precision. diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 81b909184c..f1045ceafe 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -18,6 +18,7 @@ using Terraria.ModLoader; namespace CalamityMod { + // TODO -- Change this to a ModSystem so it does not need to be manually loaded from CalamityMod internal class CalamityRecipes { private static Recipe CreateRecipe(int itemID, int stack = 1) => CalamityMod.Instance.CreateRecipe(itemID, stack); diff --git a/Utilities/TileFraming.cs b/Utilities/TileFraming.cs index d490efc7b8..6ffeacb591 100644 --- a/Utilities/TileFraming.cs +++ b/Utilities/TileFraming.cs @@ -13,6 +13,8 @@ using Terraria.ModLoader; namespace CalamityMod { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. + // OnModLoad is guaranteed to be run after all content has autoloaded. public static class TileFraming { private static int[][] PlantCheckAgainst; diff --git a/Waters/CustomLavaManagement.cs b/Waters/CustomLavaManagement.cs index 3ba4dac11d..8006f2ed39 100644 --- a/Waters/CustomLavaManagement.cs +++ b/Waters/CustomLavaManagement.cs @@ -10,6 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.Waters { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class CustomLavaManagement { internal static List CustomLavaStyles; diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index b5102fa65a..5e41427fc2 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -14,6 +14,7 @@ using static CalamityMod.Schematics.SchematicManager; namespace CalamityMod.World { + // TODO -- This can be made into a ModSystem with simple OnModLoad and Unload hooks. public static class DraedonStructures { private static int[] otherModTilesToAvoid;