Merge branch 'multisub'
Conflicts: .gitignore Subsurface/Source/Characters/Animation/HumanoidAnimController.cs Subsurface/Source/Items/Components/Holdable/RepairTool.cs Subsurface_Solution.v12.suo
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,13 @@ namespace Barotrauma
|
||||
|
||||
currentTarget = target;
|
||||
Vector2 pos = host.SimPosition;
|
||||
if (character!=null && character.Submarine==null)
|
||||
if (character != null && character.Submarine == null)
|
||||
{
|
||||
pos -= Submarine.Loaded.SimPosition;
|
||||
var targetHull = Hull.FindHull(FarseerPhysics.ConvertUnits.ToDisplayUnits(target), null, false);
|
||||
if (targetHull!=null && targetHull.Submarine != null)
|
||||
{
|
||||
pos -= targetHull.SimPosition;
|
||||
}
|
||||
}
|
||||
|
||||
currentPath = pathFinder.FindPath(pos, target);
|
||||
@@ -99,15 +103,15 @@ namespace Barotrauma
|
||||
|
||||
private Vector2 DiffToCurrentNode()
|
||||
{
|
||||
if (currentPath == null) return Vector2.Zero;
|
||||
if (currentPath == null || currentPath.Finished) return Vector2.Zero;
|
||||
|
||||
if (currentPath.CurrentIndex == currentPath.Nodes.Count)
|
||||
if (currentPath.Finished)
|
||||
{
|
||||
|
||||
Vector2 pos2 = host.SimPosition;
|
||||
if (character != null && character.Submarine == null)
|
||||
if (character != null && character.Submarine == null && CurrentPath.Nodes.Last().Submarine != null)
|
||||
{
|
||||
pos2 -= Submarine.Loaded.SimPosition;
|
||||
//todo: take multiple subs into account
|
||||
pos2 -= CurrentPath.Nodes.Last().Submarine.SimPosition;
|
||||
}
|
||||
return currentTarget-pos2;
|
||||
}
|
||||
@@ -118,9 +122,11 @@ namespace Barotrauma
|
||||
if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f;
|
||||
|
||||
Vector2 pos = host.SimPosition;
|
||||
if (character != null && character.Submarine == null)
|
||||
if (character != null && character.Submarine == null &&
|
||||
CurrentPath.CurrentNode != null && CurrentPath.CurrentNode.Submarine != null)
|
||||
{
|
||||
pos -= Submarine.Loaded.SimPosition;
|
||||
//todo: take multiple subs into account
|
||||
pos -= CurrentPath.CurrentNode.Submarine.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;
|
||||
|
||||
@@ -70,6 +70,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public bool Finished
|
||||
{
|
||||
get { return currentIndex >= nodes.Count; }
|
||||
}
|
||||
|
||||
public void SkipToNextNode()
|
||||
{
|
||||
currentIndex++;
|
||||
|
||||
@@ -734,6 +734,10 @@ namespace Barotrauma
|
||||
{
|
||||
ladderSimPos += character.SelectedConstruction.Submarine.SimPosition;
|
||||
}
|
||||
else if (currentHull.Submarine != null && currentHull.Submarine != character.SelectedConstruction.Submarine)
|
||||
{
|
||||
ladderSimPos += character.SelectedConstruction.Submarine.SimPosition - currentHull.Submarine.SimPosition;
|
||||
}
|
||||
|
||||
MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, head.SimPosition.Y + 0.05f), 10.5f);
|
||||
MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, torso.SimPosition.Y), 10.5f);
|
||||
@@ -742,7 +746,9 @@ namespace Barotrauma
|
||||
|
||||
Vector2 handPos = new Vector2(
|
||||
ladderSimPos.X,
|
||||
head.SimPosition.Y + 0.0f + movement.Y * 0.1f - ladderSimPos.Y);
|
||||
head.SimPosition.Y + movement.Y * 0.1f - ladderSimPos.Y);
|
||||
|
||||
handPos.Y = Math.Min(-0.5f, handPos.Y);
|
||||
|
||||
MoveLimb(leftHand,
|
||||
new Vector2(handPos.X,
|
||||
|
||||
@@ -572,6 +572,7 @@ namespace Barotrauma
|
||||
|
||||
if (setSubmarine)
|
||||
{
|
||||
//in -> out
|
||||
if (newHull == null && currentHull.Submarine != null)
|
||||
{
|
||||
for (int i = -1; i < 2; i += 2)
|
||||
@@ -584,17 +585,23 @@ namespace Barotrauma
|
||||
if (Gap.FindAdjacent(currentHull.ConnectedGaps, findPos, 150.0f) != null) return;
|
||||
|
||||
Teleport(ConvertUnits.ToSimUnits(currentHull.Submarine.Position), currentHull.Submarine.Velocity, true);
|
||||
|
||||
}
|
||||
//out -> in
|
||||
else if (currentHull == null && newHull.Submarine != null)
|
||||
{
|
||||
Teleport(-ConvertUnits.ToSimUnits(newHull.Submarine.Position), -newHull.Submarine.Velocity, false);
|
||||
}
|
||||
//from one sub to another
|
||||
else if (newHull != null && currentHull != null && newHull.Submarine != currentHull.Submarine)
|
||||
{
|
||||
Teleport(ConvertUnits.ToSimUnits(currentHull.Submarine.Position - newHull.Submarine.Position),
|
||||
Vector2.Zero, false);
|
||||
}
|
||||
}
|
||||
|
||||
CurrentHull = newHull;
|
||||
|
||||
character.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||
character.Submarine = currentHull == null ? null : currentHull.Submarine;
|
||||
|
||||
UpdateCollisionCategories();
|
||||
}
|
||||
@@ -609,20 +616,7 @@ namespace Barotrauma
|
||||
while (ce != null && ce.Contact != null)
|
||||
{
|
||||
ce.Contact.Enabled = false;
|
||||
//if (ce.Contact.IsTouching && ce.Contact.Enabled &&
|
||||
// ((inToOut && ce.Contact.FixtureA.Body.UserData is Structure) || (!inToOut && ce.Contact.FixtureA.Body.UserData is Submarine)))
|
||||
//{
|
||||
// Vector2 normal;
|
||||
// FarseerPhysics.Common.FixedArray2<Vector2> worldPoints;
|
||||
// ce.Contact.GetWorldManifold(out normal, out worldPoints);
|
||||
|
||||
// foreach (Limb limb2 in Limbs)
|
||||
// {
|
||||
// limb2.body.FarseerBody.ApplyLinearImpulse(limb2.Mass * normal);
|
||||
// }
|
||||
|
||||
// return false;
|
||||
//}
|
||||
ce = ce.Next;
|
||||
}
|
||||
}
|
||||
@@ -632,7 +626,7 @@ namespace Barotrauma
|
||||
limb.body.LinearVelocity += velocityChange;
|
||||
}
|
||||
|
||||
character.Stun = 0.1f;
|
||||
//character.Stun = 0.1f;
|
||||
character.DisableImpactDamageTimer = 0.25f;
|
||||
|
||||
SetPosition(refLimb.SimPosition + moveAmount);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (LightSource != null)
|
||||
{
|
||||
LightSource.Submarine = body.Submarine;
|
||||
LightSource.ParentSub = body.Submarine;
|
||||
LightSource.Position = Position;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user