Unstable 0.17.0.0
This commit is contained in:
+1
-1
@@ -90,7 +90,7 @@ namespace Barotrauma
|
||||
|
||||
checkWallsTimer = Rand.Range(0.0f, CheckWallsInterval, Rand.RandSync.ClientOnly);
|
||||
|
||||
foreach (XElement subElement in prefab.Config.Elements())
|
||||
foreach (var subElement in prefab.Config.Elements())
|
||||
{
|
||||
List<SpriteDeformation> deformationList = null;
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
|
||||
+16
-15
@@ -18,45 +18,46 @@ namespace Barotrauma
|
||||
private readonly List<BackgroundCreaturePrefab> prefabs = new List<BackgroundCreaturePrefab>();
|
||||
private readonly List<BackgroundCreature> creatures = new List<BackgroundCreature>();
|
||||
|
||||
public BackgroundCreatureManager(string configPath)
|
||||
{
|
||||
LoadConfig(new ContentFile(configPath, ContentType.BackgroundCreaturePrefabs));
|
||||
}
|
||||
|
||||
public BackgroundCreatureManager(IEnumerable<ContentFile> files)
|
||||
public BackgroundCreatureManager(IEnumerable<BackgroundCreaturePrefabsFile> files)
|
||||
{
|
||||
foreach(var file in files)
|
||||
{
|
||||
LoadConfig(file);
|
||||
LoadConfig(file.Path);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadConfig(ContentFile config)
|
||||
public BackgroundCreatureManager(string path)
|
||||
{
|
||||
DebugConsole.AddWarning($"Couldn't find any BackgroundCreaturePrefabs files, falling back to {path}");
|
||||
LoadConfig(ContentPath.FromRaw(null, path));
|
||||
}
|
||||
|
||||
private void LoadConfig(ContentPath configPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(config.Path);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configPath);
|
||||
if (doc == null) { return; }
|
||||
var mainElement = doc.Root;
|
||||
var mainElement = doc.Root.FromPackage(configPath.ContentPackage);
|
||||
if (mainElement.IsOverride())
|
||||
{
|
||||
mainElement = doc.Root.FirstElement();
|
||||
mainElement = mainElement.FirstElement();
|
||||
prefabs.Clear();
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{config.Path}'", Color.Yellow);
|
||||
DebugConsole.NewMessage($"Overriding all background creatures with '{configPath}'", Color.Yellow);
|
||||
}
|
||||
else if (prefabs.Any())
|
||||
{
|
||||
DebugConsole.NewMessage($"Loading additional background creatures from file '{config.Path}'");
|
||||
DebugConsole.NewMessage($"Loading additional background creatures from file '{configPath}'");
|
||||
}
|
||||
|
||||
foreach (XElement element in mainElement.Elements())
|
||||
foreach (var element in mainElement.Elements())
|
||||
{
|
||||
prefabs.Add(new BackgroundCreaturePrefab(element));
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", config.Path), e);
|
||||
DebugConsole.ThrowError(String.Format("Failed to load BackgroundCreatures from {0}", configPath), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-22
@@ -12,52 +12,52 @@ namespace Barotrauma
|
||||
|
||||
public readonly XElement Config;
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Speed { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float WanderAmount { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float WanderZAmount { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
[Serialize(1, IsPropertySaveable.Yes)]
|
||||
public int SwarmMin { get; private set; }
|
||||
|
||||
[Serialize(1, true)]
|
||||
[Serialize(1, IsPropertySaveable.Yes)]
|
||||
public int SwarmMax { get; private set; }
|
||||
|
||||
[Serialize(200.0f, true)]
|
||||
[Serialize(200.0f, IsPropertySaveable.Yes)]
|
||||
public float SwarmRadius { get; private set; }
|
||||
|
||||
[Serialize(0.2f, true)]
|
||||
[Serialize(0.2f, IsPropertySaveable.Yes)]
|
||||
public float SwarmCohesion { get; private set; }
|
||||
|
||||
[Serialize(10.0f, true)]
|
||||
[Serialize(10.0f, IsPropertySaveable.Yes)]
|
||||
public float MinDepth { get; private set; }
|
||||
|
||||
[Serialize(1000.0f, true)]
|
||||
[Serialize(1000.0f, IsPropertySaveable.Yes)]
|
||||
public float MaxDepth { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
public bool DisableRotation { get; private set; }
|
||||
|
||||
[Serialize(false, true)]
|
||||
[Serialize(false, IsPropertySaveable.Yes)]
|
||||
public bool DisableFlipping { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Scale { get; private set; }
|
||||
|
||||
[Serialize(1.0f, true)]
|
||||
[Serialize(1.0f, IsPropertySaveable.Yes)]
|
||||
public float Commonness { get; private set; }
|
||||
|
||||
[Serialize(1000, true)]
|
||||
[Serialize(1000, IsPropertySaveable.Yes)]
|
||||
public int MaxCount { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float FlashInterval { get; private set; }
|
||||
|
||||
[Serialize(0.0f, true)]
|
||||
[Serialize(0.0f, IsPropertySaveable.Yes)]
|
||||
public float FlashDuration { get; private set; }
|
||||
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace Barotrauma
|
||||
/// 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 Dictionary<Identifier, float> OverrideCommonness = new Dictionary<Identifier, float>();
|
||||
|
||||
public BackgroundCreaturePrefab(XElement element)
|
||||
public BackgroundCreaturePrefab(ContentXElement element)
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Barotrauma
|
||||
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -92,7 +92,7 @@ namespace Barotrauma
|
||||
DeformableLightSprite = new DeformableSprite(subElement, lazyLoad: true);
|
||||
break;
|
||||
case "overridecommonness":
|
||||
string levelType = subElement.GetAttributeString("leveltype", "").ToLowerInvariant();
|
||||
Identifier levelType = subElement.GetAttributeIdentifier("leveltype", Identifier.Empty);
|
||||
if (!OverrideCommonness.ContainsKey(levelType))
|
||||
{
|
||||
OverrideCommonness.Add(levelType, subElement.GetAttributeFloat("commonness", 1.0f));
|
||||
@@ -104,9 +104,10 @@ namespace Barotrauma
|
||||
|
||||
public float GetCommonness(LevelGenerationParams generationParams)
|
||||
{
|
||||
if (generationParams?.Identifier != null &&
|
||||
if (generationParams != null &&
|
||||
!generationParams.Identifier.IsEmpty &&
|
||||
(OverrideCommonness.TryGetValue(generationParams.Identifier, out float commonness) ||
|
||||
(generationParams.OldIdentifier != null && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
(!generationParams.OldIdentifier.IsEmpty && OverrideCommonness.TryGetValue(generationParams.OldIdentifier, out commonness))))
|
||||
{
|
||||
return commonness;
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ namespace Barotrauma
|
||||
SoundTriggers = new LevelTrigger[Prefab.Sounds.Count];
|
||||
for (int i = 0; i < Prefab.Sounds.Count; i++)
|
||||
{
|
||||
Sounds[i] = Submarine.LoadRoundSound(Prefab.Sounds[i].SoundElement, false);
|
||||
Sounds[i] = RoundSound.Load(Prefab.Sounds[i].SoundElement, false);
|
||||
SoundTriggers[i] = Prefab.Sounds[i].TriggerIndex > -1 ? Triggers[Prefab.Sounds[i].TriggerIndex] : null;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
foreach (XElement subElement in Prefab.Config.Elements())
|
||||
foreach (var subElement in Prefab.Config.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("deformablesprite", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
foreach (XElement animationElement in subElement.Elements())
|
||||
@@ -151,7 +151,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
VisibleOnSonar = Prefab.SonarDisruption > 0.0f || Prefab.OverrideProperties.Any(p => p != null && p.SonarDisruption > 0.0f) ||
|
||||
(Triggers != null && Triggers.Any(t => !MathUtils.NearlyEqual(t.Force, Vector2.Zero) && t.ForceMode != LevelTrigger.TriggerForceMode.LimitVelocity || !string.IsNullOrWhiteSpace(t.InfectIdentifier)));
|
||||
(Triggers != null && Triggers.Any(t => !MathUtils.NearlyEqual(t.Force, Vector2.Zero) && t.ForceMode != LevelTrigger.TriggerForceMode.LimitVelocity || !t.InfectIdentifier.IsEmpty));
|
||||
if (VisibleOnSonar && Triggers.Any())
|
||||
{
|
||||
SonarRadius = Triggers.Select(t => t.ColliderRadius * 1.5f).Max();
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(obj.Position.X, -obj.Position.Y), new Vector2(10.0f, 10.0f), GUI.Style.Red, true);
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(obj.Position.X, -obj.Position.Y), new Vector2(10.0f, 10.0f), GUIStyle.Red, true);
|
||||
|
||||
if (obj.Triggers == null) { continue; }
|
||||
foreach (LevelTrigger trigger in obj.Triggers)
|
||||
@@ -218,7 +218,7 @@ namespace Barotrauma
|
||||
if (flowForce.LengthSquared() > 1)
|
||||
{
|
||||
flowForce.Y = -flowForce.Y;
|
||||
GUI.DrawLine(spriteBatch, new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y), new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y) + flowForce * 10, GUI.Style.Orange, 0, 5);
|
||||
GUI.DrawLine(spriteBatch, new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y), new Vector2(trigger.WorldPosition.X, -trigger.WorldPosition.Y) + flowForce * 10, GUIStyle.Orange, 0, 5);
|
||||
}
|
||||
trigger.PhysicsBody.UpdateDrawPosition();
|
||||
trigger.PhysicsBody.DebugDraw(spriteBatch, trigger.IsTriggered ? Color.Cyan : Color.DarkCyan);
|
||||
|
||||
+11
-11
@@ -9,15 +9,15 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class LevelObjectPrefab
|
||||
partial class LevelObjectPrefab : PrefabWithUintIdentifier, ISerializableEntity
|
||||
{
|
||||
public class SoundConfig
|
||||
{
|
||||
public readonly XElement SoundElement;
|
||||
public readonly ContentXElement SoundElement;
|
||||
public readonly Vector2 Position;
|
||||
public readonly int TriggerIndex;
|
||||
|
||||
public SoundConfig(XElement element, int triggerIndex)
|
||||
public SoundConfig(ContentXElement element, int triggerIndex)
|
||||
{
|
||||
SoundElement = element;
|
||||
Position = element.GetAttributeVector2("position", Vector2.Zero);
|
||||
@@ -67,14 +67,14 @@ namespace Barotrauma
|
||||
private set;
|
||||
} = new List<SpriteDeformation>();
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
partial void InitProjSpecific(ContentXElement element)
|
||||
{
|
||||
LoadElementsProjSpecific(element, -1);
|
||||
}
|
||||
|
||||
private void LoadElementsProjSpecific(XElement element, int parentTriggerIndex)
|
||||
private void LoadElementsProjSpecific(ContentXElement element, int parentTriggerIndex)
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -121,7 +121,7 @@ namespace Barotrauma
|
||||
|
||||
SerializableProperty.SerializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements().ToList())
|
||||
foreach (var subElement in element.Elements().ToList())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -144,7 +144,7 @@ namespace Barotrauma
|
||||
{
|
||||
int elementIndex = 0;
|
||||
bool wasSaved = false;
|
||||
foreach (XElement subElement in element.Elements().ToList())
|
||||
foreach (var subElement in element.Elements().ToList())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
@@ -175,13 +175,13 @@ namespace Barotrauma
|
||||
new XAttribute("maxcount", childObj.MaxCount)));
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, float> overrideCommonness in OverrideCommonness)
|
||||
foreach (KeyValuePair<Identifier, float> overrideCommonness in OverrideCommonness)
|
||||
{
|
||||
bool elementFound = false;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("overridecommonness", System.StringComparison.OrdinalIgnoreCase)
|
||||
&& subElement.GetAttributeString("leveltype", "").Equals(overrideCommonness.Key, System.StringComparison.OrdinalIgnoreCase))
|
||||
&& subElement.GetAttributeIdentifier("leveltype", Identifier.Empty) == overrideCommonness.Key)
|
||||
{
|
||||
subElement.Attribute("commonness").Value = overrideCommonness.Value.ToString("G", CultureInfo.InvariantCulture);
|
||||
elementFound = true;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace Barotrauma
|
||||
GUI.DrawLine(spriteBatch,
|
||||
new Vector2(nodeList[i - 1].X, -nodeList[i - 1].Y),
|
||||
new Vector2(nodeList[i].X, -nodeList[i].Y),
|
||||
Color.Lerp(Color.Yellow, GUI.Style.Red, i / (float)nodeList.Count), 0, 10);
|
||||
Color.Lerp(Color.Yellow, GUIStyle.Red, i / (float)nodeList.Count), 0, 10);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user