Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -10,7 +10,7 @@ using MoonSharp.Interpreter;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class Gap : MapEntity
|
||||
partial class Gap : MapEntity, ISerializableEntity
|
||||
{
|
||||
public static List<Gap> GapList = new List<Gap>();
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace Barotrauma
|
||||
private Body outsideCollisionBlocker;
|
||||
private float outsideColliderRaycastTimer;
|
||||
|
||||
private bool wasRoomToRoom;
|
||||
|
||||
public float Open
|
||||
{
|
||||
get { return open; }
|
||||
@@ -154,12 +156,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
public override string Name => "Gap";
|
||||
|
||||
public readonly Dictionary<Identifier, SerializableProperty> properties;
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Gap";
|
||||
}
|
||||
get { return properties; }
|
||||
}
|
||||
|
||||
public Gap(Rectangle rectangle)
|
||||
@@ -186,6 +188,8 @@ namespace Barotrauma
|
||||
IsDiagonal = isDiagonal;
|
||||
open = 1.0f;
|
||||
|
||||
properties = SerializableProperty.GetProperties(this);
|
||||
|
||||
FindHulls();
|
||||
GapList.Add(this);
|
||||
InsertToList();
|
||||
@@ -200,7 +204,10 @@ namespace Barotrauma
|
||||
outsideCollisionBlocker.Enabled = false;
|
||||
#if CLIENT
|
||||
Resized += newRect => IsHorizontal = newRect.Width < newRect.Height;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
wasRoomToRoom = IsRoomToRoom;
|
||||
RefreshOutsideCollider();
|
||||
DebugConsole.Log("Created gap (" + ID + ")");
|
||||
}
|
||||
|
||||
@@ -333,9 +340,14 @@ namespace Barotrauma
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
flowForce = Vector2.Zero;
|
||||
|
||||
outsideColliderRaycastTimer -= deltaTime;
|
||||
|
||||
if (IsRoomToRoom != wasRoomToRoom)
|
||||
{
|
||||
RefreshOutsideCollider();
|
||||
wasRoomToRoom = IsRoomToRoom;
|
||||
}
|
||||
|
||||
if (open == 0.0f || linkedTo.Count == 0)
|
||||
{
|
||||
lerpedFlowForce = Vector2.Zero;
|
||||
@@ -629,11 +641,16 @@ namespace Barotrauma
|
||||
|
||||
public bool RefreshOutsideCollider()
|
||||
{
|
||||
if (IsRoomToRoom || Submarine == null || open <= 0.0f || linkedTo.Count == 0 || !(linkedTo[0] is Hull)) return false;
|
||||
if (outsideCollisionBlocker == null) { return false; }
|
||||
if (IsRoomToRoom || Submarine == null || open <= 0.0f || linkedTo.Count == 0 || linkedTo[0] is not Hull)
|
||||
{
|
||||
outsideCollisionBlocker.Enabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (outsideColliderRaycastTimer <= 0.0f)
|
||||
{
|
||||
UpdateOutsideColliderPos((Hull)linkedTo[0]);
|
||||
UpdateOutsideColliderState((Hull)linkedTo[0]);
|
||||
outsideColliderRaycastTimer = outsideCollisionBlocker.Enabled ?
|
||||
OutsideColliderRaycastIntervalHighPrio :
|
||||
OutsideColliderRaycastIntervalLowPrio;
|
||||
@@ -642,7 +659,7 @@ namespace Barotrauma
|
||||
return outsideCollisionBlocker.Enabled;
|
||||
}
|
||||
|
||||
private void UpdateOutsideColliderPos(Hull hull)
|
||||
private void UpdateOutsideColliderState(Hull hull)
|
||||
{
|
||||
if (Submarine == null || IsRoomToRoom || Level.Loaded == null) { return; }
|
||||
|
||||
@@ -679,7 +696,7 @@ namespace Barotrauma
|
||||
if (blockingBody.UserData == Submarine) { return; }
|
||||
outsideCollisionBlocker.Enabled = true;
|
||||
Vector2 colliderPos = Submarine.LastPickedPosition - Submarine.SimPosition;
|
||||
float colliderRotation = MathUtils.VectorToAngle(rayDir) - MathHelper.PiOver2;
|
||||
float colliderRotation = MathUtils.VectorToAngle(Submarine.LastPickedNormal) - MathHelper.PiOver2;
|
||||
outsideCollisionBlocker.SetTransformIgnoreContacts(ref colliderPos, colliderRotation);
|
||||
}
|
||||
else
|
||||
@@ -780,8 +797,7 @@ namespace Barotrauma
|
||||
|
||||
public static Gap Load(ContentXElement element, Submarine submarine, IdRemap idRemap)
|
||||
{
|
||||
Rectangle rect = Rectangle.Empty;
|
||||
|
||||
Rectangle rect;
|
||||
if (element.GetAttribute("rect") != null)
|
||||
{
|
||||
rect = element.GetAttributeRect("rect", Rectangle.Empty);
|
||||
|
||||
Reference in New Issue
Block a user