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); } } } }
public void Tick(float d) { if (HeadingTowardsTargetNode) { float3 l_initialDirection = math.normalize(CurrentDestination - LocomotionComponent.AssociatedEntity.EntityGameWorld.RootGround.WorldPosition); float3 l_targetPosition = LocomotionComponent.AssociatedEntity.EntityGameWorld.RootGround.WorldPosition + (l_initialDirection * LocomotionComponent.LocomotionData.Speed * d); float3 l_finalDirection = math.normalize(CurrentDestination - l_targetPosition); // If the initial direction is not the same as the final direction, this means that the destination point has been crossed // thus, the destination is reached bool l_isDestinationReached = math.dot(l_initialDirection, l_finalDirection) <= 0.0f; if (l_isDestinationReached) { /* * When the NavigationNode is reached, we set the position to the exact final location. */ l_targetPosition = CurrentDestination; } LocomotionComponent.AssociatedEntity.EntityGameWorld.RootGround.WorldPosition = l_targetPosition; if (l_isDestinationReached) { HeadingTowardsTargetNode = false; NavigationNode l_oldNavigationNode = LocomotionComponent.AssociatedEntity.CurrentNavigationNode; if (OnNavigationNodeReachedEvent != null) { OnNavigationNodeReachedEvent.Invoke(l_oldNavigationNode, CurrentTargetNode); } } else { float3 l_orientationDirection = l_initialDirection.ProjectOnPlane(math.up()); EntityGameWorld.orientTowards(ref LocomotionComponent.AssociatedEntity.EntityGameWorld, ref l_orientationDirection); } } }