(b0feecc1f) Use the code that includes wall avoidance for wandering also in AIObjectiveFindSafety and AIObjectiveGetItem when the target is unreachable.
This commit is contained in:
+2
-1
@@ -115,7 +115,8 @@ namespace Barotrauma
|
|||||||
unreachable.Add(goToObjective.Target as Hull);
|
unreachable.Add(goToObjective.Target as Hull);
|
||||||
}
|
}
|
||||||
goToObjective = null;
|
goToObjective = null;
|
||||||
SteeringManager.SteeringWander();
|
HumanAIController.ObjectiveManager.GetObjective<AIObjectiveIdle>().Wander(deltaTime);
|
||||||
|
//SteeringManager.SteeringWander();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (currentHull != null)
|
else if (currentHull != null)
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ namespace Barotrauma
|
|||||||
FindTargetItem();
|
FindTargetItem();
|
||||||
if (targetItem == null || moveToTarget == null)
|
if (targetItem == null || moveToTarget == null)
|
||||||
{
|
{
|
||||||
SteeringManager.SteeringWander();
|
HumanAIController.ObjectiveManager.GetObjective<AIObjectiveIdle>().Wander(deltaTime);
|
||||||
|
//SteeringManager.SteeringWander();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,18 +98,28 @@ namespace Barotrauma
|
|||||||
PathSteering.Reset();
|
PathSteering.Reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (standStillTimer < -walkDuration)
|
if (standStillTimer < -walkDuration)
|
||||||
{
|
{
|
||||||
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Wander(deltaTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentTarget != null)
|
||||||
|
{
|
||||||
|
character.AIController.SteeringManager.SteeringSeek(currentTarget.SimPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Wander(float deltaTime)
|
||||||
|
{
|
||||||
//steer away from edges of the hull
|
//steer away from edges of the hull
|
||||||
if (character.AnimController.CurrentHull != null && !character.IsClimbing)
|
if (character.AnimController.CurrentHull != null && !character.IsClimbing)
|
||||||
{
|
{
|
||||||
float leftDist = character.Position.X - character.AnimController.CurrentHull.Rect.X;
|
float leftDist = character.Position.X - character.AnimController.CurrentHull.Rect.X;
|
||||||
float rightDist = character.AnimController.CurrentHull.Rect.Right - character.Position.X;
|
float rightDist = character.AnimController.CurrentHull.Rect.Right - character.Position.X;
|
||||||
|
|
||||||
if (leftDist < WallAvoidDistance && rightDist < WallAvoidDistance)
|
if (leftDist < WallAvoidDistance && rightDist < WallAvoidDistance)
|
||||||
{
|
{
|
||||||
if (Math.Abs(rightDist - leftDist) > WallAvoidDistance / 2)
|
if (Math.Abs(rightDist - leftDist) > WallAvoidDistance / 2)
|
||||||
@@ -119,36 +129,25 @@ namespace Barotrauma
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PathSteering.Reset();
|
PathSteering.Reset();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (leftDist < WallAvoidDistance)
|
else if (leftDist < WallAvoidDistance)
|
||||||
{
|
{
|
||||||
PathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance-leftDist) / WallAvoidDistance);
|
PathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance - leftDist) / WallAvoidDistance);
|
||||||
PathSteering.WanderAngle = 0.0f;
|
PathSteering.WanderAngle = 0.0f;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (rightDist < WallAvoidDistance)
|
else if (rightDist < WallAvoidDistance)
|
||||||
{
|
{
|
||||||
PathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance-rightDist) / WallAvoidDistance);
|
PathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance - rightDist) / WallAvoidDistance);
|
||||||
PathSteering.WanderAngle = MathHelper.Pi;
|
PathSteering.WanderAngle = MathHelper.Pi;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SteeringManager.SteeringWander();
|
||||||
character.AIController.SteeringManager.SteeringWander();
|
|
||||||
if (!character.IsClimbing && !character.AnimController.InWater)
|
if (!character.IsClimbing && !character.AnimController.InWater)
|
||||||
{
|
{
|
||||||
//reset vertical steering to prevent dropping down from platforms etc
|
//reset vertical steering to prevent dropping down from platforms etc
|
||||||
character.AIController.SteeringManager.ResetY();
|
character.AIController.SteeringManager.ResetY();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentTarget != null)
|
|
||||||
{
|
|
||||||
character.AIController.SteeringManager.SteeringSeek(currentTarget.SimPosition);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<Hull> targetHulls = new List<Hull>(20);
|
private readonly List<Hull> targetHulls = new List<Hull>(20);
|
||||||
|
|||||||
Reference in New Issue
Block a user