private void PushPathBlockedStateNew(Mover mover, Mover blocker, float blockerDistance, List <Mover> obstacles) { if (mover.AIController != null && !Cutscene.CutsceneActive) { if (!mover.AIController.StateManager.CurrentState.AllowBlockedMovement()) { return; } mover.SaveBlockedRoute(); if (mover.AIController is PartyMemberAI) { if (mover.AIController.StateManager.CurrentState is AI.Player.WaitForClearPath) { return; } AI.Player.WaitForClearPath waitForClearPath = AIStateManager.StatePool.Allocate <AI.Player.WaitForClearPath>(); waitForClearPath.Blocker = blocker; waitForClearPath.BlockerDistance = blockerDistance; mover.AIController.StateManager.PushState(waitForClearPath, false); if (obstacles != null && obstacles.Count > 0) { waitForClearPath.Obstacles.AddRange(obstacles); } } else { if (mover.AIController.StateManager.CurrentState is AI.Plan.WaitForClearPath) { return; } if (IEModOptions.ImprovedAI) // added this if statement { // race condition if both Mover and PathFindingManager decide they are blocked in the same tick if (mover.AIController.StateManager.CurrentState is AI.Plan.ApproachTarget) { return; } var pathToPosition = mover.AIController.StateManager.CurrentState as AI.Achievement.PathToPosition; if (pathToPosition != null) { if (((Mod_AI_PathToPosition)pathToPosition).TryToPickNewTarget(true)) { return; } } } AI.Plan.WaitForClearPath waitForClearPath2 = AIStateManager.StatePool.Allocate <AI.Plan.WaitForClearPath>(); waitForClearPath2.Blocker = blocker; waitForClearPath2.BlockerDistance = blockerDistance; mover.AIController.StateManager.PushState(waitForClearPath2, false); if (obstacles != null && obstacles.Count > 0) { waitForClearPath2.Obstacles.AddRange(obstacles); } } } }
private void PushPathBlockedStateNew(List <Mover> obstacles, bool forceBlock) { if (this.AIController != null && !Cutscene.CutsceneActive) { if (!forceBlock && !this.AIController.StateManager.CurrentState.AllowBlockedMovement()) { return; } this.SaveBlockedRoute(); this.m_desiredHeading = GameUtilities.V3Subtract2D(this.m_nextCornerPos, base.transform.position); this.m_desiredHeading.Normalize(); this.m_heading = this.m_desiredHeading; if (this.AIController is PartyMemberAI) { if (this.AIController.StateManager.CurrentState is AI.Player.WaitForClearPath) { return; } AI.Player.WaitForClearPath waitForClearPath = AIStateManager.StatePool.Allocate <AI.Player.WaitForClearPath>(); waitForClearPath.Obstacles.AddRange(obstacles); waitForClearPath.BlockerDistance = 0.5f; this.AIController.StateManager.PushState(waitForClearPath, false); } else { if (this.AIController.StateManager.CurrentState is AI.Plan.WaitForClearPath) { return; } if (IEModOptions.ImprovedAI) // added this if statement { // race condition if both Mover and PathFindingManager decide they are blocked in the same tick if (this.AIController.StateManager.CurrentState is AI.Plan.ApproachTarget) { return; } var pathToPosition = this.AIController.StateManager.CurrentState as AI.Achievement.PathToPosition; if (pathToPosition != null) { if (((Mod_AI_PathToPosition)pathToPosition).TryToPickNewTarget(true)) { return; } } } AI.Plan.WaitForClearPath waitForClearPath2 = AIStateManager.StatePool.Allocate <AI.Plan.WaitForClearPath>(); waitForClearPath2.Obstacles.AddRange(obstacles); waitForClearPath2.BlockerDistance = 0.5f; this.AIController.StateManager.PushState(waitForClearPath2, false); } } }