Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git into Regalis11-master

This commit is contained in:
Evil Factory
2021-12-15 14:45:31 -03:00
388 changed files with 12646 additions and 8136 deletions
@@ -110,7 +110,7 @@ namespace Barotrauma
public static bool CheatsEnabled;
private static readonly List<ColoredText> unsavedMessages = new List<ColoredText>();
private static readonly int messagesPerFile = 5000;
private static readonly int messagesPerFile = 800;
public const string SavePath = "ConsoleLogs";
public static void AssignOnExecute(string names, Action<string[]> onExecute)
@@ -219,7 +219,7 @@ namespace Barotrauma
try
{
#if CLIENT
SpawnItem(args, GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), Character.Controlled, out string errorMsg);
SpawnItem(args, Screen.Selected.Cam?.ScreenToWorld(PlayerInput.MousePosition) ?? PlayerInput.MousePosition, Character.Controlled, out string errorMsg);
#elif SERVER
SpawnItem(args, Vector2.Zero, null, out string errorMsg);
#endif
@@ -232,7 +232,7 @@ namespace Barotrauma
{
string errorMsg = "Failed to spawn an item. Arguments: \"" + string.Join(" ", args) + "\".";
ThrowError(errorMsg, e);
GameAnalyticsManager.AddErrorEventOnce("DebugConsole.SpawnItem:Error", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg + '\n' + e.Message + '\n' + e.StackTrace.CleanupStackTrace());
GameAnalyticsManager.AddErrorEventOnce("DebugConsole.SpawnItem:Error", GameAnalyticsManager.ErrorSeverity.Error, errorMsg + '\n' + e.Message + '\n' + e.StackTrace.CleanupStackTrace());
}
},
() =>
@@ -240,7 +240,10 @@ namespace Barotrauma
List<string> itemNames = new List<string>();
foreach (ItemPrefab itemPrefab in ItemPrefab.Prefabs)
{
itemNames.Add(itemPrefab.Name);
if (!itemNames.Contains(itemPrefab.Name))
{
itemNames.Add(itemPrefab.Name);
}
}
List<string> spawnPosParams = new List<string>() { "cursor", "inventory" };
@@ -251,8 +254,8 @@ namespace Barotrauma
return new string[][]
{
itemNames.ToArray(),
spawnPosParams.ToArray()
itemNames.ToArray(),
spawnPosParams.ToArray()
};
}, isCheat: true));
@@ -879,7 +882,7 @@ namespace Barotrauma
List<TalentTree> talentTrees = new List<TalentTree>();
if (args.Length == 0 || args[0].Equals("all", StringComparison.OrdinalIgnoreCase))
{
talentTrees.AddRange(TalentTree.JobTalentTrees.Values);
talentTrees.AddRange(TalentTree.JobTalentTrees);
}
else
{
@@ -1063,7 +1066,7 @@ namespace Barotrauma
},
null));
IEnumerable<object> TestLevels()
IEnumerable<CoroutineStatus> TestLevels()
{
SubmarineInfo selectedSub = null;
string subName = GameMain.Config.QuickStartSubmarineName;
@@ -1206,7 +1209,7 @@ namespace Barotrauma
catch (InvalidOperationException e)
{
string errorMsg = "Error while executing the fixhulls command.\n" + e.StackTrace.CleanupStackTrace();
GameAnalyticsManager.AddErrorEventOnce("DebugConsole.FixHulls", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
GameAnalyticsManager.AddErrorEventOnce("DebugConsole.FixHulls", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
}
}
}, null, true));
@@ -1411,6 +1414,29 @@ namespace Barotrauma
}
}, null, isCheat: true));
commands.Add(new Command("despawnnow", "despawnnow [character]: Immediately despawns the specified dead character. If the character argument is omitted, all dead characters are despawned.", (string[] args) =>
{
if (args.Length == 0)
{
foreach (Character c in Character.CharacterList.Where(c => c.IsDead).ToList())
{
c.DespawnNow();
}
}
else
{
Character character = FindMatchingCharacter(args);
character?.DespawnNow();
}
},
() =>
{
return new string[][]
{
Character.CharacterList.Where(c => c.IsDead).Select(c => c.Name).Distinct().ToArray()
};
}, isCheat: true));
commands.Add(new Command("setclientcharacter", "setclientcharacter [client name] [character name]: Gives the client control of the specified character.", null,
() =>
{
@@ -1506,6 +1532,11 @@ namespace Barotrauma
}
}, isCheat: true));
commands.Add(new Command("skipeventcooldown", "skipeventcooldown: Skips the currently active event cooldown and triggers pending monster spawns immediately.", args =>
{
GameMain.GameSession?.EventManager?.SkipEventCooldown();
}, isCheat: true));
commands.Add(new Command("ballastflora", "infectballast [options]: Infect ballasts and control its growth.", args =>
{
if (args.Length == 0)
@@ -1833,7 +1864,7 @@ namespace Barotrauma
#if CLIENT
activeQuestionText = null;
#endif
NewMessage(command, Color.White, true);
NewCommand(command);
//reset the variable before invoking the delegate because the method may need to activate another question
var temp = activeQuestionCallback;
activeQuestionCallback = null;
@@ -1849,7 +1880,7 @@ namespace Barotrauma
ThrowError("Failed to execute command \"" + command + "\"!");
GameAnalyticsManager.AddErrorEventOnce(
"DebugConsole.ExecuteCommand:LengthZero",
GameAnalyticsSDK.Net.EGAErrorSeverity.Error,
GameAnalyticsManager.ErrorSeverity.Error,
"Failed to execute command \"" + command + "\"!");
return;
}
@@ -1858,7 +1889,7 @@ namespace Barotrauma
if (!firstCommand.Equals("admin", StringComparison.OrdinalIgnoreCase))
{
NewMessage(command, Color.White, true);
NewCommand(command);
}
#if CLIENT
@@ -2138,7 +2169,7 @@ namespace Barotrauma
{
if (spawnPos != null)
{
if (Entity.Spawner == null)
if (Entity.Spawner == null || Entity.Spawner.Removed)
{
new Item(itemPrefab, spawnPos.Value, null);
}
@@ -2174,15 +2205,37 @@ namespace Barotrauma
}
}
public static void NewMessage(string msg, bool isCommand = false)
public static void ShowError(string msg, Color? color = null)
{
color ??= Color.Red;
NewMessage(msg, color.Value, isCommand: false, isError: true);
}
public static void NewCommand(string command, Color? color = null)
{
color ??= Color.White;
NewMessage(command, color.Value, isCommand: true, isError: false);
}
public static void NewMessage(string msg, Color? color = null, bool debugOnly = false)
{
color ??= Color.White;
if (debugOnly)
{
#if DEBUG
NewMessage(msg, color.Value, isCommand: false, isError: false);
#endif
}
else
{
NewMessage(msg, color.Value, isCommand: false, isError: false);
}
#if DEBUG
Console.WriteLine(msg);
#endif
NewMessage(msg, Color.White, isCommand);
}
public static void NewMessage(string msg, Color color, bool isCommand = false, bool isError = false)
private static void NewMessage(string msg, Color color, bool isCommand, bool isError)
{
if (string.IsNullOrEmpty(msg)) { return; }
@@ -2272,7 +2325,10 @@ namespace Barotrauma
public static void Log(string message)
{
if (GameSettings.VerboseLogging) NewMessage(message, Color.Gray);
if (GameSettings.VerboseLogging)
{
NewMessage(message, Color.Gray);
}
}
public static void ThrowError(string error, Exception e = null, bool createMessageBox = false, bool appendStackTrace = false)
@@ -2310,7 +2366,7 @@ namespace Barotrauma
}
#endif
NewMessage(error, Color.Red, isError: true);
ShowError(error);
}
public static void AddWarning(string warning)
@@ -2320,7 +2376,7 @@ namespace Barotrauma
}
#if CLIENT
private static IEnumerable<object> CreateMessageBox(string errorMsg)
private static IEnumerable<CoroutineStatus> CreateMessageBox(string errorMsg)
{
while (GUI.Style == null)
{