Faction Test 100.4.0.0

This commit is contained in:
Markus Isberg
2022-11-14 18:28:28 +02:00
parent 87426b68b2
commit c772b61fc1
412 changed files with 16984 additions and 5530 deletions
@@ -23,6 +23,15 @@ namespace Barotrauma
get { return allowedLocationTypes; }
}
[Serialize(-1, IsPropertySaveable.Yes), Editable(MinValueInt = -1, MaxValueInt = 10)]
public int ForceToEndLocationIndex
{
get;
set;
}
[Serialize(10, IsPropertySaveable.Yes), Editable(MinValueInt = 1, MaxValueInt = 50)]
public int TotalModuleCount
{
@@ -30,6 +39,13 @@ namespace Barotrauma
set;
}
[Serialize(true, IsPropertySaveable.Yes, description: "Should the generator append generic (module flag \"none\") modules to the outpost to reach the total module count."), Editable]
public bool AppendToReachTotalModuleCount
{
get;
set;
}
[Serialize(200.0f, IsPropertySaveable.Yes), Editable(MinValueFloat = 0.0f, MaxValueFloat = 1000.0f)]
public float MinHallwayLength
{
@@ -79,6 +95,13 @@ namespace Barotrauma
set;
}
[Serialize(false, IsPropertySaveable.Yes), Editable]
public bool DrawBehindSubs
{
get;
set;
}
[Serialize(0.0f, IsPropertySaveable.Yes), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
public float MinWaterPercentage
{
@@ -93,26 +116,38 @@ namespace Barotrauma
set;
}
public LevelData.LevelType? LevelType
{
get;
set;
}
[Serialize("", IsPropertySaveable.Yes), Editable]
public string ReplaceInRadiation { get; set; }
public ContentPath OutpostFilePath { get; set; }
public class ModuleCount
{
public Identifier Identifier;
public int Count;
public int Order;
public Identifier RequiredFaction;
public ModuleCount(ContentXElement element)
{
Identifier = element.GetAttributeIdentifier("flag", element.GetAttributeIdentifier("moduletype", ""));
Count = element.GetAttributeInt("count", 0);
Order = element.GetAttributeInt("order", 0);
RequiredFaction = element.GetAttributeIdentifier("requiredfaction", Identifier.Empty);
}
public ModuleCount(Identifier id, int count)
{
Identifier = id;
Count = count;
RequiredFaction = Identifier.Empty;
}
}
@@ -130,16 +165,20 @@ namespace Barotrauma
private readonly HumanPrefab humanPrefab = null;
private readonly Identifier setIdentifier = Identifier.Empty;
private readonly Identifier npcIdentifier = Identifier.Empty;
public readonly Identifier FactionIdentifier = Identifier.Empty;
public Entry(HumanPrefab humanPrefab)
public Entry(HumanPrefab humanPrefab, Identifier factionIdentifier)
{
this.humanPrefab = humanPrefab;
this.FactionIdentifier = factionIdentifier;
}
public Entry(Identifier setIdentifier, Identifier npcIdentifier)
public Entry(Identifier setIdentifier, Identifier npcIdentifier, Identifier factionIdentifier)
{
this.setIdentifier = setIdentifier;
this.npcIdentifier = npcIdentifier;
this.FactionIdentifier = factionIdentifier;
}
public HumanPrefab HumanPrefab
@@ -148,12 +187,12 @@ namespace Barotrauma
private readonly List<Entry> entries = new List<Entry>();
public void Add(HumanPrefab humanPrefab)
=> entries.Add(new Entry(humanPrefab));
public void Add(HumanPrefab humanPrefab, Identifier factionIdentifier)
=> entries.Add(new Entry(humanPrefab, factionIdentifier));
public void Add(Identifier setIdentifier, Identifier npcIdentifier)
=> entries.Add(new Entry(setIdentifier, npcIdentifier));
public void Add(Identifier setIdentifier, Identifier npcIdentifier, Identifier factionIdentifier)
=> entries.Add(new Entry(setIdentifier, npcIdentifier, factionIdentifier));
public IEnumerator<HumanPrefab> GetEnumerator()
{
@@ -165,12 +204,23 @@ namespace Barotrauma
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IEnumerable<HumanPrefab> GetByFaction(IEnumerable<FactionPrefab> factions)
{
foreach (var entry in entries)
{
if (entry.FactionIdentifier == Identifier.Empty || factions.Any(f => f.Identifier == entry.FactionIdentifier))
{
yield return entry.HumanPrefab;
}
}
}
public int Count => entries.Count;
public HumanPrefab this[int index] => entries[index].HumanPrefab;
}
private readonly ImmutableArray<IReadOnlyList<HumanPrefab>> humanPrefabCollections;
private readonly ImmutableArray<NpcCollection> humanPrefabCollections;
public Dictionary<Identifier, SerializableProperty> SerializableProperties { get; private set; }
@@ -182,8 +232,23 @@ namespace Barotrauma
Name = element.GetAttributeString("name", Identifier.Value);
allowedLocationTypes = element.GetAttributeIdentifierArray("allowedlocationtypes", Array.Empty<Identifier>()).ToHashSet();
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
if (element.GetAttribute("leveltype") != null)
{
string levelTypeStr = element.GetAttributeString("leveltype", "");
if (Enum.TryParse(levelTypeStr, out LevelData.LevelType parsedLevelType))
{
LevelType = parsedLevelType;
}
else
{
DebugConsole.ThrowError($"Error in outpost generation parameters \"{Identifier}\". \"{levelTypeStr}\" is not a valid level type.");
}
}
OutpostFilePath = element.GetAttributeContentPath(nameof(OutpostFilePath));
var humanPrefabCollections = new List<IReadOnlyList<HumanPrefab>>();
var humanPrefabCollections = new List<NpcCollection>();
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -196,14 +261,14 @@ namespace Barotrauma
foreach (var npcElement in subElement.Elements())
{
Identifier from = npcElement.GetAttributeIdentifier("from", Identifier.Empty);
Identifier faction = npcElement.GetAttributeIdentifier("faction", Identifier.Empty);
if (from != Identifier.Empty)
{
newCollection.Add(from, npcElement.GetAttributeIdentifier("identifier", Identifier.Empty));
newCollection.Add(from, npcElement.GetAttributeIdentifier("identifier", Identifier.Empty), faction);
}
else
{
newCollection.Add(new HumanPrefab(npcElement, file, npcSetIdentifier: from));
newCollection.Add(new HumanPrefab(npcElement, file, npcSetIdentifier: from), faction);
}
}
humanPrefabCollections.Add(newCollection);
@@ -251,10 +316,12 @@ namespace Barotrauma
}
}
public IReadOnlyList<HumanPrefab> GetHumanPrefabs(Rand.RandSync randSync)
public IReadOnlyList<HumanPrefab> GetHumanPrefabs(IEnumerable<FactionPrefab> factions, Rand.RandSync randSync)
{
if (!humanPrefabCollections.Any()) { return Array.Empty<HumanPrefab>(); }
return humanPrefabCollections.GetRandom(randSync);
var collection = humanPrefabCollections.GetRandom(randSync);
return collection.GetByFaction(factions).ToImmutableList();
}
public ImmutableHashSet<Identifier> GetStoreIdentifiers()