You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

1 month ago
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);
}
}
}