public override void RunEvent(EventManager callingEventManagerIn) { callingEventManager = callingEventManagerIn; //Check if the goal is one move away and if it is not occupied if (Math.Abs(elementToMove.getWorldPositionX() - destination.X) + Math.Abs(elementToMove.getWorldPositionY() - destination.Y) <= 1) { if (moveGoingOn || !associatedMap.getOccupied(destination)) { //In this case we either only have to move one step - or this is a component of a larger path this.MoveToDestination(); } else { elementToMove.SetStuck(true); //kill user event if this wasn't a child if (elementToMove.GetFinalDestination() == destination) { this.SetComplete(); elementToMove.KillLinkedMovement(); } else { this.SetComplete(); } } } else { if (reattemptCounter > reattemptLimit) { elementToMove.SetStatusMessage("Ran out of attempts"); this.ShutdownSmoothly(); elementToMove.KillLinkedMovement(); } if (!this.GetShutdownSmoothly()) { if (pathFound) { movementWasPossible = true; this.PerformNextMove(); } else { if (flowMapProduced) { this.GeneratePath(); } else { this.DevelopFlowMap(); } } } else { elementToMove.KillLinkedMovement(); this.SetComplete(); } } if (!this.GetShutdownSmoothly()) { //reached destination if ((Math.Abs(elementToMove.getWorldPositionX() - elementToMove.GetFinalDestination().X) + Math.Abs(elementToMove.getWorldPositionY() - elementToMove.GetFinalDestination().Y) == 0)) { elementToMove.KillLinkedMovement(); } } }