3 using System.Reflection;
70 return new EventPrefab(element, file, fallbackIdentifier);
75 : base(file, element.GetAttributeIdentifier(
"identifier", fallbackIdentifier))
84 DebugConsole.ThrowError(
"Could not find an event class of the type \"" +
ConfigElement.
Name +
"\".",
90 DebugConsole.ThrowError(
"Could not find an event class of the type \"" +
ConfigElement.
Name +
"\".",
112 return instance is not
null;
117 ConstructorInfo constructor =
EventType.GetConstructor(
new[] { GetType(), typeof(
int) });
118 Event instance =
null;
121 instance = constructor.Invoke(
new object[] {
this, seed }) as
Event;
125 DebugConsole.ThrowError(ex.InnerException !=
null ? ex.InnerException.ToString() : ex.ToString());
135 return $
"{nameof(EventPrefab)} ({Identifier})";
140 var unlockPathEvents =
Prefabs.OrderBy(p => p.Identifier).Where(e => e.UnlockPathEvent);
141 if (faction !=
null && unlockPathEvents.Any(e => e.Faction == faction.
Prefab.Identifier))
143 unlockPathEvents = unlockPathEvents.Where(e => e.Faction == faction.
Prefab.Identifier);
146 unlockPathEvents.FirstOrDefault(ep => ep.BiomeIdentifier == biomeIdentifier) ??
147 unlockPathEvents.FirstOrDefault(ep => ep.BiomeIdentifier ==
Identifier.Empty);
string? GetAttributeString(string key, string? def)
float GetAttributeFloat(string key, float def)
ContentPackage? ContentPackage
Identifier NameAsIdentifier()
bool GetAttributeBool(string key, bool def)
int GetAttributeInt(string key, int def)
Identifier GetAttributeIdentifier(string key, string def)
virtual bool LevelMeetsRequirements()
readonly Identifier BiomeIdentifier
If set, the event set can only be chosen in this biome.
readonly LocalizedString Name
readonly Identifier RequiredLayer
If set, this layer must be present somewhere in the level.
Event CreateInstance(int seed)
readonly bool UnlockPathEvent
If set, this event is used as an event that can unlock a path to the next biome.
readonly string UnlockPathTooltip
Only valid if UnlockPathEvent is set to true. The tooltip displayed on the pathway this event is bloc...
readonly float Commonness
The commonness of the event (i.e. how likely it is for this specific event to be chosen from the even...
EventPrefab(ContentXElement element, RandomEventsFile file, Identifier fallbackIdentifier=default)
override string ToString()
static EventPrefab Create(ContentXElement element, RandomEventsFile file, Identifier fallbackIdentifier=default)
readonly bool TriggerEventCooldown
When this event occurs, should it trigger the event cooldown during which no new events are triggered...
bool TryCreateInstance< T >(int seed, out T instance)
static EventPrefab GetUnlockPathEvent(Identifier biomeIdentifier, Faction faction)
readonly ContentXElement ConfigElement
readonly Identifier Faction
If set, the event set can only be chosen in locations that belong to this faction.
readonly int UnlockPathReputation
Only valid if UnlockPathEvent is set to true. The reputation requirement displayed on the pathway thi...
readonly float Probability
The probability for the event to do something if it gets selected. For example, the probability for a...
static readonly PrefabCollection< EventPrefab > Prefabs
LocalizedString Fallback(LocalizedString fallback, bool useDefaultLanguageIfFound=true)
Use this text instead if the original text cannot be found.
readonly Identifier Identifier