1 using Microsoft.Xna.Framework;
3 using System.Collections.Generic;
4 using System.Collections.Immutable;
68 if (!Enum.TryParse(functionStr, ignoreCase:
true, out
Function))
70 DebugConsole.ThrowError(
71 $
"Invalid location type change in location type \"{change.CurrentType}\". " +
72 $
"\"{functionStr}\" is not a valid function.");
81 DebugConsole.AddWarning(
82 $
"Invalid location type change in location type \"{change.CurrentType}\". " +
83 "Probability is configured to increase when near some other type of location, but the RequiredLocations attribute is not set.",
88 DebugConsole.AddWarning(
89 $
"Invalid location type change in location type \"{change.CurrentType}\". " +
90 "Probability is configured to increase when near some other type of location, but the base probability is already 100%",
100 maxDistance: distance,
137 private readonly
bool requireChangeMessages;
138 private readonly
string messageTag;
142 if (faction !=
null && TextManager.ContainsTag(messageTag +
"." + faction.
Prefab.Identifier))
144 return TextManager.GetAll(messageTag +
"." + faction.
Prefab.Identifier).ToImmutableArray();
147 if (TextManager.ContainsTag(messageTag))
149 return TextManager.GetAll(messageTag).ToImmutableArray();
153 if (requireChangeMessages)
155 DebugConsole.ThrowError($
"No messages defined for the location type change {CurrentType} -> {ChangeToType}");
157 return Enumerable.Empty<
string>().ToImmutableArray();
206 this.requireChangeMessages = requireChangeMessages;
209 foreach (var subElement
in element.Elements())
211 if (subElement.Name.ToString().Equals(
"requirement", StringComparison.OrdinalIgnoreCase))
227 (otherLocation) => { return DisallowedAdjacentLocations.Contains(otherLocation.Type.Identifier); }))
246 if (location.ProximityTimer.ContainsKey(requirement))
string? GetAttributeString(string key, string? def)
Identifier[] GetAttributeIdentifierArray(Identifier[] def, params string[] keys)
Point GetAttributePoint(string key, in Point def)
float GetAttributeFloat(string key, float def)
ContentPackage? ContentPackage
bool GetAttributeBool(string key, bool def)
int GetAttributeInt(string key, int def)
XAttribute? GetAttribute(string name)
Identifier GetAttributeIdentifier(string key, string def)
bool IsCriticallyRadiated()
int LocationTypeChangeCooldown
readonly float Probability
Base probability per turn for the location to change if near one of the RequiredLocations
Requirement(ContentXElement element, LocationTypeChange change)
bool MatchesConnection(LocationConnection connection)
readonly bool RequireHuntingGrounds
Does there need to be hunting grounds within RequiredProximity
readonly float ProximityProbabilityIncrease
How much the probability increases per turn if within RequiredProximityForProbabilityIncrease steps o...
readonly int RequiredProximityForProbabilityIncrease
How close the location needs to be to one of the RequiredLocations for the probability to increase
bool MatchesLocation(Location location)
readonly ImmutableArray< Identifier > RequiredLocations
The change can only happen if there's at least one of the given types of locations near this one
readonly bool RequireBeaconStation
Does there need to be a beacon station within RequiredProximity
readonly FunctionType Function
bool AnyWithinDistance(Location startLocation, int distance)
readonly int RequiredProximity
How close the location needs to be to one of the RequiredLocations for the change to occur
readonly Identifier CurrentType
readonly float Probability
Base probability per turn for the location to change if near one of the RequiredLocations
List< Requirement > Requirements
readonly bool RequireDiscovered
readonly int CooldownAfterChange
The location can't change it's type for this many turns after this location type changes occurs
readonly int DisallowedProximity
How close the location needs to be to one of the DisallowedAdjacentLocations for the change to be dis...
LocationTypeChange(Identifier currentType, ContentXElement element, bool requireChangeMessages, float defaultProbability=0.0f)
readonly Identifier ChangeToType
readonly Point RequiredDurationRange
IReadOnlyList< string > GetMessages(Faction faction)
float DetermineProbability(Location location)
readonly ImmutableArray< Identifier > DisallowedAdjacentLocations
The change can't happen if there's one or more of the given types of locations near this one
static bool LocationOrConnectionWithinDistance(Location startLocation, int maxDistance, Func< Location, bool > criteria, Func< LocationConnection, bool > connectionCriteria=null)
readonly Identifier Identifier