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