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.
66 lines
2.7 KiB
66 lines
2.7 KiB
using CoreGame;
|
|
using Entitas;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class AttractorEndWaitCatchSystem : IExecuteSystem
|
|
{
|
|
private readonly IGroup<CombatEntity> m_AttractorGroup;
|
|
|
|
public AttractorEndWaitCatchSystem(Contexts contexts)
|
|
{
|
|
var matcher = CombatMatcher.AllOf(CombatMatcher.Attractor, CombatMatcher.WaitPickUpDropItem);
|
|
m_AttractorGroup = contexts.combat.GetGroup(matcher);
|
|
}
|
|
|
|
public void Execute(float deltaTime)
|
|
{
|
|
m_AttractorGroup.GetEntities(Contexts.s_CacheEntities);
|
|
if (Contexts.s_CacheEntities.Count == 0)
|
|
return;
|
|
for (int i = 0; i < Contexts.s_CacheEntities.Count; i++)
|
|
{
|
|
var attractorEnt = Contexts.s_CacheEntities[i];
|
|
if (attractorEnt.isDead)
|
|
{
|
|
attractorEnt.RemoveWaitPickUpDropItem();
|
|
continue;
|
|
}
|
|
|
|
var attractorPos = attractorEnt.transformProxy.position;
|
|
var range = attractorEnt.property.PickupRange;
|
|
var waitPickUpDropItem = attractorEnt.waitPickUpDropItem;
|
|
var targetDropItemEntity = Contexts.Combat.GetEntity(waitPickUpDropItem.dropItemEid);
|
|
if (!targetDropItemEntity.IsValid() || !targetDropItemEntity.hasWaitToBeAttracted ||
|
|
targetDropItemEntity.hasBeAttracted)
|
|
{
|
|
attractorEnt.RemoveWaitPickUpDropItem();
|
|
}
|
|
else
|
|
{
|
|
var waitToBeAttracted = targetDropItemEntity.waitToBeAttracted;
|
|
if (waitToBeAttracted.pickUpRange > 0.001f)
|
|
{
|
|
range = waitToBeAttracted.pickUpRange;
|
|
}
|
|
var et = targetDropItemEntity.transformProxy;
|
|
var inAreaRange = (attractorPos - et.position).SqrMagnitude() < range * range;
|
|
if (inAreaRange)
|
|
{
|
|
waitPickUpDropItem.timeAcc += deltaTime;
|
|
if (waitPickUpDropItem.timeAcc < waitToBeAttracted.pickUpTime)
|
|
continue;
|
|
attractorEnt.RemoveWaitPickUpDropItem();
|
|
// targetDropItemEntity.AddBeAttracted(attractorEnt.creationIndex, et.position,
|
|
// et.GetLocalScale().x, BattleConst.DropItemScale,
|
|
// BattleConst.DropItemFlyDuration);
|
|
}
|
|
else
|
|
{
|
|
attractorEnt.RemoveWaitPickUpDropItem();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|