Pathfinding fixes:
- determining if a character is close enough to a waypoint works now, even if the character is too short for its collider to overlap with the wp (e.g. crawlers) - enemies can drop down from platforms - an extra waypoint is placed at the middle of stairs to prevent characters from choosing a waypoint on a platform above the stairs as the starting point of their path
This commit is contained in:
@@ -110,7 +110,21 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
UpdateDistanceAccumulator();
|
UpdateDistanceAccumulator();
|
||||||
|
|
||||||
Character.AnimController.IgnorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
bool ignorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||||
|
|
||||||
|
if (steeringManager is IndoorsSteeringManager)
|
||||||
|
{
|
||||||
|
var currPath = ((IndoorsSteeringManager)steeringManager).CurrentPath;
|
||||||
|
if (currPath != null && currPath.CurrentNode != null)
|
||||||
|
{
|
||||||
|
if (currPath.CurrentNode.SimPosition.Y < Character.AnimController.GetColliderBottom().Y)
|
||||||
|
{
|
||||||
|
ignorePlatforms = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Character.AnimController.IgnorePlatforms = ignorePlatforms;
|
||||||
|
|
||||||
if (Character.AnimController is HumanoidAnimController)
|
if (Character.AnimController is HumanoidAnimController)
|
||||||
{
|
{
|
||||||
@@ -501,13 +515,42 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY*20.0f, Color.Red);
|
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY*20.0f, Color.Red);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedAiTarget != null)
|
||||||
|
{
|
||||||
|
GUI.DrawLine(spriteBatch,
|
||||||
|
new Vector2(Character.DrawPosition.X, -Character.DrawPosition.Y),
|
||||||
|
new Vector2(selectedAiTarget.WorldPosition.X, -selectedAiTarget.WorldPosition.Y), Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red);
|
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red);
|
||||||
|
|
||||||
spriteBatch.DrawString(GUI.Font, "updatetargets: "+updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red);
|
spriteBatch.DrawString(GUI.Font, "updatetargets: "+updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red);
|
||||||
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
||||||
|
|
||||||
|
|
||||||
|
IndoorsSteeringManager pathSteering = steeringManager as IndoorsSteeringManager;
|
||||||
|
if (pathSteering == null || pathSteering.CurrentPath == null || pathSteering.CurrentPath.CurrentNode == null) return;
|
||||||
|
|
||||||
|
GUI.DrawLine(spriteBatch,
|
||||||
|
new Vector2(Character.DrawPosition.X, -Character.DrawPosition.Y),
|
||||||
|
new Vector2(pathSteering.CurrentPath.CurrentNode.DrawPosition.X, -pathSteering.CurrentPath.CurrentNode.DrawPosition.Y),
|
||||||
|
Color.LightGreen);
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 1; i < pathSteering.CurrentPath.Nodes.Count; i++)
|
||||||
|
{
|
||||||
|
GUI.DrawLine(spriteBatch,
|
||||||
|
new Vector2(pathSteering.CurrentPath.Nodes[i].DrawPosition.X, -pathSteering.CurrentPath.Nodes[i].DrawPosition.Y),
|
||||||
|
new Vector2(pathSteering.CurrentPath.Nodes[i - 1].DrawPosition.X, -pathSteering.CurrentPath.Nodes[i - 1].DrawPosition.Y),
|
||||||
|
Color.LightGreen);
|
||||||
|
|
||||||
|
spriteBatch.DrawString(GUI.SmallFont,
|
||||||
|
pathSteering.CurrentPath.Nodes[i].ID.ToString(),
|
||||||
|
new Vector2(pathSteering.CurrentPath.Nodes[i].DrawPosition.X, -pathSteering.CurrentPath.Nodes[i].DrawPosition.Y - 10),
|
||||||
|
Color.LightGreen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FillNetworkData(NetBuffer message)
|
public override void FillNetworkData(NetBuffer message)
|
||||||
|
|||||||
@@ -146,9 +146,11 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
var collider = character.AnimController.Collider;
|
var collider = character.AnimController.Collider;
|
||||||
|
Vector2 colliderBottom = character.AnimController.GetColliderBottom();
|
||||||
|
|
||||||
if (Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X) < collider.radius * 2 &&
|
if (Math.Abs(collider.SimPosition.X - currentPath.CurrentNode.SimPosition.X) < collider.radius * 2 &&
|
||||||
Math.Abs(collider.SimPosition.Y - currentPath.CurrentNode.SimPosition.Y) < collider.height / 2 + collider.radius)
|
currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y &&
|
||||||
|
currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + 1.5f)
|
||||||
{
|
{
|
||||||
currentPath.SkipToNextNode();
|
currentPath.SkipToNextNode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,9 +225,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
movement = MathUtils.SmoothStep(movement, TargetMovement * walkSpeed, 0.2f);
|
movement = MathUtils.SmoothStep(movement, TargetMovement * walkSpeed, 0.2f);
|
||||||
if (movement == Vector2.Zero) return;
|
if (movement == Vector2.Zero) return;
|
||||||
|
|
||||||
IgnorePlatforms = (TargetMovement.Y < -Math.Abs(TargetMovement.X));
|
|
||||||
|
|
||||||
float mainLimbHeight, mainLimbAngle;
|
float mainLimbHeight, mainLimbAngle;
|
||||||
if (MainLimb.type == LimbType.Torso)
|
if (MainLimb.type == LimbType.Torso)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (Structure stairs in stairList)
|
foreach (Structure stairs in stairList)
|
||||||
{
|
{
|
||||||
WayPoint[] stairPoints = new WayPoint[2];
|
WayPoint[] stairPoints = new WayPoint[3];
|
||||||
|
|
||||||
stairPoints[0] = new WayPoint(
|
stairPoints[0] = new WayPoint(
|
||||||
new Vector2(stairs.Rect.X - 32.0f,
|
new Vector2(stairs.Rect.X - 32.0f,
|
||||||
@@ -463,8 +463,10 @@ namespace Barotrauma
|
|||||||
stairPoints[i].ConnectTo(closest);
|
stairPoints[i].ConnectTo(closest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stairPoints[0].ConnectTo(stairPoints[1]);
|
stairPoints[2] = new WayPoint((stairPoints[0].Position + stairPoints[1].Position)/2, SpawnType.Path, submarine);
|
||||||
|
stairPoints[0].ConnectTo(stairPoints[2]);
|
||||||
|
stairPoints[2].ConnectTo(stairPoints[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Item item in Item.ItemList)
|
foreach (Item item in Item.ItemList)
|
||||||
|
|||||||
Reference in New Issue
Block a user