v1.0.13.1 (first post-1.0 patch)

This commit is contained in:
Regalis11
2023-05-10 15:07:17 +03:00
parent 96fb49ba14
commit ee1db852b1
272 changed files with 5738 additions and 2413 deletions
@@ -9,7 +9,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
partial class Gap : MapEntity
partial class Gap : MapEntity, ISerializableEntity
{
public static List<Gap> GapList = new List<Gap>();
@@ -57,6 +57,8 @@ namespace Barotrauma
private Body outsideCollisionBlocker;
private float outsideColliderRaycastTimer;
private bool wasRoomToRoom;
public float Open
{
get { return open; }
@@ -153,12 +155,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)
@@ -185,6 +187,8 @@ namespace Barotrauma
IsDiagonal = isDiagonal;
open = 1.0f;
properties = SerializableProperty.GetProperties(this);
FindHulls();
GapList.Add(this);
InsertToList();
@@ -199,7 +203,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 + ")");
}
@@ -332,9 +339,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;
@@ -628,11 +640,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;
@@ -641,7 +658,7 @@ namespace Barotrauma
return outsideCollisionBlocker.Enabled;
}
private void UpdateOutsideColliderPos(Hull hull)
private void UpdateOutsideColliderState(Hull hull)
{
if (Submarine == null || IsRoomToRoom || Level.Loaded == null) { return; }
@@ -678,7 +695,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
@@ -775,8 +792,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);