// called only once public override void Execute(EventQueue p_eventQueue) { if (SourceEntity.MarkedForDestruction) { Completed = true; return; } float l_costToMove = _ActionPoint.Calculations.actionPointBetweenNavigationNodes(SourceEntity.CurrentNavigationNode, TargetNavigationNode); ActionPoint l_actionPoint = EntityComponent.get_component <ActionPoint>(SourceEntity); MovementAllowed = (l_actionPoint.ActionPointData.CurrentActionPoints >= l_costToMove && NavigationGraphAlgorithm.areNavigationNodesNeighbors(NavigationGraphContainer.UniqueNavigationGraph, SourceEntity.CurrentNavigationNode, TargetNavigationNode, NavigationGraphFlag.CURRENT)); if (MovementAllowed) { LocomotionSystemV2.HeadTowardsNode(EntityComponent.get_component <Locomotion>(SourceEntity).LocomotionSystemV2, TargetNavigationNode, (p_startNavigationNode, p_endNavigationNode) => { ActionPoint.add(l_actionPoint, -1 * l_costToMove); Completed = true; }); } else { Completed = true; } }
public override void Execute(EventQueue p_eventQueue) { if ( !SourceEntity.MarkedForDestruction && !TargetEntity.MarkedForDestruction && NavigationGraphAlgorithm.areNavigationNodesNeighbors(NavigationGraphContainer.UniqueNavigationGraph, SourceEntity.CurrentNavigationNode, TargetEntity.CurrentNavigationNode, NavigationGraphFlag.SNAPSHOT)) { ActionPoint l_actionPoint = EntityComponent.get_component <ActionPoint>(SourceEntity); if (l_actionPoint.ActionPointData.CurrentActionPoints >= Attack.AttackData.APCost) { ActionPoint.add(EntityComponent.get_component <ActionPoint>(SourceEntity), -1 * Attack.AttackData.APCost); EntityGameWorld.orientTowards(ref SourceEntity.EntityGameWorld, TargetEntity, math.up()); float l_appliedDamage = Attack.resolve(Attack, TargetEntity); EventQueue.insertEventAt(p_eventQueue, 0, EntityApplyDamageEvent.alloc(TargetEntity, l_appliedDamage)); if (Attack.AttackBeforeDamageEventHook != null) { Attack.AttackBeforeDamageEventHook.SourceEntity = SourceEntity; Attack.AttackBeforeDamageEventHook.FeedEventQueue(p_eventQueue, 0); } } } }