Unstable 1.1.14.0
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -16,12 +15,25 @@ namespace Barotrauma
|
||||
public readonly float Commonness;
|
||||
public readonly Identifier BiomeIdentifier;
|
||||
public readonly Identifier Faction;
|
||||
public readonly float SpawnDistance;
|
||||
|
||||
public readonly LocalizedString Name;
|
||||
|
||||
public readonly bool UnlockPathEvent;
|
||||
public readonly string UnlockPathTooltip;
|
||||
public readonly int UnlockPathReputation;
|
||||
|
||||
public static EventPrefab Create(ContentXElement element, RandomEventsFile file, Identifier fallbackIdentifier = default)
|
||||
{
|
||||
if (element.NameAsIdentifier() == nameof(TraitorEvent))
|
||||
{
|
||||
return new TraitorEventPrefab(element, file, fallbackIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new EventPrefab(element, file, fallbackIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
public EventPrefab(ContentXElement element, RandomEventsFile file, Identifier fallbackIdentifier = default)
|
||||
: base(file, element.GetAttributeIdentifier("identifier", fallbackIdentifier))
|
||||
{
|
||||
@@ -40,6 +52,8 @@ namespace Barotrauma
|
||||
DebugConsole.ThrowError("Could not find an event class of the type \"" + ConfigElement.Name + "\".");
|
||||
}
|
||||
|
||||
Name = TextManager.Get($"eventname.{Identifier}").Fallback(Identifier.ToString());
|
||||
|
||||
BiomeIdentifier = ConfigElement.GetAttributeIdentifier("biome", Identifier.Empty);
|
||||
Faction = ConfigElement.GetAttributeIdentifier("faction", Identifier.Empty);
|
||||
Commonness = element.GetAttributeFloat("commonness", 1.0f);
|
||||
@@ -49,19 +63,17 @@ namespace Barotrauma
|
||||
UnlockPathEvent = element.GetAttributeBool("unlockpathevent", false);
|
||||
UnlockPathTooltip = element.GetAttributeString("unlockpathtooltip", "lockedpathtooltip");
|
||||
UnlockPathReputation = element.GetAttributeInt("unlockpathreputation", 0);
|
||||
|
||||
SpawnDistance = element.GetAttributeFloat("spawndistance", 0);
|
||||
}
|
||||
|
||||
public bool TryCreateInstance<T>(out T instance) where T : Event
|
||||
{
|
||||
instance = CreateInstance() as T;
|
||||
return instance is T;
|
||||
return instance is not null;
|
||||
}
|
||||
|
||||
public Event CreateInstance()
|
||||
{
|
||||
ConstructorInfo constructor = EventType.GetConstructor(new[] { typeof(EventPrefab) });
|
||||
ConstructorInfo constructor = EventType.GetConstructor(new[] { GetType() });
|
||||
Event instance = null;
|
||||
try
|
||||
{
|
||||
@@ -79,7 +91,7 @@ namespace Barotrauma
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"EventPrefab ({Identifier})";
|
||||
return $"{nameof(EventPrefab)} ({Identifier})";
|
||||
}
|
||||
|
||||
public static EventPrefab GetUnlockPathEvent(Identifier biomeIdentifier, Faction faction)
|
||||
|
||||
Reference in New Issue
Block a user