CustomGameplayModifiers
Custom gameplay modifiers library
CHANGELOG
#v1.0.1
Declarative StatModificationAdd pattern
ModifierInstance(CustomGameplayModifiers/Framework/Abstractions/ModifierInstance.cs): Adds a virtualStatModificationAddproperty (Func<ModifierStat, GameObject, float>) returning stat bonuses declaratively.- Replaces the imperative
AddStatModifier/RemoveStatModifierpattern — overrideStatModificationAddand wire it viaLiveModifier.GetStatModificationAdd = StatModificationAddinOnActivated(). - Eliminates tracking active/inactive state and manual cleanup of stat modifiers on removal.
Preview lifecycle
ItemModuleInstance(CustomGameplayModifiers/ItemModules/ItemModuleInstance.cs): AddsIsPreviewproperty andOnPreviewActivated()virtual method.- When the game creates a preview instance (loadout GUI),
OnPreviewActivated()automatically wiresStatModificationAdd, giving accurate stat readouts without additional code.
New events
ShipCannonFiredEvent(CustomGameplayModifiers/Framework/EventType/ShipCannonFiredEvent.cs): Published whenPlayerShip_IndividualTurretController.Firefires.AIShipDamagedEvent(CustomGameplayModifiers/Framework/EventType/AIShipDamagedEvent.cs): Published whenAI_Capability_Ship_Health.DamageRecievedis called.- Both wired via new Harmony patches in
CustomGameplayModifiers/Patches/EventHooks.cs.
Refactored examples
ExampleItemModule: Jump boost now usesStatModificationAddinstead of theItemHeldChangedEventsubscription. RemovedHandleHeldChanged.ReloadDamageModule: Damage bonus now usesStatModificationAddinstead of manualAddStatModifier/RemoveStatModifier. SimplifiedHandleReloadandHandleFired.ExamplePlayerTrait: Completely simplified — removedFloatObserver,OnHealthChanged,ApplyBoost/RemoveBoost. Replaced withStatModificationAddand a trivialInitWhenReadycoroutine.
New example: ExampleComponentModule
- Demonstrates targeting ship components (pilot cannons) via
ItemAssetRegistry.GetAllComponentsBySubtype(ComponentSubtype.PilotCannon). - Uses
StatModificationAddforModifierStat.ShipDamage. - Reacts to
AIShipDamagedEventto duplicate damaged enemy ships. - Registered in
ExampleMod/Core.cs.