1 using Microsoft.Xna.Framework;
33 private readonly
Identifier metaDataIdentifier;
48 if (MathUtils.NearlyEqual(
Value, value) ||
Metadata ==
null) {
return; }
50 float prevValue =
Value;
56 int increase = (int)
Value - (
int)prevValue;
61 increase > 0 ? GUIStyle.Green : GUIStyle.Red,
62 playSound:
true,
Identifier, increase, lifetime: 5.0f);
70 Value = newReputation;
75 return reputationChange
switch
84 float multiplier = 1f;
86 if (crew !=
null && crew.Any())
88 multiplier *= 1f + crew.Max(c => c.GetStatValue(statTypes, includeSaved:
false));
89 multiplier *= 1f + crew.Max(c => c.Info?.GetSavedStatValue(statTypes, identifier) ?? 0);
95 public void AddReputation(
float reputationChange,
float maxReputationChangePerRound =
float.MaxValue)
97 float prevValue =
Value;
99 if (doesReputationChangeGoOverLimit(prevValue, reputationChange))
105 if (doesReputationChangeGoOverLimit(newValue, newValue - prevValue))
112 bool doesReputationChangeGoOverLimit(
float newValue,
float change)
116 Math.Abs(totalReputationChange) > maxReputationChangePerRound &&
117 Math.Sign(totalReputationChange) == Math.Sign(change);
129 : this(metadata, null, location, identifier, minReputation, maxReputation, initialReputation)
133 public Reputation(CampaignMetadata metadata,
Faction faction,
int minReputation,
int maxReputation,
int initialReputation)
134 : this(metadata, faction, null, $
"faction.{faction.Prefab.Identifier}".ToIdentifier(), minReputation, maxReputation, initialReputation)
140 System.Diagnostics.Debug.Assert(faction !=
null || location !=
null);
143 metaDataIdentifier = $
"reputation.{Identifier}".ToIdentifier();
161 return TextManager.Get(
"reputationverylow");
163 else if (normalizedValue < 0.4f)
165 return TextManager.Get(
"reputationlow");
167 else if (normalizedValue < 0.6f)
169 return TextManager.Get(
"reputationneutral");
171 else if (normalizedValue < 0.8f)
173 return TextManager.Get(
"reputationhigh");
175 return TextManager.Get(
"reputationveryhigh");
183 return GUIStyle.ColorReputationVeryLow;
185 else if (normalizedValue < 0.4f)
187 return GUIStyle.ColorReputationLow;
189 else if (normalizedValue < 0.6f)
191 return GUIStyle.ColorReputationNeutral;
193 else if (normalizedValue < 0.8f)
195 return GUIStyle.ColorReputationHigh;
197 return GUIStyle.ColorReputationVeryHigh;
207 LocalizedString formattedReputation = TextManager.GetWithVariables(
"reputationformat",
208 (
"[reputationname]", reputationName),
209 (
"[reputationvalue]", ((
int)Math.Round(value)).ToString()));
212 formattedReputation = $
"‖color:{XMLExtensions.ToStringHex(GetReputationColor(normalizedValue))}‖{formattedReputation}‖end‖";
214 return formattedReputation;
void AddMessage(string rawText, Color color, bool playSound, Identifier identifier=default, int? value=null, float lifetime=3.0f)
static Character? Controlled
static ImmutableHashSet< Character > GetSessionCrewCharacters(CharacterType type)
Returns a list of crew characters currently in the game with a given filter.
LocalizedString DisplayName
Reputation(CampaignMetadata metadata, Location location, Identifier identifier, int minReputation, int maxReputation, int initialReputation)
const float HostileThreshold
const float MaxReputationLossPerStolenItem
const float ReputationLossPerStolenItemPrice
float GetReputationChangeMultiplier(float reputationChange)
const float MaxReputationLossFromWallDamage
Maximum amount of reputation loss you can get from damaging outpost walls per round
const float MinReputationLossPerStolenItem
LocalizedString GetReputationName()
static LocalizedString GetReputationName(float normalizedValue)
static LocalizedString GetFormattedReputationText(float normalizedValue, float value, bool addColorTags=false)
static readonly NamedEvent< Reputation > OnAnyReputationValueChanged
static Color GetReputationColor(float normalizedValue)
const float MaxReputationLossFromNPCDamage
Maximum amount of reputation loss you can get from damaging outpost NPCs per round
void SetReputation(float newReputation)
void AddReputation(float reputationChange, float maxReputationChangePerRound=float.MaxValue)
const float ReputationLossPerNPCDamage
float ReputationAtRoundStart
LocalizedString GetFormattedReputationText(bool addColorTags=false)
readonly NamedEvent< Reputation > OnReputationValueChanged
readonly Location Location
const float ReputationLossPerWallDamage
CampaignMetadata Metadata
float NormalizedValue
Reputation value normalized to the range of 0-1
Reputation(CampaignMetadata metadata, Faction faction, int minReputation, int maxReputation, int initialReputation)
StatTypes
StatTypes are used to alter several traits of a character. They are mostly used by talents.