Autopilot uses submarine position as a "reference position" (instead of the position of the nav terminal), radar display bugfix, ragdolls aren't teleported outside the sub if they're in a tiny gap between hulls (e.g. passing through a broken wall between rooms)

This commit is contained in:
Regalis
2016-04-20 17:28:20 +03:00
parent 188220c464
commit e271873a43
4 changed files with 64 additions and 48 deletions
+11
View File
@@ -117,6 +117,7 @@
<Compile Include="Source\Items\Components\Holdable\MeleeWeapon.cs" /> <Compile Include="Source\Items\Components\Holdable\MeleeWeapon.cs" />
<Compile Include="Source\Items\Components\Holdable\Propulsion.cs" /> <Compile Include="Source\Items\Components\Holdable\Propulsion.cs" />
<Compile Include="Source\Items\Components\Machines\Deconstructor.cs" /> <Compile Include="Source\Items\Components\Machines\Deconstructor.cs" />
<Compile Include="Source\Items\Components\Radio.cs" />
<Compile Include="Source\Items\Components\Signal\DelayComponent.cs" /> <Compile Include="Source\Items\Components\Signal\DelayComponent.cs" />
<Compile Include="Source\Items\Components\Signal\RelayComponent.cs" /> <Compile Include="Source\Items\Components\Signal\RelayComponent.cs" />
<Compile Include="Source\Items\Components\Signal\WaterDetector.cs" /> <Compile Include="Source\Items\Components\Signal\WaterDetector.cs" />
@@ -136,6 +137,7 @@
<Compile Include="Source\Map\SubmarineBody.cs" /> <Compile Include="Source\Map\SubmarineBody.cs" />
<Compile Include="Source\Map\TransitionCinematic.cs" /> <Compile Include="Source\Map\TransitionCinematic.cs" />
<Compile Include="Source\Networking\BanList.cs" /> <Compile Include="Source\Networking\BanList.cs" />
<Compile Include="Source\Networking\ChatMessage.cs" />
<Compile Include="Source\Networking\FileStreamReceiver.cs" /> <Compile Include="Source\Networking\FileStreamReceiver.cs" />
<Compile Include="Source\Networking\FileStreamSender.cs" /> <Compile Include="Source\Networking\FileStreamSender.cs" />
<Compile Include="Source\Networking\NetBufferExtensions.cs" /> <Compile Include="Source\Networking\NetBufferExtensions.cs" />
@@ -461,6 +463,9 @@
<Content Include="Content\Items\Jobgear\engigear.xml"> <Content Include="Content\Items\Jobgear\engigear.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Items\Jobgear\headset.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Jobgear\securitygear.xml"> <Content Include="Content\Items\Jobgear\securitygear.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -1180,6 +1185,12 @@
<None Include="Content\Sounds\UI\beep-shinymetal.ogg"> <None Include="Content\Sounds\UI\beep-shinymetal.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Content\Sounds\UI\deadmsg.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\UI\radiomsg.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\UI\tap-zipper.ogg"> <None Include="Content\Sounds\UI\tap-zipper.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
@@ -560,6 +560,15 @@ namespace Barotrauma
{ {
if (newHull == null && currentHull.Submarine != null) if (newHull == null && currentHull.Submarine != null)
{ {
//if there's a hull right above and below the position, don't teleport outside the sub
//(the character is most likely inside some small gap between hulls)
if (Hull.FindHull(findPos + Vector2.UnitY * Submarine.GridSize.Y * 2.0f, currentHull) != null &&
Hull.FindHull(findPos - Vector2.UnitY * Submarine.GridSize.Y * 2.0f, currentHull) != null) return;
if (Hull.FindHull(findPos + Vector2.UnitX * Submarine.GridSize.X * 2.0f, currentHull) != null &&
Hull.FindHull(findPos - Vector2.UnitX * Submarine.GridSize.X * 2.0f, currentHull) != null) return;
Vector2 ragdollSpeed = refLimb.LinearVelocity == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(refLimb.LinearVelocity); Vector2 ragdollSpeed = refLimb.LinearVelocity == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(refLimb.LinearVelocity);
SetPosition(refLimb.SimPosition + ragdollSpeed + ConvertUnits.ToSimUnits(currentHull.Submarine.Position)); SetPosition(refLimb.SimPosition + ragdollSpeed + ConvertUnits.ToSimUnits(currentHull.Submarine.Position));
character.CursorPosition += currentHull.Submarine.Position; character.CursorPosition += currentHull.Submarine.Position;
@@ -147,7 +147,7 @@ namespace Barotrauma.Items.Components
} }
else else
{ {
float simScale = ConvertUnits.ToSimUnits(displayScale); float simScale = displayScale * Physics.DisplayToSimRation;
Vector2 offset = ConvertUnits.ToSimUnits(Submarine.Loaded.WorldPosition - item.WorldPosition); Vector2 offset = ConvertUnits.ToSimUnits(Submarine.Loaded.WorldPosition - item.WorldPosition);
@@ -158,8 +158,7 @@ namespace Barotrauma.Items.Components
Vector2 end = (Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] + offset) * simScale; Vector2 end = (Submarine.Loaded.HullVertices[(i + 1) % Submarine.Loaded.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y; end.Y = -end.Y;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green); GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
} }
} }
@@ -208,52 +208,49 @@ namespace Barotrauma.Items.Components
private void UpdateAutoPilot(float deltaTime) private void UpdateAutoPilot(float deltaTime)
{ {
if (posToMaintain==null) if (posToMaintain != null)
{
autopilotRayCastTimer -= deltaTime;
steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f);
if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null)
{
Vector2 diff = Vector2.Normalize(ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.WorldPosition));
bool nextVisible = true;
for (int x = -1; x < 2; x += 2)
{
for (int y = -1; y < 2; y += 2)
{
Vector2 cornerPos =
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.WorldPosition);
float dist = Vector2.Distance(cornerPos, steeringPath.NextNode.SimPosition);
if (Submarine.PickBody(cornerPos, cornerPos + diff*dist, null, Physics.CollisionLevel) == null) continue;
nextVisible = false;
x = 2;
y = 2;
}
}
if (nextVisible) steeringPath.SkipToNextNode();
autopilotRayCastTimer = AutopilotRayCastInterval;
}
if (steeringPath.CurrentNode != null)
{
SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition);
}
}
else
{ {
SteerTowardsPosition((Vector2)posToMaintain); SteerTowardsPosition((Vector2)posToMaintain);
return;
} }
autopilotRayCastTimer -= deltaTime;
steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.Submarine.WorldPosition), 10.0f);
if (autopilotRayCastTimer <= 0.0f && steeringPath.NextNode != null)
{
Vector2 diff = Vector2.Normalize(ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.WorldPosition));
bool nextVisible = true;
for (int x = -1; x < 2; x += 2)
{
for (int y = -1; y < 2; y += 2)
{
Vector2 cornerPos =
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.WorldPosition);
float dist = Vector2.Distance(cornerPos, steeringPath.NextNode.SimPosition);
if (Submarine.PickBody(cornerPos, cornerPos + diff*dist, null, Physics.CollisionLevel) == null) continue;
nextVisible = false;
x = 2;
y = 2;
}
}
if (nextVisible) steeringPath.SkipToNextNode();
autopilotRayCastTimer = AutopilotRayCastInterval;
}
if (steeringPath.CurrentNode != null)
{
SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition);
}
} }
private void SteerTowardsPosition(Vector2 worldPosition) private void SteerTowardsPosition(Vector2 worldPosition)
@@ -261,7 +258,7 @@ namespace Barotrauma.Items.Components
float prediction = 10.0f; float prediction = 10.0f;
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction; Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction;
Vector2 targetSpeed = ((worldPosition - item.WorldPosition) - futurePosition); Vector2 targetSpeed = ((worldPosition - item.Submarine.WorldPosition) - futurePosition);
if (targetSpeed.Length()>500.0f) if (targetSpeed.Length()>500.0f)
{ {
@@ -282,13 +279,13 @@ namespace Barotrauma.Items.Components
if (tickBox.Selected) if (tickBox.Selected)
{ {
if (Submarine.Loaded == null) if (item.Submarine == null)
{ {
posToMaintain = null; posToMaintain = null;
} }
else else
{ {
posToMaintain = item.WorldPosition; posToMaintain = item.Submarine.WorldPosition;
} }
} }
else else