- Renamed a bunch of ObjectProperty-related stuff (ObjectProperty -> SerializableProperty, IPropertyObject -> ISerializableEntity, the "SerializableProperty" attribute -> Serialize).

- Rectangle serialization.
- Option to restrict numeric properties to a range of values.
- WIP generic ISerializableEntity editor.
This commit is contained in:
Joonas Rikkonen
2017-11-08 21:15:03 +02:00
parent a0d606ef5f
commit 8e556f1c76
60 changed files with 1035 additions and 678 deletions
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
partial class Hull : MapEntity, IPropertyObject, IServerSerializable
partial class Hull : MapEntity, ISerializableEntity, IServerSerializable
{
const float NetworkUpdateInterval = 0.5f;
@@ -40,8 +40,8 @@ namespace Barotrauma
//how much excess water the room can contain (= more than the volume of the room)
public const float MaxCompress = 10000f;
public readonly Dictionary<string, ObjectProperty> properties;
public Dictionary<string, ObjectProperty> ObjectProperties
public readonly Dictionary<string, SerializableProperty> properties;
public Dictionary<string, SerializableProperty> SerializableProperties
{
get { return properties; }
}
@@ -139,7 +139,7 @@ namespace Barotrauma
}
}
[SerializableProperty(90.0f, true)]
[Serialize(90.0f, true)]
public float Oxygen
{
get { return oxygen; }
@@ -197,7 +197,7 @@ namespace Barotrauma
fireSources = new List<FireSource>();
properties = ObjectProperty.GetProperties(this);
properties = SerializableProperty.GetProperties(this);
int arraySize = (rectangle.Width / WaveWidth + 1);
waveY = new float[arraySize];
@@ -44,7 +44,7 @@ namespace Barotrauma
}
}
class LevelGenerationParams : IPropertyObject
class LevelGenerationParams : ISerializableEntity
{
private static List<LevelGenerationParams> levelParams;
private static List<Biome> biomes;
@@ -102,27 +102,27 @@ namespace Barotrauma
set;
}
[SerializableProperty(1000, false)]
[Serialize(1000, false)]
public int BackgroundSpriteAmount
{
get;
set;
}
public Dictionary<string, ObjectProperty> ObjectProperties
public Dictionary<string, SerializableProperty> SerializableProperties
{
get;
set;
}
[SerializableProperty(100000.0f, false)]
[Serialize(100000.0f, false)]
public float Width
{
get { return width; }
set { width = Math.Max(value, 2000.0f); }
}
[SerializableProperty(50000.0f, false)]
[Serialize(50000.0f, false)]
public float Height
{
get { return height; }
@@ -160,7 +160,7 @@ namespace Barotrauma
}
}
[SerializableProperty(5, false)]
[Serialize(5, false)]
public int SmallTunnelCount
{
get { return smallTunnelCount; }
@@ -177,21 +177,21 @@ namespace Barotrauma
}
}
[SerializableProperty(-300000.0f, false)]
[Serialize(-300000.0f, false)]
public float SeaFloorDepth
{
get { return seaFloorBaseDepth; }
set { seaFloorBaseDepth = MathHelper.Clamp(value, Level.MaxEntityDepth, 0.0f); }
}
[SerializableProperty(1000.0f, false)]
[Serialize(1000.0f, false)]
public float SeaFloorVariance
{
get { return seaFloorVariance; }
set { seaFloorVariance = value; }
}
[SerializableProperty(0, false)]
[Serialize(0, false)]
public int MountainCountMin
{
get { return mountainCountMin; }
@@ -201,7 +201,7 @@ namespace Barotrauma
}
}
[SerializableProperty(0, false)]
[Serialize(0, false)]
public int MountainCountMax
{
get { return mountainCountMax; }
@@ -211,7 +211,7 @@ namespace Barotrauma
}
}
[SerializableProperty(1000.0f, false)]
[Serialize(1000.0f, false)]
public float MountainHeightMin
{
get { return mountainHeightMin; }
@@ -221,7 +221,7 @@ namespace Barotrauma
}
}
[SerializableProperty(5000.0f, false)]
[Serialize(5000.0f, false)]
public float MountainHeightMax
{
get { return mountainHeightMax; }
@@ -231,14 +231,14 @@ namespace Barotrauma
}
}
[SerializableProperty(1, false)]
[Serialize(1, false)]
public int RuinCount
{
get { return ruinCount; }
set { ruinCount = MathHelper.Clamp(value, 0, 10); }
}
[SerializableProperty(0.4f, false)]
[Serialize(0.4f, false)]
public float BottomHoleProbability
{
get { return bottomHoleProbability; }
@@ -278,7 +278,7 @@ namespace Barotrauma
private LevelGenerationParams(XElement element)
{
Name = element == null ? "default" : element.Name.ToString();
ObjectProperties = ObjectProperty.DeserializeProperties(this, element);
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
Vector3 colorVector = element.GetAttributeVector3("BackgroundColor", new Vector3(50, 46, 20));
BackgroundColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z);
@@ -132,7 +132,7 @@ namespace Barotrauma
sp.size.Y = element.GetAttributeFloat("height", 0.0f);
string spriteColorStr = element.GetAttributeString("spritecolor", "1.0,1.0,1.0,1.0");
sp.SpriteColor = new Color(XMLExtensions.ParseToVector4(spriteColorStr));
sp.SpriteColor = new Color(XMLExtensions.ParseVector4(spriteColorStr));
sp.maxHealth = element.GetAttributeFloat("health", 100.0f);