v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -67,6 +67,8 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public readonly List<Identifier> NonRepeatableEvents = new List<Identifier>();
|
||||
|
||||
public readonly Dictionary<EventSet, int> FinishedEvents = new Dictionary<EventSet, int>();
|
||||
|
||||
/// <summary>
|
||||
/// 'Exhaustible' sets won't appear in the same level until after one world step (~10 min, see Map.ProgressWorld) has passed. <see cref="EventSet.Exhaustible"/>.
|
||||
/// </summary>
|
||||
@@ -155,6 +157,47 @@ namespace Barotrauma
|
||||
string[] nonRepeatablePrefabNames = element.GetAttributeStringArray("nonrepeatableevents", Array.Empty<string>());
|
||||
NonRepeatableEvents.AddRange(EventPrefab.Prefabs.Where(p => nonRepeatablePrefabNames.Any(n => p.Identifier == n)).Select(p => p.Identifier));
|
||||
|
||||
string finishedEventsName = nameof(FinishedEvents);
|
||||
if (element.GetChildElement(finishedEventsName) is { } finishedEventsElement)
|
||||
{
|
||||
foreach (var childElement in finishedEventsElement.GetChildElements(finishedEventsName))
|
||||
{
|
||||
Identifier eventSetIdentifier = childElement.GetAttributeIdentifier("set", Identifier.Empty);
|
||||
if (eventSetIdentifier.IsEmpty) { continue; }
|
||||
if (!EventSet.Prefabs.TryGet(eventSetIdentifier, out EventSet eventSet))
|
||||
{
|
||||
foreach (var prefab in EventSet.Prefabs)
|
||||
{
|
||||
if (FindSetRecursive(prefab, eventSetIdentifier) is { } foundSet)
|
||||
{
|
||||
eventSet = foundSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eventSet is null) { continue; }
|
||||
int count = childElement.GetAttributeInt("count", 0);
|
||||
if (count < 1) { continue; }
|
||||
FinishedEvents.Add(eventSet, count);
|
||||
}
|
||||
|
||||
static EventSet FindSetRecursive(EventSet parentSet, Identifier setIdentifier)
|
||||
{
|
||||
foreach (var childSet in parentSet.ChildSets)
|
||||
{
|
||||
if (childSet.Identifier == setIdentifier)
|
||||
{
|
||||
return childSet;
|
||||
}
|
||||
if (FindSetRecursive(childSet, setIdentifier) is { } foundSet)
|
||||
{
|
||||
return foundSet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
EventsExhausted = element.GetAttributeBool(nameof(EventsExhausted).ToLower(), false);
|
||||
}
|
||||
|
||||
@@ -319,6 +362,18 @@ namespace Barotrauma
|
||||
{
|
||||
newElement.Add(new XAttribute("nonrepeatableevents", string.Join(',', NonRepeatableEvents)));
|
||||
}
|
||||
if (FinishedEvents.Any())
|
||||
{
|
||||
var finishedEventsElement = new XElement(nameof(FinishedEvents));
|
||||
foreach (var (set, count) in FinishedEvents)
|
||||
{
|
||||
var element = new XElement(nameof(FinishedEvents),
|
||||
new XAttribute("set", set.Identifier),
|
||||
new XAttribute("count", count));
|
||||
finishedEventsElement.Add(element);
|
||||
}
|
||||
newElement.Add(finishedEventsElement);
|
||||
}
|
||||
}
|
||||
|
||||
parentElement.Add(newElement);
|
||||
|
||||
Reference in New Issue
Block a user