Unstable 1.2.4.0

This commit is contained in:
Markus Isberg
2023-11-30 13:53:00 +02:00
parent 8a2e2ea0ae
commit fb5ea537bf
210 changed files with 4201 additions and 1283 deletions
@@ -262,7 +262,7 @@ namespace Barotrauma
while (spawnWaypoints.Any() && spawnWaypoints.Count < characterInfos.Count)
{
spawnWaypoints.Add(spawnWaypoints[Rand.Int(spawnWaypoints.Count)]);
}
}
}
if (spawnWaypoints == null || !spawnWaypoints.Any())
{
@@ -306,15 +306,16 @@ namespace Barotrauma
}
character.LoadTalents();
character.GiveIdCardTags(new List<WayPoint>() { mainSubWaypoints[i], spawnWaypoints[i] });
character.Info.StartItemsGiven = true;
character.GiveIdCardTags(mainSubWaypoints[i]);
character.GiveIdCardTags(spawnWaypoints[i]);
character.Info.StartItemsGiven = true;
if (character.Info.OrderData != null)
{
character.Info.ApplyOrderData();
}
}
AddCharacter(character, sortCrewList: false);
#if CLIENT
if (IsSinglePlayer && (Character.Controlled == null || character.Info.LastControlled)) { Character.Controlled = character; }
@@ -45,7 +45,14 @@ namespace Barotrauma
}
else
{
data.Add(identifier, Convert.ChangeType(value, type, NumberFormatInfo.InvariantInfo));
try
{
data.Add(identifier, Convert.ChangeType(value, type, NumberFormatInfo.InvariantInfo));
}
catch (Exception e)
{
DebugConsole.ThrowError($"Failed to change the type of the value \"{value}\" to {type}.", e);
}
}
}
}
@@ -57,7 +57,7 @@ namespace Barotrauma
if (increase != 0 && Character.Controlled != null)
{
Character.Controlled.AddMessage(
TextManager.GetWithVariable("reputationgainnotification", "[reputationname]", Location?.Name ?? Faction.Prefab.Name).Value,
TextManager.GetWithVariable("reputationgainnotification", "[reputationname]", Location?.DisplayName ?? Faction.Prefab.Name).Value,
increase > 0 ? GUIStyle.Green : GUIStyle.Red,
playSound: true, Identifier, increase, lifetime: 5.0f);
}
@@ -558,8 +558,8 @@ namespace Barotrauma
if (availableTransition == TransitionType.None)
{
DebugConsole.ThrowError("Failed to load a new campaign level. No available level transitions " +
"(current location: " + (map.CurrentLocation?.Name ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.Name ?? "null") + ", " +
"(current location: " + (map.CurrentLocation?.DisplayName ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.DisplayName ?? "null") + ", " +
"leaving sub: " + (leavingSub?.Info?.Name ?? "null") + ", " +
"at start: " + (leavingSub?.AtStartExit.ToString() ?? "null") + ", " +
"at end: " + (leavingSub?.AtEndExit.ToString() ?? "null") + ")\n" +
@@ -570,8 +570,8 @@ namespace Barotrauma
{
DebugConsole.ThrowError("Failed to load a new campaign level. No available level transitions " +
"(transition type: " + availableTransition + ", " +
"current location: " + (map.CurrentLocation?.Name ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.Name ?? "null") + ", " +
"current location: " + (map.CurrentLocation?.DisplayName ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.DisplayName ?? "null") + ", " +
"leaving sub: " + (leavingSub?.Info?.Name ?? "null") + ", " +
"at start: " + (leavingSub?.AtStartExit.ToString() ?? "null") + ", " +
"at end: " + (leavingSub?.AtEndExit.ToString() ?? "null") + ")\n" +
@@ -582,8 +582,8 @@ namespace Barotrauma
ShowCampaignUI = ForceMapUI = false;
#endif
DebugConsole.NewMessage("Transitioning to " + (nextLevel?.Seed ?? "null") +
" (current location: " + (map.CurrentLocation?.Name ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.Name ?? "null") + ", " +
" (current location: " + (map.CurrentLocation?.DisplayName ?? "null") + ", " +
"selected location: " + (map.SelectedLocation?.DisplayName ?? "null") + ", " +
"leaving sub: " + (leavingSub?.Info?.Name ?? "null") + ", " +
"at start: " + (leavingSub?.AtStartExit.ToString() ?? "null") + ", " +
"at end: " + (leavingSub?.AtEndExit.ToString() ?? "null") + ", " +
@@ -1024,7 +1024,7 @@ namespace Barotrauma
return ToolBox.SelectWeightedRandom(factionsList, weights, random);
}
public bool TryHireCharacter(Location location, CharacterInfo characterInfo, Client client = null)
public bool TryHireCharacter(Location location, CharacterInfo characterInfo, Character hirer, Client client = null)
{
if (characterInfo == null) { return false; }
if (characterInfo.MinReputationToHire.factionId != Identifier.Empty)
@@ -1034,7 +1034,8 @@ namespace Barotrauma
return false;
}
}
if (!TryPurchase(client, characterInfo.Salary)) { return false; }
if (!TryPurchase(client, HireManager.GetSalaryFor(characterInfo))) { return false; }
characterInfo.IsNewHire = true;
characterInfo.Title = null;
location.RemoveHireableCharacter(characterInfo);
@@ -1263,7 +1264,7 @@ namespace Barotrauma
{
DebugConsole.NewMessage("********* CAMPAIGN STATUS *********", Color.White);
DebugConsole.NewMessage(" Money: " + Bank.Balance, Color.White);
DebugConsole.NewMessage(" Current location: " + map.CurrentLocation.Name, Color.White);
DebugConsole.NewMessage(" Current location: " + map.CurrentLocation.DisplayName, Color.White);
DebugConsole.NewMessage(" Available destinations: ", Color.White);
for (int i = 0; i < map.CurrentLocation.Connections.Count; i++)
@@ -1271,11 +1272,11 @@ namespace Barotrauma
Location destination = map.CurrentLocation.Connections[i].OtherLocation(map.CurrentLocation);
if (destination == map.SelectedLocation)
{
DebugConsole.NewMessage(" " + i + ". " + destination.Name + " [SELECTED]", Color.White);
DebugConsole.NewMessage(" " + i + ". " + destination.DisplayName + " [SELECTED]", Color.White);
}
else
{
DebugConsole.NewMessage(" " + i + ". " + destination.Name, Color.White);
DebugConsole.NewMessage(" " + i + ". " + destination.DisplayName, Color.White);
}
}
@@ -1307,7 +1308,7 @@ namespace Barotrauma
{
if (NumberOfMissionsAtLocation(location) > Settings.TotalMaxMissionCount)
{
DebugConsole.AddWarning($"Client {sender.Name} had too many missions selected for location {location.Name}! Count was {NumberOfMissionsAtLocation(location)}. Deselecting extra missions.");
DebugConsole.AddWarning($"Client {sender.Name} had too many missions selected for location {location.DisplayName}! Count was {NumberOfMissionsAtLocation(location)}. Deselecting extra missions.");
foreach (Mission mission in currentLocation.SelectedMissions.Where(m => m.Locations[1] == location).Skip(Settings.TotalMaxMissionCount).ToList())
{
currentLocation.DeselectMission(mission);
@@ -161,16 +161,18 @@ namespace Barotrauma
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
#if CLIENT
case "gamemode": //legacy support
case "singleplayercampaign":
#if CLIENT
CrewManager = new CrewManager(true);
var campaign = SinglePlayerCampaign.Load(subElement);
campaign.LoadNewLevel();
GameMode = campaign;
InitOwnedSubs(submarineInfo, ownedSubmarines);
break;
#else
throw new Exception("The server cannot load a single player campaign.");
#endif
break;
case "multiplayercampaign":
CrewManager = new CrewManager(false);
var mpCampaign = MultiPlayerCampaign.LoadNew(subElement);
@@ -567,7 +569,7 @@ namespace Barotrauma
if (EndLocation != null && levelData != null)
{
GUI.AddMessage(levelData.Biome.DisplayName, Color.Lerp(Color.CadetBlue, Color.DarkRed, levelData.Difficulty / 100.0f), 5.0f, playSound: false);
GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Destination"), EndLocation.Name), Color.CadetBlue, playSound: false);
GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Destination"), EndLocation.DisplayName), Color.CadetBlue, playSound: false);
var missionsToShow = missions.Where(m => m.Prefab.ShowStartMessage);
if (missionsToShow.Count() > 1)
{
@@ -582,7 +584,7 @@ namespace Barotrauma
}
else
{
GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Location"), StartLocation.Name), Color.CadetBlue, playSound: false);
GUI.AddMessage(TextManager.AddPunctuation(':', TextManager.Get("Location"), StartLocation.DisplayName), Color.CadetBlue, playSound: false);
}
}
@@ -871,6 +873,7 @@ namespace Barotrauma
//Clear the grids to allow for garbage collection
Powered.Grids.Clear();
Powered.ChangedConnections.Clear();
try
{
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
@@ -20,6 +21,23 @@ namespace Barotrauma
AvailableCharacters.Remove(character);
}
public static int GetSalaryFor(IReadOnlyCollection<CharacterInfo> hires)
{
return hires.Sum(hire => GetSalaryFor(hire));
}
public static int GetSalaryFor(CharacterInfo hire)
{
IEnumerable<Character> crew = GameSession.GetSessionCrewCharacters(CharacterType.Both);
float multiplier = 0;
foreach (var character in crew)
{
multiplier += character?.Info?.GetSavedStatValueWithAll(StatTypes.HireCostMultiplier, hire.Job.Prefab.Identifier) ?? 0;
}
float finalMultiplier = 1f + MathF.Max(multiplier, -1f);
return (int)(hire.Salary * finalMultiplier);
}
public void GenerateCharacters(Location location, int amount)
{
AvailableCharacters.ForEach(c => c.Remove());