using GAS.Runtime; namespace CoreGame.Render { // p1 0 增加 1 减少 public class Trigger_OnAnyCountChange : TriggerBase { public override void OnEvent(TriggerSpec self, int deltaCount, object param1) { if (deltaCount < 0 && triggerCfg.param1 == 1 // sub || deltaCount > 0 && triggerCfg.param1 == 0) // add { OnTrigger(self, 0, null); } } public override void Init(TriggerSpec self) { self.tagChangedHandle = (tag, deltaCount) => { OnEvent(self, deltaCount, null); }; var gameplayTag = GameplayTagsManager.RequestGameplayTag(triggerCfg.strParam1); self.owner.abilitySystem.GameplayTagCountContainer.RegisterGameplayTagEvent(gameplayTag, EGameplayTagEventType.AnyCountChange, self.tagChangedHandle); } public override void UnInit(TriggerSpec self) { var gameplayTag = GameplayTagsManager.RequestGameplayTag(triggerCfg.strParam1); self.owner.abilitySystem.GameplayTagCountContainer.UnregisterGameplayTagEvent(gameplayTag, EGameplayTagEventType.AnyCountChange, self.tagChangedHandle); } } }