Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -337,7 +337,14 @@ namespace Barotrauma
|
||||
NewMessage("Enemy AI enabled", Color.Green);
|
||||
}, isCheat: true));
|
||||
|
||||
commands.Add(new Command("starttraitormissionimmediately", "starttraitormissionimmediately: Skip the initial delay of the traitor mission and start one immediately.", null));
|
||||
commands.Add(new Command("triggertraitorevent|starttraitoreventimmediately", "triggertraitorevent [eventidentifier]: Skip the initial delay of the traitor events and start one immediately. You can optionally specify which event to start (otherwise a random event is chosen).", null,
|
||||
() =>
|
||||
{
|
||||
return new string[][]
|
||||
{
|
||||
EventPrefab.Prefabs.Where(p => p is TraitorEventPrefab).Select(p => p.Identifier.ToString()).ToArray()
|
||||
};
|
||||
}));
|
||||
|
||||
commands.Add(new Command("botcount", "botcount [x]: Set the number of bots in the crew in multiplayer.", null));
|
||||
|
||||
@@ -645,7 +652,7 @@ namespace Barotrauma
|
||||
commands.Add(new Command("findentityids", "findentityids [entityname]", (string[] args) =>
|
||||
{
|
||||
if (args.Length == 0) { return; }
|
||||
foreach (MapEntity mapEntity in MapEntity.mapEntityList)
|
||||
foreach (MapEntity mapEntity in MapEntity.MapEntityList)
|
||||
{
|
||||
if (mapEntity.Name.Equals(args[0], StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -738,7 +745,7 @@ namespace Barotrauma
|
||||
commands.Add(new Command("revive", "revive [character name]: Bring the specified character back from the dead. If the name parameter is omitted, the controlled character will be revived.", (string[] args) =>
|
||||
{
|
||||
Character revivedCharacter = (args.Length == 0) ? Character.Controlled : FindMatchingCharacter(args);
|
||||
if (revivedCharacter == null) return;
|
||||
if (revivedCharacter == null) { return; }
|
||||
|
||||
revivedCharacter.Revive();
|
||||
#if SERVER
|
||||
@@ -746,7 +753,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
if (c.Character != revivedCharacter) continue;
|
||||
if (c.Character != revivedCharacter) { continue; }
|
||||
|
||||
//clients stop controlling the character when it dies, force control back
|
||||
GameMain.Server.SetClientCharacter(c, revivedCharacter);
|
||||
@@ -816,8 +823,12 @@ namespace Barotrauma
|
||||
if (GameMain.GameSession?.EventManager != null && args.Length > 0)
|
||||
{
|
||||
EventPrefab eventPrefab = eventPrefabs.Find(prefab => prefab.Identifier == args[0]);
|
||||
|
||||
if (eventPrefab != null)
|
||||
if (eventPrefab is TraitorEventPrefab)
|
||||
{
|
||||
ThrowError($"{eventPrefab.Identifier} is a traitor event. You need to use the 'triggertraitorevent' command to start it.");
|
||||
return;
|
||||
}
|
||||
else if (eventPrefab != null)
|
||||
{
|
||||
var newEvent = eventPrefab.CreateInstance();
|
||||
if (newEvent == null)
|
||||
@@ -825,8 +836,7 @@ namespace Barotrauma
|
||||
NewMessage($"Could not initialize event {args[0]} because level did not meet requirements");
|
||||
return;
|
||||
}
|
||||
GameMain.GameSession.EventManager.ActiveEvents.Add(newEvent);
|
||||
newEvent.Init();
|
||||
GameMain.GameSession.EventManager.ActivateEvent(newEvent);
|
||||
NewMessage($"Initialized event {eventPrefab.Identifier}", Color.Aqua);
|
||||
return;
|
||||
}
|
||||
@@ -845,9 +855,36 @@ namespace Barotrauma
|
||||
};
|
||||
}));
|
||||
|
||||
commands.Add(new Command("debugevent", "debugevent [identifier]: outputs debug info about a specific event that's currently active. Mainly intended for debugging events in multiplayer: in single player, the same information is available by enabling debugdraw.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.GameSession?.EventManager is EventManager eventManager && args.Length > 0)
|
||||
{
|
||||
var ev = eventManager.ActiveEvents.FirstOrDefault(ev => ev.Prefab?.Identifier == args[0]);
|
||||
if (ev == null)
|
||||
{
|
||||
ThrowError($"Event \"{args[0]}\" not found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
string info = ev.GetDebugInfo();
|
||||
#if SERVER
|
||||
//strip rich text tags
|
||||
RichTextData.GetRichTextData(info, out info);
|
||||
#endif
|
||||
NewMessage(info);
|
||||
}
|
||||
}
|
||||
}, isCheat: true, getValidArgs: () =>
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
GameMain.GameSession?.EventManager?.ActiveEvents.Select(ev => ev.Prefab.Identifier.ToString()).ToArray() ?? Array.Empty<string>()
|
||||
};
|
||||
}));
|
||||
|
||||
commands.Add(new Command("unlockmission", "unlockmission [identifier/tag]: Unlocks a mission in a random adjacent level.", (string[] args) =>
|
||||
{
|
||||
if (!(GameMain.GameSession?.GameMode is CampaignMode campaign))
|
||||
if (GameMain.GameSession?.GameMode is not CampaignMode campaign)
|
||||
{
|
||||
ThrowError("The unlockmission command is only usable in the campaign mode.");
|
||||
return;
|
||||
@@ -1152,6 +1189,33 @@ namespace Barotrauma
|
||||
throw new Exception("crash command issued");
|
||||
}));
|
||||
|
||||
commands.Add(new Command("listeditableproperties", "", (string[] args) =>
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string filename;
|
||||
#if CLIENT
|
||||
filename = "ItemComponent properties (client).txt";
|
||||
sb.AppendLine("Client-side ItemComponent properties:");
|
||||
#else
|
||||
filename = "ItemComponent properties (server).txt";
|
||||
sb.AppendLine("Server-side ItemComponent properties:");
|
||||
#endif
|
||||
var itemComponents = typeof(ItemComponent).Assembly.GetTypes().Where(type => type.IsSubclassOf(typeof(ItemComponent)));
|
||||
foreach (var ic in itemComponents.OrderBy(ic => ic.Name))
|
||||
{
|
||||
sb.AppendLine(ic.Name+":");
|
||||
foreach (var prop in ic.GetProperties())
|
||||
{
|
||||
if (prop.DeclaringType != ic) { continue; }
|
||||
if (prop.GetCustomAttributes(inherit: false).OfType<Editable>().Any())
|
||||
{
|
||||
sb.AppendLine(prop.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
File.WriteAllText(filename, sb.ToString());
|
||||
}));
|
||||
|
||||
commands.Add(new Command("fastforward", "fastforward [seconds]: Fast forwards the game by x seconds. Note that large numbers may cause a long freeze.", (string[] args) =>
|
||||
{
|
||||
float seconds = 0;
|
||||
@@ -1264,7 +1328,7 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
commands.Add(new Command("showreputation", "showreputation: List the current reputation values.", (string[] args) =>
|
||||
commands.Add(new Command("showreputation", "showreputation: List the current reputation values.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.GameSession?.GameMode is CampaignMode campaign)
|
||||
{
|
||||
@@ -1641,7 +1705,7 @@ namespace Barotrauma
|
||||
List<Pump> pumps = new List<Pump>();
|
||||
foreach (Item item in Submarine.MainSub.GetItems(true))
|
||||
{
|
||||
if (item.CurrentHull != null && item.HasTag("ballast") && item.GetComponent<Pump>() is { } pump)
|
||||
if (item.CurrentHull != null && item.HasTag(Tags.Ballast) && item.GetComponent<Pump>() is { } pump)
|
||||
{
|
||||
if (item.CurrentHull.BallastFlora != null) { continue; }
|
||||
pumps.Add(pump);
|
||||
@@ -2225,8 +2289,8 @@ namespace Barotrauma
|
||||
|
||||
string itemNameOrId = args[0].ToLowerInvariant();
|
||||
ItemPrefab itemPrefab =
|
||||
(MapEntityPrefab.Find(itemNameOrId, identifier: null, showErrorMessages: false) ??
|
||||
MapEntityPrefab.Find(null, identifier: itemNameOrId, showErrorMessages: false)) as ItemPrefab;
|
||||
(MapEntityPrefab.FindByName(itemNameOrId) ??
|
||||
MapEntityPrefab.FindByIdentifier(itemNameOrId.ToIdentifier())) as ItemPrefab;
|
||||
if (itemPrefab == null)
|
||||
{
|
||||
errorMsg = "Item \"" + itemNameOrId + "\" not found!";
|
||||
@@ -2321,6 +2385,19 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Throws the error in debug builds. In non-debug builds, logs it instead.
|
||||
/// Use for handling non-critical errors that shouldn't go unnoticed in debug builds (like warnings might), but which don't break the game and thus doesn't have to open the console.
|
||||
/// </summary>
|
||||
public static void AddSafeError(string error)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(error);
|
||||
#else
|
||||
DebugConsole.LogError(error);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void LogError(string msg, Color? color = null)
|
||||
{
|
||||
color ??= Color.Red;
|
||||
@@ -2494,7 +2571,16 @@ namespace Barotrauma
|
||||
|
||||
LogError(error);
|
||||
}
|
||||
|
||||
|
||||
public static void ThrowErrorAndLogToGA(string gaIdentifier, string errorMsg)
|
||||
{
|
||||
ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
gaIdentifier,
|
||||
GameAnalyticsManager.ErrorSeverity.Error,
|
||||
errorMsg);
|
||||
}
|
||||
|
||||
public static void AddWarning(string warning)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(warning);
|
||||
|
||||
Reference in New Issue
Block a user