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.
127 lines
4.9 KiB
127 lines
4.9 KiB
1 month ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using AOT;
|
||
|
using CoreGame.Logic;
|
||
|
using GAS.Runtime;
|
||
|
using xFrame;
|
||
|
|
||
|
|
||
|
namespace CoreGame.Render
|
||
|
{
|
||
|
public static class TriggerSrv
|
||
|
{
|
||
|
public static Dictionary<int, Type> s_TypesMap = new()
|
||
|
{
|
||
|
{ (int)TriggerType.OnAdd, typeof(Trigger_OnGranted) },
|
||
|
{ (int)TriggerType.CriticalHit, typeof(Trigger_Critical) },
|
||
|
{ (int)TriggerType.KillEntity, typeof(Trigger_OnKillEntity) },
|
||
|
{ (int)TriggerType.ChangeGun, typeof(Trigger_ChangeGun) },
|
||
|
{ (int)TriggerType.GunReloadStart, typeof(Trigger_GunReloadStart) },
|
||
|
{ (int)TriggerType.GunReloadEnd, typeof(Trigger_GunReloadEnd) },
|
||
|
{ (int)TriggerType.OnCatchDropItem, typeof(Trigger_OnCatchDropItem) },
|
||
|
{ (int)TriggerType.DurationShoot, typeof(Trigger_OnDurationShoot) },
|
||
|
{ (int)TriggerType.HeadShotHit, typeof(Trigger_HeadShot) },
|
||
|
{ (int)TriggerType.StunHit, typeof(Trigger_Stun) },
|
||
|
{ (int)TriggerType.NoMovementTime, typeof(Trigger_NoMovementTime) },
|
||
|
{ (int)TriggerType.ShootBouncyBullets, typeof(Trigger_OnShootBouncyBullets) },
|
||
|
{ (int)TriggerType.OnBulletBounce, typeof(Trigger_OnBulletBounce) },
|
||
|
{ (int)TriggerType.OnDamage, typeof(Trigger_OnDamage) },
|
||
|
{ (int)TriggerType.OnTakeDamage, typeof(Trigger_OnTakeDamage) },
|
||
|
{ (int)TriggerType.LevelMonsterRage, typeof(Trigger_LevelMonsterRage) },
|
||
|
{ (int)TriggerType.ReviveEntity, typeof(Trigger_OnReviveEntity) },
|
||
|
{ (int)TriggerType.OnDotBoomDmg, typeof(Trigger_OnDotBoomDmg) },
|
||
|
{ (int)TriggerType.MakeEntityCannotBeHurt, typeof(Trigger_MakeEntityCannotBeHurt) },
|
||
|
{ (int)TriggerType.LossHp, typeof(Trigger_OnLossHp) },
|
||
|
{ (int)TriggerType.ChangeGunSkillEnd, typeof(Trigger_ChangeGunSkillEnd) },
|
||
|
{ (int)TriggerType.NewOrRemoved, typeof(Trigger_OnNewOrRemoved) },
|
||
|
{ (int)TriggerType.AnyCountChange, typeof(Trigger_OnAnyCountChange) },
|
||
|
{ (int)TriggerType.SuppressHit, typeof(Trigger_Suppress) },
|
||
|
};
|
||
|
|
||
|
public static Dictionary<int, TriggerBase> s_TriggerTemplateMap = new();
|
||
|
|
||
|
public static TriggerBase NewTriggerTemplate(int triggerId, TriggerAction triggerAction)
|
||
|
{
|
||
|
var tbTrigger = TriggerDescMgr.Instance.GetConfig(triggerId);
|
||
|
if (tbTrigger == null)
|
||
|
return null;
|
||
|
|
||
|
if (s_TriggerTemplateMap.TryGetValue(triggerId, out var instance))
|
||
|
{
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
if (s_TypesMap.TryGetValue((int)tbTrigger.triggerType, out var type))
|
||
|
{
|
||
|
instance = (TriggerBase)Activator.CreateInstance(type);
|
||
|
instance.ParseCfg(tbTrigger);
|
||
|
s_TriggerTemplateMap.Add(triggerId, instance);
|
||
|
}
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
public static void ReleaseTask(ref InstantListenTaskSpec task)
|
||
|
{
|
||
|
SptPool.Free(task.classType, task);
|
||
|
task = null;
|
||
|
}
|
||
|
|
||
|
public static void Init()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
// 检查ga,ge是否能触发, 阻塞触发计数
|
||
|
public static bool CheckTagAndBlockAcc(TriggerSpec self, bool flag)
|
||
|
{
|
||
|
// 检查是能触发
|
||
|
if (flag == false)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (self.abilitySpec != null)
|
||
|
{
|
||
|
var canActivate = self.abilitySpec.CheckGameplayTagsValidTpActivate();
|
||
|
if (canActivate == false)
|
||
|
{
|
||
|
XLog.LogDebug($"ability不能激活,触发器不能触发 {canActivate}");
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
var canRunning = self.effectSpec.GameplayEffect.CanRunning(self.effectSpec.Owner);
|
||
|
if (canRunning == false)
|
||
|
{
|
||
|
XLog.LogDebug($"effect不能激活,触发器不能触发 {canRunning}");
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static void AssembleTriggerAbilitySpecCtx(TriggerSpec spec, HurtData hurtData, bool isCaster = false)
|
||
|
{
|
||
|
if (spec.abilitySpec == null) return;
|
||
|
var ctx = spec.abilitySpec.ctx;
|
||
|
ctx.castTarget.Clear();
|
||
|
ctx.castPos.Clear();
|
||
|
if (!isCaster)
|
||
|
{
|
||
|
ctx.castTarget.Add(hurtData.dst.creationIndex);
|
||
|
ctx.castPos.Add(hurtData.dst.logicTransform.position);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
var caster = TargetSelectSrv.GetCaster(hurtData.src) ?? hurtData.src;
|
||
|
if (caster.IsValid())
|
||
|
{
|
||
|
ctx.castTarget.Add(caster.creationIndex);
|
||
|
ctx.castPos.Add(caster.logicTransform.position);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|