Submarine saving fixes, impact damage in sub-sub collisions, submarine ambient sounds
This commit is contained in:
@@ -526,7 +526,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
if (e.MoveWithLevel) continue;
|
||||
if (e.MoveWithLevel ||e.Submarine != this) continue;
|
||||
e.Save(doc);
|
||||
}
|
||||
|
||||
@@ -548,17 +548,15 @@ namespace Barotrauma
|
||||
|
||||
public static bool SaveCurrent(string filePath)
|
||||
{
|
||||
if (!loaded.Any())
|
||||
if (Submarine.MainSub == null)
|
||||
{
|
||||
loaded.Add(new Submarine(filePath));
|
||||
Submarine.MainSub = new Submarine(filePath);
|
||||
// return;
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.Assert(loaded.Count==1);
|
||||
Submarine.MainSub.filePath = filePath;
|
||||
|
||||
loaded.First().filePath = filePath;
|
||||
|
||||
return loaded.First().SaveAs(filePath);
|
||||
return Submarine.MainSub.SaveAs(filePath);
|
||||
}
|
||||
|
||||
public void CheckForErrors()
|
||||
|
||||
@@ -415,12 +415,9 @@ namespace Barotrauma
|
||||
|
||||
public bool OnCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
VoronoiCell cell = f2.Body.UserData as VoronoiCell;
|
||||
|
||||
if (cell == null)
|
||||
Limb limb = f2.Body.UserData as Limb;
|
||||
if (limb!= null)
|
||||
{
|
||||
Limb limb = f2.Body.UserData as Limb;
|
||||
if (limb == null) return true;
|
||||
|
||||
bool collision = HandleLimbCollision(contact, limb);
|
||||
|
||||
@@ -436,12 +433,32 @@ namespace Barotrauma
|
||||
return collision;
|
||||
}
|
||||
|
||||
var collisionNormal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
|
||||
VoronoiCell cell = f2.Body.UserData as VoronoiCell;
|
||||
if (cell != null)
|
||||
{
|
||||
var collisionNormal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
|
||||
|
||||
float wallImpact = Vector2.Dot(Velocity, -collisionNormal);
|
||||
float wallImpact = Vector2.Dot(Velocity, -collisionNormal);
|
||||
|
||||
ApplyImpact(wallImpact, -collisionNormal, contact);
|
||||
ApplyImpact(wallImpact, -collisionNormal, contact);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Submarine sub = f2.Body.UserData as Submarine;
|
||||
if (sub != null)
|
||||
{
|
||||
Debug.Assert(sub != submarine);
|
||||
|
||||
Vector2 normal;
|
||||
FixedArray2<Vector2> points;
|
||||
contact.GetWorldManifold(out normal, out points);
|
||||
|
||||
ApplyImpact(Vector2.Dot(Velocity - sub.Velocity, normal) / 2.0f, normal, contact);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user