From 1d5f52e24dbeeb0b7f636fc69a7835667cfae7e9 Mon Sep 17 00:00:00 2001 From: Rebecca Kelly Date: Thu, 1 Sep 2022 17:23:08 -0400 Subject: [PATCH] RegisterBuiltins() removed in favour of using the BONSAIRC lump --- gun-bonsai/BONSAIRC | 53 ++++++++++++++++ gun-bonsai/CHANGELOG.md | 1 + gun-bonsai/ca.ancilla.bonsai/EventHandler.zs | 2 - .../ca.ancilla.bonsai/upgrades/Registry.zs | 61 ------------------- 4 files changed, 54 insertions(+), 63 deletions(-) diff --git a/gun-bonsai/BONSAIRC b/gun-bonsai/BONSAIRC index d3db69c..eb310af 100644 --- a/gun-bonsai/BONSAIRC +++ b/gun-bonsai/BONSAIRC @@ -31,6 +31,59 @@ # An list is the same but for upgrade names. Wildcards are not # supported; exact class names must be used. +# All builtin upgrades that don't require other mods to function are registered +# here. Mod-specific stanzas below tweak things further. +register + # player upgrades + TFLV_Upgrade_AmmoLeech + TFLV_Upgrade_ArmourLeech + TFLV_Upgrade_BlastShaping + TFLV_Upgrade_Intuition + TFLV_Upgrade_Juggler + TFLV_Upgrade_LifeLeech + TFLV_Upgrade_PlayerDamage + TFLV_Upgrade_Thorns + TFLV_Upgrade_ToughAsNails + # generic weapon upgrades + TFLV_Upgrade_BouncyShots + TFLV_Upgrade_DarkHarvest + TFLV_Upgrade_ExplosiveDeath + TFLV_Upgrade_ExplosiveShots + TFLV_Upgrade_FastShots + TFLV_Upgrade_FragmentationShots + TFLV_Upgrade_HomingShots + TFLV_Upgrade_PiercingShots + TFLV_Upgrade_RapidFire + TFLV_Upgrade_Shield + TFLV_Upgrade_Submunitions + TFLV_Upgrade_Swiftness + TFLV_Upgrade_WeaponDamage + # Fire upgrades + TFLV_Upgrade_IncendiaryShots + TFLV_Upgrade_BurningTerror + TFLV_Upgrade_Conflagration + TFLV_Upgrade_InfernalKiln + # Poison upgrades + TFLV_Upgrade_PoisonShots + TFLV_Upgrade_Weakness + TFLV_Upgrade_Putrefaction + TFLV_Upgrade_Hallucinogens + # Acid upgrades + TFLV_Upgrade_CorrosiveShots + TFLV_Upgrade_ConcentratedAcid + TFLV_Upgrade_AcidSpray + TFLV_Upgrade_Embrittlement + # Lightning upgrades + TFLV_Upgrade_ShockingInscription + TFLV_Upgrade_Revivification + TFLV_Upgrade_ChainLightning + TFLV_Upgrade_Thunderbolt + # elemental synthesis dual-element upgrades + TFLV_Upgrade_ElementalBeam + TFLV_Upgrade_ElementalBlast + TFLV_Upgrade_ElementalWave + ; + # Load Indestructable upgrade only if the Indestructable mod is also present. ifdef TFIS_IndestructableEventHandler { register TFLV_Upgrade_Indestructable; } diff --git a/gun-bonsai/CHANGELOG.md b/gun-bonsai/CHANGELOG.md index b42a992..441a3f4 100644 --- a/gun-bonsai/CHANGELOG.md +++ b/gun-bonsai/CHANGELOG.md @@ -16,6 +16,7 @@ - upgrade appendix moved into [its own file](./UPGRADES.md) - OnActivate/OnDeactivate API enabling new kinds of upgrades to be written - melee weapon detection should be more permissive now + - builtin upgrades are now registered via BONSAIRC lump - Fix: - crash when opening the menu while no weapon is equipped diff --git a/gun-bonsai/ca.ancilla.bonsai/EventHandler.zs b/gun-bonsai/ca.ancilla.bonsai/EventHandler.zs index 540188a..3a92def 100644 --- a/gun-bonsai/ca.ancilla.bonsai/EventHandler.zs +++ b/gun-bonsai/ca.ancilla.bonsai/EventHandler.zs @@ -12,9 +12,7 @@ class ::EventHandler : StaticEventHandler { override void OnRegister() { DEBUG("Initializing Gun Bonsai..."); - // Register all builtin upgrades. UPGRADE_REGISTRY = new("::Upgrade::Registry"); - UPGRADE_REGISTRY.RegisterBuiltins(); if (::Settings.have_legendoom()) { console.printf("%s", StringTable.Localize("$TFLV_MSG_LD_YES")); diff --git a/gun-bonsai/ca.ancilla.bonsai/upgrades/Registry.zs b/gun-bonsai/ca.ancilla.bonsai/upgrades/Registry.zs index e40af7a..45aad49 100644 --- a/gun-bonsai/ca.ancilla.bonsai/upgrades/Registry.zs +++ b/gun-bonsai/ca.ancilla.bonsai/upgrades/Registry.zs @@ -31,67 +31,6 @@ class ::Registry : Object play { upgrades.delete(idx); } - // Can't be static because we need to call it during eventmanager initialization, - // and at that point the EventHandler isn't findable. - void RegisterBuiltins() { - DEBUG("RegisterBuiltins"); - static const string UpgradeNames[] = { - // "::Agonizer", - "::AmmoLeech", - "::ArmourLeech", - // "::Beam", TODO: fix interactions with HE shots and similar - "::BlastShaping", - "::BouncyShots", - "::DarkHarvest", - "::ExplosiveDeath", - "::ExplosiveShots", - "::FastShots", - "::FragmentationShots", - "::HomingShots", - // "::Ignition", - "::Intuition", - "::Juggler", - "::LifeLeech", - "::PiercingShots", - "::PlayerDamage", - "::RapidFire", - "::Shield", - "::Submunitions", - "::Swiftness", - "::Thorns", - "::ToughAsNails", - "::WeaponDamage", - // Fire upgrades - "::IncendiaryShots", - "::BurningTerror", - "::Conflagration", - "::InfernalKiln", - // Poison upgrades - "::PoisonShots", - "::Weakness", - "::Putrefaction", - "::Hallucinogens", - // Acid upgrades - "::CorrosiveShots", - "::ConcentratedAcid", - "::AcidSpray", - "::Embrittlement", - // Lightning upgrades - "::ShockingInscription", - "::Revivification", - "::ChainLightning", - "::Thunderbolt", - // Dual-element power moves - "::ElementalBeam", - "::ElementalBlast", - "::ElementalWave" - }; - for (uint i = 0; i < UpgradeNames.size(); ++i) { - upgrade_names.push(UpgradeNames[i]); - upgrades.push(::BaseUpgrade(new(UpgradeNames[i]))); - } - } - // Returns true if Indestructable has delegated management of lives to Gun Bonsai. static bool IsIndestructableDelegated() { return CVar.FindCVar("indestructable_starting_lives").GetInt() == 0