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
@@ -1,6 +1,6 @@
using System;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;
namespace Barotrauma
{
@@ -14,12 +14,12 @@ namespace Barotrauma
public readonly bool TriggerEventCooldown;
public readonly float Commonness;
public readonly Identifier BiomeIdentifier;
public readonly Identifier Faction;
public readonly float SpawnDistance;
public readonly bool UnlockPathEvent;
public readonly string UnlockPathTooltip;
public readonly int UnlockPathReputation;
public readonly string UnlockPathFaction;
public EventPrefab(ContentXElement element, RandomEventsFile file, Identifier fallbackIdentifier = default)
: base(file, element.GetAttributeIdentifier("identifier", fallbackIdentifier))
@@ -40,6 +40,7 @@ namespace Barotrauma
}
BiomeIdentifier = ConfigElement.GetAttributeIdentifier("biome", Identifier.Empty);
Faction = ConfigElement.GetAttributeIdentifier("faction", Identifier.Empty);
Commonness = element.GetAttributeFloat("commonness", 1.0f);
Probability = Math.Clamp(element.GetAttributeFloat(1.0f, "probability", "spawnprobability"), 0, 1);
TriggerEventCooldown = element.GetAttributeBool("triggereventcooldown", EventType != typeof(ScriptedEvent));
@@ -47,7 +48,6 @@ namespace Barotrauma
UnlockPathEvent = element.GetAttributeBool("unlockpathevent", false);
UnlockPathTooltip = element.GetAttributeString("unlockpathtooltip", "lockedpathtooltip");
UnlockPathReputation = element.GetAttributeInt("unlockpathreputation", 0);
UnlockPathFaction = element.GetAttributeString("unlockpathfaction", "");
SpawnDistance = element.GetAttributeFloat("spawndistance", 0);
}
@@ -80,5 +80,17 @@ namespace Barotrauma
{
return $"EventPrefab ({Identifier})";
}
public static EventPrefab GetUnlockPathEvent(Identifier biomeIdentifier, Faction faction)
{
var unlockPathEvents = Prefabs.OrderBy(p => p.Identifier).Where(e => e.UnlockPathEvent);
if (faction != null && unlockPathEvents.Any(e => e.Faction == faction.Prefab.Identifier))
{
unlockPathEvents = unlockPathEvents.Where(e => e.Faction == faction.Prefab.Identifier);
}
return
unlockPathEvents.FirstOrDefault(ep => ep.BiomeIdentifier == biomeIdentifier) ??
unlockPathEvents.FirstOrDefault(ep => ep.BiomeIdentifier == Identifier.Empty);
}
}
}