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.

63 lines
2.5 KiB

1 month ago
using System.Collections.Generic;
using CoreGame;
using Entitas;
using GAS.Runtime;
namespace CoreGame.Render
{
/// <summary>
/// 刷新可刷新的护盾
/// </summary>
public class RefreshableHpShieldReloadSystem : IExecuteSystem
{
readonly IGroup<CombatEntity> m_Group;
public static Dictionary<int, string> s_Element2Res = new()
{
{(int)ElementType.None, "Assets/GAS_Setting/Config/GameplayAbilityLib/temp/GE_HpShield_BossNone.asset"},
{(int)ElementType.Fire, "Assets/GAS_Setting/Config/GameplayAbilityLib/temp/GE_HpShield_BossFire.asset"},
{(int)ElementType.Toxic, "Assets/GAS_Setting/Config/GameplayAbilityLib/temp/GE_HpShield_BossToxic.asset"},
{(int)ElementType.Thunder, "Assets/GAS_Setting/Config/GameplayAbilityLib/temp/GE_HpShield_BossThunder.asset"},
};
public RefreshableHpShieldReloadSystem(CombatContext contexts)
{
var gunReloadMatcher =
(Matcher<CombatEntity>)Matcher<CombatEntity>.AllOf(CombatComponentsLookup.RefreshableHpShield,
CombatComponentsLookup.Reload);
m_Group = contexts.GetGroup(gunReloadMatcher);
}
public void Execute(float dt)
{
m_Group.GetEntities(Contexts.s_CacheEntities);
if (Contexts.s_CacheEntities.Count == 0)
return;
var entities = Contexts.s_CacheEntities;
for (int i = 0; i < entities.Count; i++)
{
var entity = entities[i];
var reload = entity.reload;
reload.cdAcc += dt;
if (reload.cdAcc < reload.cdTotal || entity.isMainAssetLoaded == false)
continue;
// 刷新护盾
entity.RemoveReload();
s_Element2Res.TryGetValue((int)entity.refreshableHpShield.elementType, out var res);
var gameplayEffect = AbilitySrv.GetGameplayEffect(res);
if (gameplayEffect != null)
{
var effectParams = new GameplayEffectParams();
var abilitySystem = entity.abilitySystem;
effectParams.level = 1;
effectParams.source = abilitySystem;
effectParams.owner = abilitySystem;
abilitySystem.ApplyGameplayEffectTo_WithParams(gameplayEffect, effectParams);
}
}
}
}
}