Skip to content

Understanding The Cyclops Upgrade Cycle

PrimeSonic edited this page Apr 14, 2020 · 5 revisions

Originally introduced in the 3.0 update and later refined in the 4.0 overhaul, MoreCyclopsUpgrades can now be used as a public API, allowing other mods to integrate their own cyclops upgrade modules and have them be fully compatible with the Auxiliary Upgrade Console.


Understanding the Cyclops upgrade handling cycle

Cyclops upgrades are handled differently than vehicles.
Instead of checking when an individual upgrade module is added or removed, the Cyclops SubRoot class checks all upgrades during a single Update cycle when its subModulesDirty field is set to true.
Upgrades are first disabled and then each is enabled again as its corresponding upgrade module is found in the upgrade console equipment slots.

It's unclear why the Cyclops handles upgrades differently from the small vehicles, even though the vanilla upgrades for the Cyclops aren't any more complex than the ones for the Seamoth and Prawn Suit.
Regardless, with the addition of the Auxiliary Upgrade Consoles, it became much more useful to adopt this pattern so that it would be easier to treat upgrade modules across all upgrade consoles as a single collection.

MoreCyclopsUpgrades provides an upgrade cycle that mimics that same process but instead of the SubRoot class itself handling the upgrade module effects directly, each UpgradeHandler is tasked with enabling, disabling, or updating any effects for upgrade modules it manages.

The Cyclops Upgrade Cycle is handled by the UpgradeManager and follows this 3-step process:

  1. Clear Upgrades
    The OnClearUpgrades event is invoked on all UpgradeHandlers.
    All Count values are reset to 0.
    This step can be used to reset an upgrade status back to its disabled state. This mimics how SubRoot originally would start by disabling upgrades before checking for which ones to activate.
  2. Count Upgrades
    All upgrade slots are checked, one by one.
    When a non-empty slot is found, the OnUpgradeCounted and OnUpgradeCountedDetailed events are invoked on the UpgradeHandler managing that upgrade type.
    Some simple upgrades can be enabled here.
  3. Finalize Upgrades
    The OnFinishedUpgrades event is invoked on all UpgradeHandlers.
    Any final handling can be performed here for upgrade types that need to know the status of several slots before taking action.
    Stacking or tiered upgrade modules (like Depth and Engine upgrades) need to be fully counted before they can be enabled.
    UpgradeHandlers that need to take action on having no upgrades found will act here.

Every time an upgrade module is added or removed from any Cyclops upgrade module, the subModulesDirty field is set to true and these events all happen again on the next Update cycle.


If you need to check if an upgrade module is installed outside of the upgrade handling cycle,
then you have a few options

  1. For simply checking if a single upgrade is installed or not, you can pass your TechType value to the HasUpgradeInstalled method of the MCU CrossMod Service
  2. You can also find your upgrade handler and check its public properties.
Clone this wiki locally
  翻译: