(1762f02b3) Merge branch 'dev' into human-ai

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:08:22 +03:00
parent 4797f6b0d3
commit 454dda56c7
91 changed files with 1138 additions and 744 deletions
@@ -24,8 +24,6 @@ namespace Barotrauma
private bool removed;
private bool removed;
#if CLIENT
private List<Decal> burnDecals = new List<Decal>();
#endif
+19 -10
View File
@@ -299,6 +299,25 @@ namespace Barotrauma
}
}
public string DisplayName
{
get;
private set;
}
private string roomName;
[Editable, Serialize("", true, translationTextTag: "RoomName.")]
public string RoomName
{
get { return roomName; }
set
{
if (roomName == value) { return; }
roomName = value;
DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName;
}
}
public override Rectangle Rect
{
get
@@ -633,11 +652,6 @@ namespace Barotrauma
public void AddFireSource(FireSource fireSource)
{
FireSources.Add(fireSource);
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer && !IdFreed)
{
GameMain.NetworkMember.CreateEntityEvent(this);
}
}
public override void Update(float deltaTime, Camera cam)
@@ -805,11 +819,6 @@ namespace Barotrauma
public void RemoveFire(FireSource fire)
{
FireSources.Remove(fire);
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer && !Removed && !IdFreed)
{
GameMain.NetworkMember.CreateEntityEvent(this);
}
}
public IEnumerable<Hull> GetConnectedHulls(int? searchDepth)
@@ -522,15 +522,9 @@ namespace Barotrauma
}
}
}
// The value should always be copied from the prefab. Editing is enabled only for testing the scale in the sub editor (changes are not saved).
#if DEBUG
[Serialize(1f, false), Editable(0.1f, 10f, DecimalCount = 3, ValueStep = 0.1f)]
#else
[Serialize(1f, false)]
#endif
public float Scale { get; set; } = 1;
public virtual float Scale { get; set; } = 1;
#endregion
}
}
@@ -159,6 +159,32 @@ namespace Barotrauma
private set;
}
private float scale = 1.0f;
public override float Scale
{
get { return scale; }
set
{
if (scale == value) { return; }
scale = MathHelper.Clamp(value, 0.1f, 10.0f);
float relativeScale = scale / prefab.Scale;
if (!ResizeHorizontal || !ResizeVertical)
{
int newWidth = ResizeHorizontal ? rect.Width : (int)(defaultRect.Width * relativeScale);
int newHeight = ResizeVertical ? rect.Height : (int)(defaultRect.Height * relativeScale);
Rect = new Rectangle(rect.X, rect.Y, newWidth, newHeight);
if (Sections != null)
{
UpdateSections();
}
}
}
}
private Rectangle defaultRect;
public override Rectangle Rect
{
get
@@ -169,9 +195,13 @@ namespace Barotrauma
{
Rectangle oldRect = Rect;
base.Rect = value;
if (Prefab.Body) CreateSections();
if (Prefab.Body)
{
CreateSections();
}
else
{
if (Sections == null) { return; }
foreach (WallSection sec in Sections)
{
Rectangle secRect = sec.rect;
@@ -189,11 +219,11 @@ namespace Barotrauma
public float BodyWidth
{
get { return Prefab.BodyWidth > 0.0f ? Prefab.BodyWidth : rect.Width; }
get { return Prefab.BodyWidth > 0.0f ? Prefab.BodyWidth * scale : rect.Width; }
}
public float BodyHeight
{
get { return Prefab.BodyHeight > 0.0f ? Prefab.BodyHeight : rect.Height; }
get { return Prefab.BodyHeight > 0.0f ? Prefab.BodyHeight * scale : rect.Height; }
}
/// <summary>
@@ -965,6 +995,7 @@ namespace Barotrauma
private void UpdateSections()
{
if (Bodies == null) return;
foreach (Body b in Bodies)
{
GameMain.World.RemoveBody(b);
@@ -1028,9 +1059,9 @@ namespace Barotrauma
if (BodyWidth > 0.0f) rect.Width = (int)BodyWidth;
if (BodyHeight > 0.0f) rect.Height = Math.Max((int)Math.Round(BodyHeight * (rect.Height / (float)this.rect.Height)), 1);
}
if (FlippedX) diffFromCenter = -diffFromCenter;
if (FlippedX) { diffFromCenter = -diffFromCenter; }
Vector2 bodyOffset = ConvertUnits.ToSimUnits(Prefab.BodyOffset);
Vector2 bodyOffset = ConvertUnits.ToSimUnits(Prefab.BodyOffset) * scale;
if (FlippedX) { bodyOffset.X = -bodyOffset.X; }
if (FlippedY) { bodyOffset.Y = -bodyOffset.Y; }
@@ -1050,7 +1081,8 @@ namespace Barotrauma
{
newBody.Position = structureCenter + bodyOffset + new Vector2(
(float)Math.Cos(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation),
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation)) * ConvertUnits.ToSimUnits(diffFromCenter);
(float)Math.Sin(IsHorizontal ? -BodyRotation : MathHelper.PiOver2 - BodyRotation))
* ConvertUnits.ToSimUnits(diffFromCenter);
newBody.Rotation = -BodyRotation;
}
else
@@ -1191,6 +1223,9 @@ namespace Barotrauma
{
XElement element = new XElement("Structure");
int width = ResizeHorizontal ? rect.Width : defaultRect.Width;
int height = ResizeVertical ? rect.Height : defaultRect.Height;
element.Add(
new XAttribute("name", prefab.Name),
new XAttribute("identifier", prefab.Identifier),
@@ -1203,15 +1238,6 @@ namespace Barotrauma
if (FlippedX) element.Add(new XAttribute("flippedx", true));
if (FlippedY) element.Add(new XAttribute("flippedy", true));
if (FlippedX) element.Add(new XAttribute("flippedx", true));
if (FlippedY) element.Add(new XAttribute("flippedy", true));
if (FlippedX) element.Add(new XAttribute("flippedx", true));
if (FlippedY) element.Add(new XAttribute("flippedy", true));
if (FlippedX) element.Add(new XAttribute("flippedx", true));
if (FlippedY) element.Add(new XAttribute("flippedy", true));
for (int i = 0; i < Sections.Length; i++)
{
if (Sections[i].damage == 0.0f) continue;
@@ -1117,6 +1117,7 @@ namespace Barotrauma
}
}
savedSubmarines.Add(new Submarine(filePath));
savedSubmarines = savedSubmarines.OrderBy(s => s.filePath ?? "").ToList();
}
public static void RefreshSavedSubs()