Build 1.1.4.0
This commit is contained in:
@@ -32,44 +32,73 @@ namespace Barotrauma
|
||||
return ToolBox.GradientLerp(t, GUIStyle.Green, GUIStyle.Orange, GUIStyle.Red);
|
||||
}
|
||||
|
||||
public virtual RichString GetMissionRewardText(Submarine sub)
|
||||
/// <summary>
|
||||
/// Returns the amount of marks you get from the reward (e.g. "3,000 mk")
|
||||
/// </summary>
|
||||
protected LocalizedString GetRewardAmountText(Submarine sub)
|
||||
{
|
||||
LocalizedString rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetReward(sub)));
|
||||
return RichString.Rich(TextManager.GetWithVariable("missionreward", "[reward]", "‖color:gui.orange‖"+rewardText+"‖end‖"));
|
||||
int baseReward = GetReward(sub);
|
||||
int finalReward = GetFinalReward(sub);
|
||||
string rewardAmountText = string.Format(CultureInfo.InvariantCulture, "{0:N0}", baseReward);
|
||||
if (finalReward > baseReward)
|
||||
{
|
||||
rewardAmountText += $" + {string.Format(CultureInfo.InvariantCulture, "{0:N0}", finalReward - baseReward)}";
|
||||
}
|
||||
return TextManager.GetWithVariable("currencyformat", "[credits]", rewardAmountText);
|
||||
}
|
||||
|
||||
public RichString GetReputationRewardText(Location currLocation)
|
||||
/// <summary>
|
||||
/// Returns the full reward text of the mission (e.g. "Reward: 2,000 mk" or "Reward: 500 mk x 2 (out of max 5) = 1,000 mk")
|
||||
/// </summary>
|
||||
public virtual RichString GetMissionRewardText(Submarine sub)
|
||||
{
|
||||
LocalizedString rewardText = GetRewardAmountText(sub);
|
||||
return RichString.Rich(TextManager.GetWithVariable("missionreward", "[reward]", "‖color:gui.orange‖" + rewardText + "‖end‖"));
|
||||
}
|
||||
|
||||
public RichString GetReputationRewardText()
|
||||
{
|
||||
List<LocalizedString> reputationRewardTexts = new List<LocalizedString>();
|
||||
foreach (var reputationReward in ReputationRewards)
|
||||
{
|
||||
LocalizedString name = "";
|
||||
|
||||
if (reputationReward.Key == "location")
|
||||
FactionPrefab targetFactionPrefab;
|
||||
if (reputationReward.Key == "location" )
|
||||
{
|
||||
name = $"‖color:gui.orange‖{currLocation.Name}‖end‖";
|
||||
targetFactionPrefab = OriginLocation.Faction?.Prefab;
|
||||
}
|
||||
else
|
||||
{
|
||||
var faction = FactionPrefab.Prefabs.Find(f => f.Identifier == reputationReward.Key);
|
||||
if (faction != null)
|
||||
{
|
||||
name = $"‖color:{XMLExtensions.ColorToString(faction.IconColor)}‖{faction.Name}‖end‖";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = TextManager.Get(reputationReward.Key);
|
||||
}
|
||||
FactionPrefab.Prefabs.TryGet(reputationReward.Key, out targetFactionPrefab);
|
||||
}
|
||||
|
||||
if (targetFactionPrefab == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
float normalizedValue = MathUtils.InverseLerp(-100.0f, 100.0f, reputationReward.Value);
|
||||
string formattedValue = ((int)reputationReward.Value).ToString("+#;-#;0"); //force plus sign for positive numbers
|
||||
|
||||
float totalReputationChange = reputationReward.Value;
|
||||
if (GameMain.GameSession?.Campaign?.Factions.Find(f => f.Prefab == targetFactionPrefab) is Faction faction)
|
||||
{
|
||||
totalReputationChange = reputationReward.Value * faction.Reputation.GetReputationChangeMultiplier(reputationReward.Value);
|
||||
}
|
||||
|
||||
LocalizedString name = $"‖color:{XMLExtensions.ToStringHex(targetFactionPrefab.IconColor)}‖{targetFactionPrefab.Name}‖end‖";
|
||||
float normalizedValue = MathUtils.InverseLerp(-100.0f, 100.0f, totalReputationChange);
|
||||
string formattedValue = ((int)Math.Round(totalReputationChange)).ToString("+#;-#;0"); //force plus sign for positive numbers
|
||||
LocalizedString rewardText = TextManager.GetWithVariables(
|
||||
"reputationformat",
|
||||
("[reputationname]", name),
|
||||
("[reputationvalue]", $"‖color:{XMLExtensions.ColorToString(Reputation.GetReputationColor(normalizedValue))}‖{formattedValue}‖end‖" ));
|
||||
("[reputationvalue]", $"‖color:{XMLExtensions.ToStringHex(Reputation.GetReputationColor(normalizedValue))}‖{formattedValue}‖end‖" ));
|
||||
reputationRewardTexts.Add(rewardText.Value);
|
||||
}
|
||||
return RichString.Rich(TextManager.AddPunctuation(':', TextManager.Get("reputation"), LocalizedString.Join(", ", reputationRewardTexts)));
|
||||
if (reputationRewardTexts.Any())
|
||||
{
|
||||
return RichString.Rich(TextManager.AddPunctuation(':', TextManager.Get("reputation"), LocalizedString.Join(", ", reputationRewardTexts)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
partial void ShowMessageProjSpecific(int missionState)
|
||||
@@ -107,6 +136,11 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
public Identifier GetOverrideMusicType()
|
||||
{
|
||||
return Prefab.GetOverrideMusicType(State);
|
||||
}
|
||||
|
||||
public virtual void ClientRead(IReadMessage msg)
|
||||
{
|
||||
State = msg.ReadInt16();
|
||||
|
||||
Reference in New Issue
Block a user