Skip to content

Commit

Permalink
RegisterBuiltins() removed in favour of using the BONSAIRC lump
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicFrog committed Sep 1, 2022
1 parent 769a2b3 commit 1d5f52e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 63 deletions.
53 changes: 53 additions & 0 deletions gun-bonsai/BONSAIRC
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,59 @@
# An <upgrades> 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; }

Expand Down
1 change: 1 addition & 0 deletions gun-bonsai/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions gun-bonsai/ca.ancilla.bonsai/EventHandler.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
61 changes: 0 additions & 61 deletions gun-bonsai/ca.ancilla.bonsai/upgrades/Registry.zs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1d5f52e

Please sign in to comment.