Unstable 0.17.0.0
This commit is contained in:
@@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Immutable;
|
||||
using Barotrauma.Abilities;
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -56,9 +57,9 @@ namespace Barotrauma
|
||||
private readonly List<Vector2> bodyDebugDimensions = new List<Vector2>();
|
||||
|
||||
#if DEBUG
|
||||
[Serialize(false, true), Editable]
|
||||
[Serialize(false, IsPropertySaveable.Yes), Editable]
|
||||
#else
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
#endif
|
||||
public bool Indestructible
|
||||
{
|
||||
@@ -75,7 +76,7 @@ namespace Barotrauma
|
||||
|
||||
public override Sprite Sprite
|
||||
{
|
||||
get { return prefab.sprite; }
|
||||
get { return base.Prefab.Sprite; }
|
||||
}
|
||||
|
||||
public bool IsPlatform
|
||||
@@ -91,7 +92,7 @@ namespace Barotrauma
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return prefab.Name; }
|
||||
get { return base.Prefab.Name.Value; }
|
||||
}
|
||||
|
||||
public bool HasBody
|
||||
@@ -115,7 +116,7 @@ namespace Barotrauma
|
||||
|
||||
private float? maxHealth;
|
||||
|
||||
[Serialize(100.0f, true), Editable(MinValueFloat = 0)]
|
||||
[Serialize(100.0f, IsPropertySaveable.Yes), Editable(MinValueFloat = 0)]
|
||||
public float MaxHealth
|
||||
{
|
||||
get => maxHealth ?? Prefab.Health;
|
||||
@@ -124,7 +125,7 @@ namespace Barotrauma
|
||||
|
||||
private float crushDepth;
|
||||
|
||||
[Serialize(Level.DefaultRealWorldCrushDepth, true)]
|
||||
[Serialize(Level.DefaultRealWorldCrushDepth, IsPropertySaveable.Yes)]
|
||||
public float CrushDepth
|
||||
{
|
||||
get => crushDepth;
|
||||
@@ -163,29 +164,26 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
public StructurePrefab Prefab => prefab as StructurePrefab;
|
||||
public new StructurePrefab Prefab => base.Prefab as StructurePrefab;
|
||||
|
||||
public HashSet<string> Tags
|
||||
{
|
||||
get { return prefab.Tags; }
|
||||
}
|
||||
public ImmutableHashSet<Identifier> Tags => Prefab.Tags;
|
||||
|
||||
protected Color spriteColor;
|
||||
[Editable, Serialize("1.0,1.0,1.0,1.0", true)]
|
||||
[Editable, Serialize("1.0,1.0,1.0,1.0", IsPropertySaveable.Yes)]
|
||||
public Color SpriteColor
|
||||
{
|
||||
get { return spriteColor; }
|
||||
set { spriteColor = value; }
|
||||
}
|
||||
|
||||
[Editable, Serialize(false, true)]
|
||||
[Editable, Serialize(false, IsPropertySaveable.Yes)]
|
||||
public bool UseDropShadow
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Editable, Serialize("0,0", true, description: "The position of the drop shadow relative to the structure. If set to zero, the shadow is positioned automatically so that it points towards the sub's center of mass.")]
|
||||
[Editable, Serialize("0,0", IsPropertySaveable.Yes, description: "The position of the drop shadow relative to the structure. If set to zero, the shadow is positioned automatically so that it points towards the sub's center of mass.")]
|
||||
public Vector2 DropShadowOffset
|
||||
{
|
||||
get;
|
||||
@@ -201,7 +199,7 @@ namespace Barotrauma
|
||||
if (scale == value) { return; }
|
||||
scale = MathHelper.Clamp(value, 0.1f, 10.0f);
|
||||
|
||||
float relativeScale = scale / prefab.Scale;
|
||||
float relativeScale = scale / base.Prefab.Scale;
|
||||
|
||||
if (!ResizeHorizontal || !ResizeVertical)
|
||||
{
|
||||
@@ -230,7 +228,7 @@ namespace Barotrauma
|
||||
|
||||
protected Vector2 textureScale = Vector2.One;
|
||||
|
||||
[Editable(DecimalCount = 3, MinValueFloat = 0.01f, MaxValueFloat = 10f, ValueStep = 0.1f), Serialize("1.0, 1.0", false)]
|
||||
[Editable(DecimalCount = 3, MinValueFloat = 0.01f, MaxValueFloat = 10f, ValueStep = 0.1f), Serialize("1.0, 1.0", IsPropertySaveable.No)]
|
||||
public Vector2 TextureScale
|
||||
{
|
||||
get { return textureScale; }
|
||||
@@ -250,7 +248,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
protected Vector2 textureOffset = Vector2.Zero;
|
||||
[Editable(MinValueFloat = -1000f, MaxValueFloat = 1000f, ValueStep = 10f), Serialize("0.0, 0.0", true)]
|
||||
[Editable(MinValueFloat = -1000f, MaxValueFloat = 1000f, ValueStep = 10f), Serialize("0.0, 0.0", IsPropertySaveable.Yes)]
|
||||
public Vector2 TextureOffset
|
||||
{
|
||||
get { return textureOffset; }
|
||||
@@ -343,14 +341,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
[Serialize(false, true), Editable]
|
||||
[Serialize(false, IsPropertySaveable.Yes), Editable]
|
||||
public bool NoAITarget
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties
|
||||
public Dictionary<Identifier, SerializableProperty> SerializableProperties
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
@@ -406,7 +404,7 @@ namespace Barotrauma
|
||||
rect = rectangle;
|
||||
TextureScale = sp.TextureScale;
|
||||
|
||||
spriteColor = prefab.SpriteColor;
|
||||
spriteColor = base.Prefab.SpriteColor;
|
||||
if (sp.IsHorizontal.HasValue)
|
||||
{
|
||||
IsHorizontal = sp.IsHorizontal.Value;
|
||||
@@ -461,7 +459,7 @@ namespace Barotrauma
|
||||
SerializableProperties = element != null ? SerializableProperty.DeserializeProperties(this, element) : SerializableProperty.GetProperties(this);
|
||||
|
||||
#if CLIENT
|
||||
foreach (XElement subElement in sp.ConfigElement.Elements())
|
||||
foreach (var subElement in sp.ConfigElement.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("light", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -524,7 +522,7 @@ namespace Barotrauma
|
||||
{
|
||||
defaultRect = defaultRect
|
||||
};
|
||||
foreach (KeyValuePair<string, SerializableProperty> property in SerializableProperties)
|
||||
foreach (KeyValuePair<Identifier, SerializableProperty> property in SerializableProperties)
|
||||
{
|
||||
if (!property.Value.Attributes.OfType<Editable>().Any()) { continue; }
|
||||
clone.SerializableProperties[property.Key].TrySetValue(clone, property.Value.GetValue(this));
|
||||
@@ -572,13 +570,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (FlippedX && IsHorizontal)
|
||||
{
|
||||
xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width);
|
||||
width = prefab.sprite.SourceRect.Width;
|
||||
xsections = (int)Math.Ceiling((float)rect.Width / base.Prefab.Sprite.SourceRect.Width);
|
||||
width = base.Prefab.Sprite.SourceRect.Width;
|
||||
}
|
||||
else if (FlippedY && !IsHorizontal)
|
||||
{
|
||||
ysections = (int)Math.Ceiling((float)rect.Height / prefab.sprite.SourceRect.Height);
|
||||
width = prefab.sprite.SourceRect.Height;
|
||||
ysections = (int)Math.Ceiling((float)rect.Height / base.Prefab.Sprite.SourceRect.Height);
|
||||
width = base.Prefab.Sprite.SourceRect.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1184,7 +1182,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (damageDiff < 0.0f)
|
||||
{
|
||||
attacker.Info?.IncreaseSkillLevel("mechanical",
|
||||
attacker.Info?.IncreaseSkillLevel("mechanical".ToIdentifier(),
|
||||
-damageDiff * SkillSettings.Current.SkillIncreasePerRepairedStructureDamage / Math.Max(attacker.GetSkillLevel("mechanical"), 1.0f));
|
||||
}
|
||||
}
|
||||
@@ -1374,10 +1372,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static Structure Load(XElement element, Submarine submarine, IdRemap idRemap)
|
||||
public static Structure Load(ContentXElement element, Submarine submarine, IdRemap idRemap)
|
||||
{
|
||||
string name = element.Attribute("name").Value;
|
||||
string identifier = element.GetAttributeString("identifier", "");
|
||||
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
|
||||
|
||||
StructurePrefab prefab = FindPrefab(name, identifier);
|
||||
if (prefab == null)
|
||||
@@ -1398,7 +1396,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
bool hasDamage = false;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -1421,7 +1419,7 @@ namespace Barotrauma
|
||||
break;
|
||||
case "upgrade":
|
||||
{
|
||||
var upgradeIdentifier = subElement.GetAttributeString("identifier", string.Empty);
|
||||
var upgradeIdentifier = subElement.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
UpgradePrefab upgradePrefab = UpgradePrefab.Find(upgradeIdentifier);
|
||||
int level = subElement.GetAttributeInt("level", 1);
|
||||
if (upgradePrefab != null)
|
||||
@@ -1460,18 +1458,18 @@ namespace Barotrauma
|
||||
return s;
|
||||
}
|
||||
|
||||
public static StructurePrefab FindPrefab(string name, string identifier)
|
||||
public static StructurePrefab FindPrefab(string name, Identifier identifier)
|
||||
{
|
||||
StructurePrefab prefab = null;
|
||||
if (string.IsNullOrEmpty(identifier))
|
||||
if (identifier.IsEmpty)
|
||||
{
|
||||
//legacy support:
|
||||
//1. attempt to find a prefab with an empty identifier and a matching name
|
||||
prefab = MapEntityPrefab.Find(name, "") as StructurePrefab;
|
||||
//2. not found, attempt to find a prefab with a matching name
|
||||
if (prefab == null) prefab = MapEntityPrefab.Find(name) as StructurePrefab;
|
||||
if (prefab == null) { prefab = MapEntityPrefab.Find(name) as StructurePrefab; }
|
||||
//3. not found, attempt to find a prefab that uses the previous name as an identifier
|
||||
if (prefab == null) prefab = MapEntityPrefab.Find(null, name) as StructurePrefab;
|
||||
if (prefab == null) { prefab = MapEntityPrefab.Find(null, name) as StructurePrefab; }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1488,8 +1486,8 @@ namespace Barotrauma
|
||||
int height = ResizeVertical ? rect.Height : defaultRect.Height;
|
||||
|
||||
element.Add(
|
||||
new XAttribute("name", prefab.Name),
|
||||
new XAttribute("identifier", prefab.Identifier),
|
||||
new XAttribute("name", base.Prefab.Name),
|
||||
new XAttribute("identifier", base.Prefab.Identifier),
|
||||
new XAttribute("ID", ID),
|
||||
new XAttribute("rect",
|
||||
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
|
||||
|
||||
Reference in New Issue
Block a user