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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user