IndoorsSteering works outside now

This commit is contained in:
Regalis
2016-01-06 22:50:55 +02:00
parent 48eabedb77
commit e102154f5f
6 changed files with 33 additions and 19 deletions

View File

@@ -12,10 +12,7 @@ namespace Barotrauma
const float UpdateObjectiveInterval = 0.5f;
private AIObjectiveManager objectiveManager;
private IndoorsSteeringManager indoorsSteeringManager;
private SteeringManager outdoorsSteeringManager;
private AITarget selectedAiTarget;
private float updateObjectiveTimer;
@@ -34,8 +31,7 @@ namespace Barotrauma
public HumanAIController(Character c) : base(c)
{
indoorsSteeringManager = new IndoorsSteeringManager(this, true);
outdoorsSteeringManager = new SteeringManager(this);
steeringManager = new IndoorsSteeringManager(this, true);
objectiveManager = new AIObjectiveManager(c);
objectiveManager.AddObjective(new AIObjectiveFindSafety(c));
@@ -48,7 +44,7 @@ namespace Barotrauma
{
Character.ClearInputs();
steeringManager = Character.AnimController.CurrentHull == null ? outdoorsSteeringManager : indoorsSteeringManager;
//steeringManager = Character.AnimController.CurrentHull == null ? outdoorsSteeringManager : indoorsSteeringManager;
if (updateObjectiveTimer>0.0f)
{

View File

@@ -21,5 +21,7 @@ namespace Barotrauma
get;
}
}
}

View File

@@ -72,7 +72,13 @@ namespace Barotrauma
if (findPathTimer > 0.0f) return Vector2.Zero;
currentTarget = target;
currentPath = pathFinder.FindPath(host.SimPosition, target);
Vector2 pos = host.SimPosition;
if (character!=null && character.Submarine==null)
{
pos -= Submarine.Loaded.SimPosition;
}
currentPath = pathFinder.FindPath(pos, target);
findPathTimer = Rand.Range(1.0f,1.2f);
@@ -95,7 +101,13 @@ namespace Barotrauma
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f;
currentPath.CheckProgress(host.SimPosition, allowedDistance);
Vector2 pos = host.SimPosition;
if (character != null && character.Submarine == null)
{
pos -= Submarine.Loaded.SimPosition;
}
currentPath.CheckProgress(pos, allowedDistance);
if (currentPath.CurrentNode == null) return Vector2.Zero;
@@ -104,7 +116,7 @@ namespace Barotrauma
// return currentPath.PrevNode.SimPosition - host.SimPosition;
//}
return currentPath.CurrentNode.SimPosition - host.SimPosition;
return currentPath.CurrentNode.SimPosition - pos;
}
private void CheckDoorsInPath()

View File

@@ -76,7 +76,11 @@ namespace Barotrauma
//if character is outside the sub and target isn't, transform the position
if (character.Submarine == null && target.Submarine != null)
{
currTargetPos += target.Submarine.SimPosition;
//currTargetPos += target.Submarine.SimPosition;
}
else if (target.Submarine==null)
{
currTargetPos -= Submarine.Loaded.SimPosition;
}
}

View File

@@ -103,10 +103,10 @@ namespace Barotrauma
Vector2 nodePos = node.Position;
//if node waypoint is one of submarine waypoints outside the sub, transform position
if (node.Waypoint != null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull == null)
{
nodePos -= node.Waypoint.Submarine.Position;
}
//if (node.Waypoint != null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull == null)
//{
// nodePos -= node.Waypoint.Submarine.Position;
//}
float dist = System.Math.Abs(start.X-nodePos.X)+
System.Math.Abs(start.Y - nodePos.Y)*10.0f +
@@ -135,10 +135,10 @@ namespace Barotrauma
Vector2 nodePos = node.Position;
//if node waypoint is one of submarine waypoints outside the sub, transform position
if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null)
{
nodePos -= node.Waypoint.Submarine.Position;
}
//if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null)
//{
// nodePos -= node.Waypoint.Submarine.Position;
//}
float dist = Vector2.Distance(end, nodePos);
if (dist < closestDist || endNode == null)

Binary file not shown.