Unstable 1.1.14.0
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Items.Components;
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,22 +10,37 @@ namespace Barotrauma
|
||||
public override bool DisplayAsCompleted => false;
|
||||
public override bool DisplayAsFailed => false;
|
||||
|
||||
public override int State
|
||||
{
|
||||
get => base.State;
|
||||
set
|
||||
{
|
||||
base.State = value;
|
||||
if (base.State > 0)
|
||||
{
|
||||
caves.ForEach(c => c.MissionsToDisplayOnSonar.Remove(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClientReadInitial(IReadMessage msg)
|
||||
{
|
||||
base.ClientReadInitial(msg);
|
||||
byte caveCount = msg.ReadByte();
|
||||
for (int i = 0; i < caveCount; i++)
|
||||
{
|
||||
byte selectedCave = msg.ReadByte();
|
||||
if (selectedCave < 255 && Level.Loaded != null)
|
||||
byte selectedCaveIndex = msg.ReadByte();
|
||||
if (selectedCaveIndex < 255 && Level.Loaded != null)
|
||||
{
|
||||
if (selectedCave < Level.Loaded.Caves.Count)
|
||||
if (selectedCaveIndex < Level.Loaded.Caves.Count)
|
||||
{
|
||||
Level.Loaded.Caves[selectedCave].DisplayOnSonar = true;
|
||||
var selectedCave = Level.Loaded.Caves[selectedCaveIndex];
|
||||
selectedCave.MissionsToDisplayOnSonar.Add(this);
|
||||
caves.Add(selectedCave);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError($"Cave index out of bounds when reading nest mission data. Index: {selectedCave}, number of caves: {Level.Loaded.Caves.Count}");
|
||||
DebugConsole.ThrowError($"Cave index out of bounds when reading nest mission data. Index: {selectedCaveIndex}, number of caves: {Level.Loaded.Caves.Count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using static Barotrauma.MissionPrefab;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -27,7 +28,11 @@ namespace Barotrauma
|
||||
|
||||
public Color GetDifficultyColor()
|
||||
{
|
||||
int v = Difficulty ?? MissionPrefab.MinDifficulty;
|
||||
return GetDifficultyColor(Difficulty ?? MissionPrefab.MinDifficulty);
|
||||
}
|
||||
public static Color GetDifficultyColor(int difficulty)
|
||||
{
|
||||
int v = difficulty;
|
||||
float t = MathUtils.InverseLerp(MissionPrefab.MinDifficulty, MissionPrefab.MaxDifficulty, v);
|
||||
return ToolBox.GradientLerp(t, GUIStyle.Green, GUIStyle.Orange, GUIStyle.Red);
|
||||
}
|
||||
@@ -61,36 +66,48 @@ namespace Barotrauma
|
||||
List<LocalizedString> reputationRewardTexts = new List<LocalizedString>();
|
||||
foreach (var reputationReward in ReputationRewards)
|
||||
{
|
||||
FactionPrefab targetFactionPrefab;
|
||||
if (reputationReward.Key == "location" )
|
||||
FactionPrefab factionPrefab;
|
||||
if (reputationReward.FactionIdentifier == "location" )
|
||||
{
|
||||
targetFactionPrefab = OriginLocation.Faction?.Prefab;
|
||||
factionPrefab = OriginLocation.Faction?.Prefab;
|
||||
}
|
||||
else
|
||||
{
|
||||
FactionPrefab.Prefabs.TryGet(reputationReward.Key, out targetFactionPrefab);
|
||||
}
|
||||
|
||||
if (targetFactionPrefab == null)
|
||||
{
|
||||
return string.Empty;
|
||||
FactionPrefab.Prefabs.TryGet(reputationReward.FactionIdentifier, out factionPrefab);
|
||||
}
|
||||
|
||||
float totalReputationChange = reputationReward.Value;
|
||||
if (GameMain.GameSession?.Campaign?.Factions.Find(f => f.Prefab == targetFactionPrefab) is Faction faction)
|
||||
if (factionPrefab != null)
|
||||
{
|
||||
totalReputationChange = reputationReward.Value * faction.Reputation.GetReputationChangeMultiplier(reputationReward.Value);
|
||||
AddReputationText(factionPrefab, reputationReward.Amount);
|
||||
if (!MathUtils.NearlyEqual(reputationReward.AmountForOpposingFaction, 0.0f) &&
|
||||
FactionPrefab.Prefabs.TryGet(factionPrefab.OpposingFaction, out var opposingFactionPrefab))
|
||||
{
|
||||
AddReputationText(opposingFactionPrefab, reputationReward.AmountForOpposingFaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddReputationText(FactionPrefab factionPrefab, float amount)
|
||||
{
|
||||
if (factionPrefab == null) { return; }
|
||||
|
||||
float totalReputationChange = amount;
|
||||
if (GameMain.GameSession?.Campaign?.Factions.Find(f => f.Prefab == factionPrefab) is Faction faction)
|
||||
{
|
||||
totalReputationChange = amount * faction.Reputation.GetReputationChangeMultiplier(amount);
|
||||
}
|
||||
|
||||
LocalizedString name = $"‖color:{XMLExtensions.ToStringHex(targetFactionPrefab.IconColor)}‖{targetFactionPrefab.Name}‖end‖";
|
||||
LocalizedString name = $"‖color:{XMLExtensions.ToStringHex(factionPrefab.IconColor)}‖{factionPrefab.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.ToStringHex(Reputation.GetReputationColor(normalizedValue))}‖{formattedValue}‖end‖" ));
|
||||
("[reputationvalue]", $"‖color:{XMLExtensions.ToStringHex(Reputation.GetReputationColor(normalizedValue))}‖{formattedValue}‖end‖"));
|
||||
reputationRewardTexts.Add(rewardText.Value);
|
||||
}
|
||||
|
||||
|
||||
if (reputationRewardTexts.Any())
|
||||
{
|
||||
return RichString.Rich(TextManager.AddPunctuation(':', TextManager.Get("reputation"), LocalizedString.Join(", ", reputationRewardTexts)));
|
||||
@@ -100,6 +117,20 @@ namespace Barotrauma
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
partial void DistributeExperienceToCrew(IEnumerable<Character> crew, int experienceGain)
|
||||
{
|
||||
foreach (Character character in crew)
|
||||
{
|
||||
GiveMissionExperience(character.Info);
|
||||
}
|
||||
void GiveMissionExperience(CharacterInfo info)
|
||||
{
|
||||
if (info == null) { return; }
|
||||
var experienceGainMultiplierIndividual = new AbilityMissionExperienceGainMultiplier(this, 1f);
|
||||
info.Character?.CheckTalents(AbilityEffectType.OnGainMissionExperience, experienceGainMultiplierIndividual);
|
||||
info.GiveExperience((int)(experienceGain * experienceGainMultiplierIndividual.Value));
|
||||
}
|
||||
}
|
||||
|
||||
partial void ShowMessageProjSpecific(int missionState)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,19 @@ namespace Barotrauma
|
||||
public override bool DisplayAsCompleted => State > 0 && !requireDelivery;
|
||||
public override bool DisplayAsFailed => false;
|
||||
|
||||
public override int State
|
||||
{
|
||||
get => base.State;
|
||||
set
|
||||
{
|
||||
base.State = value;
|
||||
if (base.State > 0 && selectedCave != null)
|
||||
{
|
||||
selectedCave.MissionsToDisplayOnSonar.Remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClientReadInitial(IReadMessage msg)
|
||||
{
|
||||
base.ClientReadInitial(msg);
|
||||
@@ -20,8 +33,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (selectedCaveIndex < Level.Loaded.Caves.Count)
|
||||
{
|
||||
Level.Loaded.Caves[selectedCaveIndex].DisplayOnSonar = true;
|
||||
SpawnNestObjects(Level.Loaded, Level.Loaded.Caves[selectedCaveIndex]);
|
||||
selectedCave = Level.Loaded.Caves[selectedCaveIndex];
|
||||
selectedCave.MissionsToDisplayOnSonar.Add(this);
|
||||
SpawnNestObjects(Level.Loaded, selectedCave);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user