Started refactoring the submarine class in order to make it possible to add multiple submarines (or other movable structures)
This commit is contained in:
@@ -164,15 +164,15 @@ namespace Barotrauma
|
||||
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(Character.WorldPosition.X, -Character.WorldPosition.Y),
|
||||
new Vector2(pathSteering.CurrentPath.CurrentNode.Position.X+Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.CurrentNode.Position.Y+Submarine.Loaded.Position.Y)),
|
||||
new Vector2(pathSteering.CurrentPath.CurrentNode.WorldPosition.X, -pathSteering.CurrentPath.CurrentNode.WorldPosition.Y),
|
||||
Color.LightGreen);
|
||||
|
||||
|
||||
for (int i = 1; i < pathSteering.CurrentPath.Nodes.Count; i++)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(pathSteering.CurrentPath.Nodes[i].Position.X + Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.Nodes[i].Position.Y + Submarine.Loaded.Position.Y)),
|
||||
new Vector2(pathSteering.CurrentPath.Nodes[i - 1].Position.X + Submarine.Loaded.Position.X, -(pathSteering.CurrentPath.Nodes[i-1].Position.Y + Submarine.Loaded.Position.Y)),
|
||||
new Vector2(pathSteering.CurrentPath.Nodes[i].WorldPosition.X, -pathSteering.CurrentPath.Nodes[i].WorldPosition.Y),
|
||||
new Vector2(pathSteering.CurrentPath.Nodes[i - 1].WorldPosition.Y, -pathSteering.CurrentPath.Nodes[i-1].WorldPosition.Y),
|
||||
Color.LightGreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Barotrauma
|
||||
Vector2 pos = host.SimPosition;
|
||||
if (character!=null && character.Submarine==null)
|
||||
{
|
||||
pos -= Submarine.Loaded.SimPosition;
|
||||
pos -= Submarine.MainSub.SimPosition;
|
||||
}
|
||||
|
||||
currentPath = pathFinder.FindPath(pos, target);
|
||||
@@ -107,7 +107,7 @@ namespace Barotrauma
|
||||
Vector2 pos2 = host.SimPosition;
|
||||
if (character != null && character.Submarine == null)
|
||||
{
|
||||
pos2 -= Submarine.Loaded.SimPosition;
|
||||
pos2 -= Submarine.MainSub.SimPosition;
|
||||
}
|
||||
return currentTarget-pos2;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace Barotrauma
|
||||
Vector2 pos = host.SimPosition;
|
||||
if (character != null && character.Submarine == null)
|
||||
{
|
||||
pos -= Submarine.Loaded.SimPosition;
|
||||
pos -= Submarine.MainSub.SimPosition;
|
||||
}
|
||||
|
||||
if (currentPath.CurrentNode!= null && currentPath.CurrentNode.Ladders!=null)
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (target.Submarine == null)
|
||||
{
|
||||
currTargetPos -= Submarine.Loaded.SimPosition;
|
||||
currTargetPos -= character.Submarine.SimPosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Barotrauma
|
||||
if (currentTarget != null)
|
||||
{
|
||||
Vector2 pos = character.SimPosition;
|
||||
if (character != null && character.Submarine == null) pos -= Submarine.Loaded.SimPosition;
|
||||
if (character != null && character.Submarine == null) pos -= Submarine.MainSub.SimPosition;
|
||||
|
||||
var path = pathSteering.PathFinder.FindPath(pos, currentTarget.SimPosition);
|
||||
if (path.Cost > 200.0f && character.AnimController.CurrentHull!=null) return;
|
||||
|
||||
@@ -594,7 +594,7 @@ namespace Barotrauma
|
||||
|
||||
CurrentHull = newHull;
|
||||
|
||||
character.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||
character.Submarine = currentHull == null ? null : currentHull.Submarine;
|
||||
|
||||
UpdateCollisionCategories();
|
||||
}
|
||||
|
||||
@@ -855,7 +855,10 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (AnimController.CurrentHull != null) cursorPosition -= Submarine.Loaded.Position;
|
||||
if (AnimController.CurrentHull != null && AnimController.CurrentHull.Submarine != null)
|
||||
{
|
||||
cursorPosition -= AnimController.CurrentHull.Submarine.Position;
|
||||
}
|
||||
|
||||
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
||||
|
||||
@@ -1006,12 +1009,9 @@ namespace Barotrauma
|
||||
if (needsAir)
|
||||
{
|
||||
bool protectedFromPressure = PressureProtection > 0.0f;
|
||||
|
||||
if (Submarine.Loaded != null && Level.Loaded != null)
|
||||
{
|
||||
protectedFromPressure = protectedFromPressure && WorldPosition.Y > SubmarineBody.DamageDepth;
|
||||
}
|
||||
|
||||
protectedFromPressure = protectedFromPressure && WorldPosition.Y > SubmarineBody.DamageDepth;
|
||||
|
||||
if (!protectedFromPressure &&
|
||||
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 80.0f))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user