v0.11.0.9
This commit is contained in:
+94
-27
@@ -1,50 +1,117 @@
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class BackgroundCreaturePrefab
|
||||
{
|
||||
public readonly Sprite Sprite;
|
||||
public readonly Sprite Sprite, LightSprite;
|
||||
public readonly DeformableSprite DeformableSprite, DeformableLightSprite;
|
||||
|
||||
public readonly float Speed;
|
||||
public readonly string Name;
|
||||
|
||||
public readonly float WanderAmount;
|
||||
public readonly XElement Config;
|
||||
|
||||
public readonly float WanderZAmount;
|
||||
[Serialize(1.0f, true)]
|
||||
public float Speed { get; private set; }
|
||||
|
||||
public readonly int SwarmMin, SwarmMax;
|
||||
public readonly float SwarmRadius, SwarmCohesion;
|
||||
[Serialize(0.0f, true)]
|
||||
public float WanderAmount { get; private set; }
|
||||
|
||||
public readonly bool DisableRotation;
|
||||
[Serialize(0.0f, true)]
|
||||
public float WanderZAmount { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
public int SwarmMin { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
public int SwarmMax { get; private set; }
|
||||
|
||||
[Serialize(200.0f, true)]
|
||||
public float SwarmRadius { get; private set; }
|
||||
|
||||
[Serialize(0.2f, true)]
|
||||
public float SwarmCohesion { get; private set; }
|
||||
|
||||
[Serialize(10.0f, true)]
|
||||
public float MinDepth { get; private set; }
|
||||
|
||||
[Serialize(1000.0f, true)]
|
||||
public float MaxDepth { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
public bool DisableRotation { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
public bool DisableFlipping { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
public float Scale { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
public float Commonness { get; private set; }
|
||||
|
||||
[Serialize(1000, true)]
|
||||
public int MaxCount { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
public float FlashInterval { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
public float FlashDuration { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the commonness of the object in a specific level type.
|
||||
/// Key = name of the level type, value = commonness in that level type.
|
||||
/// </summary>
|
||||
public Dictionary<string, float> OverrideCommonness = new Dictionary<string, float>();
|
||||
|
||||
public readonly float Scale;
|
||||
|
||||
public BackgroundCreaturePrefab(XElement element)
|
||||
{
|
||||
Speed = element.GetAttributeFloat("speed", 1.0f);
|
||||
Name = element.Name.ToString();
|
||||
|
||||
WanderAmount = element.GetAttributeFloat("wanderamount", 0.0f);
|
||||
Config = element;
|
||||
|
||||
WanderZAmount = element.GetAttributeFloat("wanderzamount", 0.0f);
|
||||
|
||||
SwarmMin = element.GetAttributeInt("swarmmin", 1);
|
||||
SwarmMax = element.GetAttributeInt("swarmmax", 1);
|
||||
|
||||
SwarmRadius = element.GetAttributeFloat("swarmradius", 200.0f);
|
||||
SwarmCohesion = element.GetAttributeFloat("swarmcohesion", 0.2f);
|
||||
|
||||
DisableRotation = element.GetAttributeBool("disablerotation", false);
|
||||
|
||||
Scale = element.GetAttributeFloat("scale", 1.0f);
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("sprite", System.StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
|
||||
Sprite = new Sprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "sprite":
|
||||
Sprite = new Sprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "deformablesprite":
|
||||
DeformableSprite = new DeformableSprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "lightsprite":
|
||||
LightSprite = new Sprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "deformablelightsprite":
|
||||
DeformableLightSprite = new DeformableSprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "overridecommonness":
|
||||
string levelType = subElement.GetAttributeString("leveltype", "").ToLowerInvariant();
|
||||
if (!OverrideCommonness.ContainsKey(levelType))
|
||||
{
|
||||
OverrideCommonness.Add(levelType, subElement.GetAttributeFloat("commonness", 1.0f));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetCommonness(LevelGenerationParams generationParams)
|
||||
{
|
||||
if (generationParams?.Identifier != null &&
|
||||
(OverrideCommonness.TryGetValue(generationParams.Identifier, out float commonness) ||
|
||||
(generationParams.OldIdentifier != null && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
{
|
||||
return commonness;
|
||||
}
|
||||
return Commonness;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user