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.
61 lines
1.9 KiB
61 lines
1.9 KiB
1 month ago
|
using CoreGame;
|
||
|
using Entitas;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace CoreGame.Render
|
||
|
{
|
||
|
public class BornSystem: IExecuteSystem
|
||
|
{
|
||
|
private readonly IGroup<CombatEntity> m_BornGroup;
|
||
|
|
||
|
public BornSystem(CombatContext contexts)
|
||
|
{
|
||
|
m_BornGroup = contexts.GetGroup(CombatMatcher.Born);
|
||
|
}
|
||
|
|
||
|
public void Execute(float deltaTime)
|
||
|
{
|
||
|
m_BornGroup.GetEntities(Contexts.s_CacheEntities);
|
||
|
for (int i = 0; i < Contexts.s_CacheEntities.Count; i++)
|
||
|
{
|
||
|
var ent = Contexts.s_CacheEntities[i];
|
||
|
Born(ent, deltaTime);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void Born(CombatEntity ent, float dt)
|
||
|
{
|
||
|
var bronComponent = ent.born;
|
||
|
bronComponent.delayCreateTime -= dt;
|
||
|
if (bronComponent.delayCreateTime <= 0)
|
||
|
{
|
||
|
ent.RemoveBorn();
|
||
|
|
||
|
RPCCaller.Call_SpawnEntity(ent);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (bronComponent.bornEffect == null)
|
||
|
{
|
||
|
bronComponent.bornEffect = GoPoolDic.GetPool(bronComponent.bornEffectPath).GetNewGo(BornEffect, ent.creationIndex);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void BornEffect(ReuseGoData goData)
|
||
|
{
|
||
|
var entity = Contexts.Combat.GetEntity(goData.interlockInd);
|
||
|
if (entity.IsValid() == false)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var blackboard = entity.blackboard;
|
||
|
goData.go.transform.localRotation = Quaternion.identity;
|
||
|
goData.go.transform.position = blackboard.GetBornPos();
|
||
|
var propDesc = MonsterPropDescMgr.Instance.GetConfig(blackboard.unitCfgId);
|
||
|
goData.go.transform.localScale = Vector3.one * (propDesc.VFXsize * BattleConst.TenThousandReverse).AsFloat;
|
||
|
goData.go.SetActiveWrap(true);
|
||
|
}
|
||
|
}
|
||
|
}
|