Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -1,65 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.AI.Utility;
using Content.Server.AI.Utility.AiLogic;
using Content.Server.GameObjects.Components.Movement;
using Content.Server.GameObjects.EntitySystems.AI;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.AI
{
[AdminCommand(AdminFlags.Fun)]
public class AddAiCommand : IConsoleCommand
{
public string Command => "addai";
public string Description => "Add an ai component with a given processor to an entity.";
public string Help => "Usage: addai <entityId> <behaviorSet1> <behaviorSet2>..."
+ "\n entityID: Uid of entity to add the AiControllerComponent to. Open its VV menu to find this."
+ "\n behaviorSet: Name of a behaviorset to add to the component on initialize.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if(args.Length < 1)
{
shell.WriteLine("Wrong number of args.");
return;
}
var entId = new EntityUid(int.Parse(args[0]));
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(entId, out var ent))
{
shell.WriteLine($"Unable to find entity with uid {entId}");
return;
}
if (ent.HasComponent<AiControllerComponent>())
{
shell.WriteLine("Entity already has an AI component.");
return;
}
// TODO: IMover refffaaccctttooorrr
if (ent.HasComponent<IMoverComponent>())
{
ent.RemoveComponent<IMoverComponent>();
}
var comp = ent.AddComponent<UtilityAi>();
var behaviorManager = IoCManager.Resolve<INpcBehaviorManager>();
for (var i = 1; i < args.Length; i++)
{
var bSet = args[i];
behaviorManager.AddBehaviorSet(comp, bSet, false);
}
behaviorManager.RebuildActions(comp);
shell.WriteLine("AI component added.");
}
}
}

View File

@@ -1,96 +0,0 @@
using System;
using System.Text;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.AI;
using Content.Server.GameObjects.EntitySystems.AI;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.Commands.AI
{
[AdminCommand(AdminFlags.Fun)]
public sealed class FactionCommand : IConsoleCommand
{
public string Command => "factions";
public string Description => "Update / list factional relationships for NPCs.";
public string Help => "faction <source> <friendly/hostile> target\n" +
"faction <source> list: hostile factions";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length == 0)
{
var result = new StringBuilder();
foreach (Faction value in Enum.GetValues(typeof(Faction)))
{
if (value == Faction.None)
continue;
result.Append(value + "\n");
}
shell.WriteLine(result.ToString());
return;
}
if (args.Length < 2)
{
shell.WriteLine(Loc.GetString("Need more args"));
return;
}
if (!Enum.TryParse(args[0], true, out Faction faction))
{
shell.WriteLine(Loc.GetString("Invalid faction"));
return;
}
Faction targetFaction;
switch (args[1])
{
case "friendly":
if (args.Length < 3)
{
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
return;
}
if (!Enum.TryParse(args[2], true, out targetFaction))
{
shell.WriteLine(Loc.GetString("Invalid target faction"));
return;
}
EntitySystem.Get<AiFactionTagSystem>().MakeFriendly(faction, targetFaction);
shell.WriteLine(Loc.GetString("Command successful"));
break;
case "hostile":
if (args.Length < 3)
{
shell.WriteLine(Loc.GetString("Need to supply a target faction"));
return;
}
if (!Enum.TryParse(args[2], true, out targetFaction))
{
shell.WriteLine(Loc.GetString("Invalid target faction"));
return;
}
EntitySystem.Get<AiFactionTagSystem>().MakeHostile(faction, targetFaction);
shell.WriteLine(Loc.GetString("Command successful"));
break;
case "list":
shell.WriteLine(EntitySystem.Get<AiFactionTagSystem>().GetHostileFactions(faction).ToString());
break;
default:
shell.WriteLine(Loc.GetString("Unknown faction arg"));
break;
}
return;
}
}
}

View File

@@ -1,66 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.Server.Commands.Actions
{
[AdminCommand(AdminFlags.Debug)]
public sealed class CooldownAction : IConsoleCommand
{
public string Command => "coolaction";
public string Description => "Sets a cooldown on an action for a player, defaulting to current player";
public string Help => "coolaction <actionType> <seconds> <name or userID, omit for current player>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null) return;
var attachedEntity = player.AttachedEntity;
if (args.Length > 2)
{
var target = args[2];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
}
if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{
shell.WriteLine("user has no actions component");
return;
}
var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{
shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw);
return;
}
var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action))
{
shell.WriteLine("unrecognized actionType " + actionType);
return;
}
var cooldownStart = IoCManager.Resolve<IGameTiming>().CurTime;
if (!uint.TryParse(args[1], out var seconds))
{
shell.WriteLine("cannot parse seconds: " + args[1]);
return;
}
var cooldownEnd = cooldownStart.Add(TimeSpan.FromSeconds(seconds));
actionsComponent.Cooldown(action.ActionType, (cooldownStart, cooldownEnd));
}
}
}

View File

@@ -1,53 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Actions
{
[AdminCommand(AdminFlags.Debug)]
public sealed class GrantAction : IConsoleCommand
{
public string Command => "grantaction";
public string Description => "Grants an action to a player, defaulting to current player";
public string Help => "grantaction <actionType> <name or userID, omit for current player>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null) return;
var attachedEntity = player.AttachedEntity;
if (args.Length > 1)
{
var target = args[1];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
}
if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{
shell.WriteLine("user has no actions component");
return;
}
var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{
shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw);
return;
}
var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action))
{
shell.WriteLine("unrecognized actionType " + actionType);
return;
}
actionsComponent.Grant(action.ActionType);
}
}
}

View File

@@ -1,54 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Actions
{
[AdminCommand(AdminFlags.Debug)]
public sealed class RevokeAction : IConsoleCommand
{
public string Command => "revokeaction";
public string Description => "Revokes an action from a player, defaulting to current player";
public string Help => "revokeaction <actionType> <name or userID, omit for current player>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null) return;
var attachedEntity = player.AttachedEntity;
if (args.Length > 1)
{
var target = args[1];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
}
if (attachedEntity == null) return;
if (!attachedEntity.TryGetComponent(out ServerActionsComponent? actionsComponent))
{
shell.WriteLine("user has no actions component");
return;
}
var actionTypeRaw = args[0];
if (!Enum.TryParse<ActionType>(actionTypeRaw, out var actionType))
{
shell.WriteLine("unrecognized ActionType enum value, please" +
" ensure you used correct casing: " + actionTypeRaw);
return;
}
var actionMgr = IoCManager.Resolve<ActionManager>();
if (!actionMgr.TryGet(actionType, out var action))
{
shell.WriteLine("unrecognized actionType " + actionType);
return;
}
actionsComponent.Revoke(action.ActionType);
}
}
}

View File

@@ -1,54 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Administration;
using Content.Shared.Alert;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Alerts
{
[AdminCommand(AdminFlags.Debug)]
public sealed class ClearAlert : IConsoleCommand
{
public string Command => "clearalert";
public string Description => "Clears an alert for a player, defaulting to current player";
public string Help => "clearalert <alertType> <name or userID, omit for current player>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player?.AttachedEntity == null)
{
shell.WriteLine("You don't have an entity.");
return;
}
var attachedEntity = player.AttachedEntity;
if (args.Length > 1)
{
var target = args[1];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
}
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent))
{
shell.WriteLine("user has no alerts component");
return;
}
var alertType = args[0];
var alertMgr = IoCManager.Resolve<AlertManager>();
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
{
shell.WriteLine("unrecognized alertType " + alertType);
return;
}
alertsComponent.ClearAlert(alert.AlertType);
}
}
}

View File

@@ -1,65 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.Administration;
using Content.Shared.Alert;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Alerts
{
[AdminCommand(AdminFlags.Debug)]
public sealed class ShowAlert : IConsoleCommand
{
public string Command => "showalert";
public string Description => "Shows an alert for a player, defaulting to current player";
public string Help => "showalert <alertType> <severity, -1 if no severity> <name or userID, omit for current player>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("You cannot run this command from the server.");
return;
}
var attachedEntity = player.AttachedEntity;
if (attachedEntity == null)
{
shell.WriteLine("You don't have an entity.");
return;
}
if (args.Length > 2)
{
var target = args[2];
if (!CommandUtils.TryGetAttachedEntityByUsernameOrId(shell, target, player, out attachedEntity)) return;
}
if (!attachedEntity.TryGetComponent(out ServerAlertsComponent? alertsComponent))
{
shell.WriteLine("user has no alerts component");
return;
}
var alertType = args[0];
var severity = args[1];
var alertMgr = IoCManager.Resolve<AlertManager>();
if (!alertMgr.TryGet(Enum.Parse<AlertType>(alertType), out var alert))
{
shell.WriteLine("unrecognized alertType " + alertType);
return;
}
if (!short.TryParse(severity, out var sevint))
{
shell.WriteLine("invalid severity " + sevint);
return;
}
alertsComponent.ShowAlert(alert.AlertType, sevint == -1 ? (short?) null : sevint);
}
}
}

View File

@@ -1,41 +0,0 @@
using System;
using System.Text;
using Content.Server.Administration;
using Content.Server.Interfaces.Chat;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Fun)]
public class AnnounceCommand : IConsoleCommand
{
public string Command => "announce";
public string Description => "Send an in-game announcement.";
public string Help => $"{Command} <sender> <message> or {Command} <message> to send announcement as centcomm.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var chat = IoCManager.Resolve<IChatManager>();
if (args.Length == 0)
{
shell.WriteError("Not enough arguments! Need at least 1.");
return;
}
if (args.Length == 1)
{
chat.DispatchStationAnnouncement(args[0]);
shell.WriteLine("Sent!");
return;
}
if (args.Length < 2) return;
var message = string.Join(' ', new ArraySegment<string>(args, 1, args.Length-1));
chat.DispatchStationAnnouncement(message, args[0]);
shell.WriteLine("Sent!");
}
}
}

View File

@@ -1,106 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using static Content.Server.GameObjects.Components.Body.Part.BodyPartComponent;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Fun)]
public class AttachBodyPartCommand : IConsoleCommand
{
public string Command => "attachbodypart";
public string Description => "Attaches a body part to you or someone else.";
public string Help => $"{Command} <partEntityUid> / {Command} <entityUid> <partEntityUid>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var entityManager = IoCManager.Resolve<IEntityManager>();
IEntity entity;
EntityUid partUid;
switch (args.Length)
{
case 1:
if (player == null)
{
shell.WriteLine($"You need to specify an entity to attach the part to if you aren't a player.\n{Help}");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine($"You need to specify an entity to attach the part to if you aren't attached to an entity.\n{Help}");
return;
}
if (!EntityUid.TryParse(args[0], out partUid))
{
shell.WriteLine($"{args[0]} is not a valid entity uid.");
return;
}
entity = player.AttachedEntity;
break;
case 2:
if (!EntityUid.TryParse(args[0], out var entityUid))
{
shell.WriteLine($"{args[0]} is not a valid entity uid.");
return;
}
if (!EntityUid.TryParse(args[1], out partUid))
{
shell.WriteLine($"{args[1]} is not a valid entity uid.");
return;
}
if (!entityManager.TryGetEntity(entityUid, out var tempEntity))
{
shell.WriteLine($"{entityUid} is not a valid entity.");
return;
}
entity = tempEntity;
break;
default:
shell.WriteLine(Help);
return;
}
if (!entity.TryGetComponent(out IBody? body))
{
shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(IBody)} component.");
return;
}
if (!entityManager.TryGetEntity(partUid, out var partEntity))
{
shell.WriteLine($"{partUid} is not a valid entity.");
return;
}
if (!partEntity.TryGetComponent(out IBodyPart? part))
{
shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(IBodyPart)} component.");
return;
}
if (body.HasPart(part))
{
shell.WriteLine($"Body part {partEntity.Name} with uid {partEntity.Uid} is already attached to entity {entity.Name} with uid {entity.Uid}");
return;
}
body.SetPart($"{nameof(AttachBodyPartVerb)}-{partEntity.Uid}", part);
}
}
}

View File

@@ -1,146 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.Commands.Body
{
[AdminCommand(AdminFlags.Fun)]
class AddHandCommand : IConsoleCommand
{
public const string DefaultHandPrototype = "LeftHandHuman";
public string Command => "addhand";
public string Description => "Adds a hand to your entity.";
public string Help => $"Usage: {Command} <entityUid> <handPrototypeId> / {Command} <entityUid> / {Command} <handPrototypeId> / {Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (args.Length > 1)
{
shell.WriteLine(Help);
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
IEntity entity;
IEntity hand;
switch (args.Length)
{
case 0:
{
if (player == null)
{
shell.WriteLine("Only a player can run this command without arguments.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("You don't have an entity to add a hand to.");
return;
}
entity = player.AttachedEntity;
hand = entityManager.SpawnEntity(DefaultHandPrototype, entity.Transform.Coordinates);
break;
}
case 1:
{
if (EntityUid.TryParse(args[0], out var uid))
{
if (!entityManager.TryGetEntity(uid, out var parsedEntity))
{
shell.WriteLine($"No entity found with uid {uid}");
return;
}
entity = parsedEntity;
hand = entityManager.SpawnEntity(DefaultHandPrototype, entity.Transform.Coordinates);
}
else
{
if (player == null)
{
shell.WriteLine("You must specify an entity to add a hand to when using this command from the server terminal.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("You don't have an entity to add a hand to.");
return;
}
entity = player.AttachedEntity;
hand = entityManager.SpawnEntity(args[0], entity.Transform.Coordinates);
}
break;
}
case 2:
{
if (!EntityUid.TryParse(args[0], out var uid))
{
shell.WriteLine($"{args[0]} is not a valid entity uid.");
return;
}
if (!entityManager.TryGetEntity(uid, out var parsedEntity))
{
shell.WriteLine($"No entity exists with uid {uid}.");
return;
}
entity = parsedEntity;
if (!prototypeManager.HasIndex<EntityPrototype>(args[1]))
{
shell.WriteLine($"No hand entity exists with id {args[1]}.");
return;
}
hand = entityManager.SpawnEntity(args[1], entity.Transform.Coordinates);
break;
}
default:
{
shell.WriteLine(Help);
return;
}
}
if (!entity.TryGetComponent(out IBody? body))
{
var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.WriteLine(text);
return;
}
if (!hand.TryGetComponent(out IBodyPart? part))
{
shell.WriteLine($"Hand entity {hand} does not have a {nameof(IBodyPart)} component.");
return;
}
var slot = part.GetHashCode().ToString();
body.SetPart(slot, part);
shell.WriteLine($"Added hand to entity {entity.Name}");
}
}
}

View File

@@ -1,65 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Random;
namespace Content.Server.Commands.Body
{
[AdminCommand(AdminFlags.Fun)]
class DestroyMechanismCommand : IConsoleCommand
{
public string Command => "destroymechanism";
public string Description => "Destroys a mechanism from your entity";
public string Help => $"Usage: {Command} <mechanism>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("Only a player can run this command.");
return;
}
if (args.Length == 0)
{
shell.WriteLine(Help);
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("You have no entity.");
return;
}
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
{
var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.WriteLine(text);
return;
}
var mechanismName = string.Join(" ", args).ToLowerInvariant();
foreach (var (part, _) in body.Parts)
foreach (var mechanism in part.Mechanisms)
{
if (mechanism.Name.ToLowerInvariant() == mechanismName)
{
part.DeleteMechanism(mechanism);
shell.WriteLine($"Mechanism with name {mechanismName} has been destroyed.");
return;
}
}
shell.WriteLine($"No mechanism was found with name {mechanismName}.");
}
}
}

View File

@@ -1,57 +0,0 @@
#nullable enable
using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Random;
namespace Content.Server.Commands.Body
{
[AdminCommand(AdminFlags.Fun)]
class RemoveHandCommand : IConsoleCommand
{
public string Command => "removehand";
public string Description => "Removes a hand from your entity.";
public string Help => $"Usage: {Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("Only a player can run this command.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("You have no entity.");
return;
}
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
{
var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.WriteLine(text);
return;
}
var hand = body.GetPartsOfType(BodyPartType.Hand).FirstOrDefault();
if (hand == null)
{
shell.WriteLine("You have no hands.");
}
else
{
body.RemovePart(hand);
}
}
}
}

View File

@@ -1,39 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Interfaces.Chat;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat
{
[AdminCommand(AdminFlags.Admin)]
internal class AdminChatCommand : IConsoleCommand
{
public string Command => "asay";
public string Description => "Send chat messages to the private admin chat channel.";
public string Help => "asay <text>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = (IPlayerSession?) shell.Player;
if (player == null)
{
shell.WriteError("You can't run this command locally.");
return;
}
if (args.Length < 1)
return;
var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;
var chat = IoCManager.Resolve<IChatManager>();
chat.SendAdminChat(player, message);
}
}
}

View File

@@ -1,56 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Interfaces.Chat;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat
{
[AnyCommand]
internal class MeCommand : IConsoleCommand
{
public string Command => "me";
public string Description => "Perform an action.";
public string Help => "me <text>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("This command cannot be run from the server.");
return;
}
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
return;
if (args.Length < 1)
return;
var action = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(action))
return;
var chat = IoCManager.Resolve<IChatManager>();
var mindComponent = player.ContentData()?.Mind;
if (mindComponent == null)
{
shell.WriteError("You don't have a mind!");
return;
}
if (mindComponent.OwnedEntity == null)
{
shell.WriteError("You don't have an entity!");
return;
}
chat.EntityMe(mindComponent.OwnedEntity, action);
}
}
}

View File

@@ -1,38 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Interfaces.Chat;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat
{
[AnyCommand]
internal class OOCCommand : IConsoleCommand
{
public string Command => "ooc";
public string Description => "Send Out Of Character chat messages.";
public string Help => "ooc <text>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = (IPlayerSession?) shell.Player;
if (player == null)
{
shell.WriteError("You can't run this command locally.");
return;
}
if (args.Length < 1)
return;
var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;
var chat = IoCManager.Resolve<IChatManager>();
chat.SendOOC(player, message);
}
}
}

View File

@@ -1,71 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.Chat;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Chat
{
[AnyCommand]
internal class SayCommand : IConsoleCommand
{
public string Command => "say";
public string Description => "Send chat messages to the local channel or a specified radio channel.";
public string Help => "say <text>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("This command cannot be run from the server.");
return;
}
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
return;
if (args.Length < 1)
return;
var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;
var chat = IoCManager.Resolve<IChatManager>();
var playerEntity = player.AttachedEntity;
if (playerEntity == null)
{
shell.WriteLine("You don't have an entity!");
return;
}
if (playerEntity.HasComponent<GhostComponent>())
chat.SendDeadChat(player, message);
else
{
var mindComponent = player.ContentData()?.Mind;
if (mindComponent == null)
{
shell.WriteError("You don't have a mind!");
return;
}
if (mindComponent.OwnedEntity == null)
{
shell.WriteError("You don't have an entity!");
return;
}
chat.EntitySay(mindComponent.OwnedEntity, message);
}
}
}
}

View File

@@ -1,132 +0,0 @@
#nullable enable
using System;
using System.Linq;
using Content.Server.Administration;
using Content.Server.Commands.Observer;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Players;
using Content.Server.Utility;
using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Interfaces;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Commands.Chat
{
[AnyCommand]
internal class SuicideCommand : IConsoleCommand
{
public string Command => "suicide";
public string Description => "Commits suicide";
public string Help => "The suicide command gives you a quick way out of a round while remaining in-character.\n" +
"The method varies, first it will attempt to use the held item in your active hand.\n" +
"If that fails, it will attempt to use an object in the environment.\n" +
"Finally, if neither of the above worked, you will die by biting your tongue.";
private void DealDamage(ISuicideAct suicide, IChatManager chat, IDamageableComponent damageableComponent, IEntity source, IEntity target)
{
var kind = suicide.Suicide(target, chat);
if (kind != SuicideKind.Special)
{
damageableComponent.SetDamage(kind switch
{
SuicideKind.Blunt => DamageType.Blunt,
SuicideKind.Slash => DamageType.Slash,
SuicideKind.Piercing => DamageType.Piercing,
SuicideKind.Heat => DamageType.Heat,
SuicideKind.Shock => DamageType.Shock,
SuicideKind.Cold => DamageType.Cold,
SuicideKind.Poison => DamageType.Poison,
SuicideKind.Radiation => DamageType.Radiation,
SuicideKind.Asphyxiation => DamageType.Asphyxiation,
SuicideKind.Bloodloss => DamageType.Bloodloss,
_ => DamageType.Blunt
},
200, source);
}
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("You cannot run this command from the server.");
return;
}
if (player.Status != SessionStatus.InGame)
return;
var chat = IoCManager.Resolve<IChatManager>();
var mind = player.ContentData()?.Mind;
var owner = mind?.OwnedComponent?.Owner;
// This check also proves mind not-null for at the end when the mob is ghosted.
if (owner == null)
{
shell.WriteLine("You don't have a mind!");
return;
}
var dmgComponent = owner.GetComponent<IDamageableComponent>();
//TODO: needs to check if the mob is actually alive
//TODO: maybe set a suicided flag to prevent resurrection?
// Held item suicide
var handsComponent = owner.GetComponent<HandsComponent>();
var itemComponent = handsComponent.GetActiveHand;
if (itemComponent != null)
{
var suicide = itemComponent.Owner.GetAllComponents<ISuicideAct>().FirstOrDefault();
if (suicide != null)
{
DealDamage(suicide, chat, dmgComponent, itemComponent.Owner, owner);
return;
}
}
// Get all entities in range of the suicider
var entities = IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(owner, 1, true).ToArray();
if (entities.Length > 0)
{
foreach (var entity in entities)
{
if (entity.HasComponent<ItemComponent>())
continue;
var suicide = entity.GetAllComponents<ISuicideAct>().FirstOrDefault();
if (suicide != null)
{
DealDamage(suicide, chat, dmgComponent, entity, owner);
return;
}
}
}
// Default suicide, bite your tongue
var othersMessage = Loc.GetString("{0:theName} is attempting to bite {0:their} own tongue!", owner);
owner.PopupMessageOtherClients(othersMessage);
var selfMessage = Loc.GetString("You attempt to bite your own tongue!");
owner.PopupMessage(selfMessage);
dmgComponent.SetDamage(DamageType.Piercing, 200, owner);
// Prevent the player from returning to the body.
// Note that mind cannot be null because otherwise owner would be null.
IoCManager.Resolve<IGameTicker>().OnGhostAttempt(mind!, false);
}
}
}

View File

@@ -1,28 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands.Damage
{
[AdminCommand(AdminFlags.Fun)]
public class AddDamageFlagCommand : DamageFlagCommand
{
public override string Command => "adddamageflag";
public override string Description => "Adds a damage flag to your entity or another.";
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (!TryGetEntity(shell, player, args, true, out var entity, out var flag, out var damageable))
{
return;
}
damageable.AddFlag(flag);
shell.WriteLine($"Added damage flag {flag} to entity {entity.Name}");
}
}
}

View File

@@ -1,115 +0,0 @@
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Damage
{
public abstract class DamageFlagCommand : IConsoleCommand
{
public abstract string Command { get; }
public abstract string Description { get; }
public abstract string Help { get; }
public abstract void Execute(IConsoleShell shell, string argStr, string[] args);
public bool TryGetEntity(
IConsoleShell shell,
IPlayerSession? player,
string[] args,
bool adding,
[NotNullWhen(true)] out IEntity? entity,
out DamageFlag flag,
[NotNullWhen(true)] out IDamageableComponent? damageable)
{
entity = null;
flag = DamageFlag.None;
damageable = null;
IEntity? parsedEntity;
DamageFlag parsedFlag;
IDamageableComponent? parsedDamageable;
switch (args.Length)
{
case 1:
{
if (player == null)
{
shell.WriteLine("An entity needs to be specified when the command isn't used by a player.");
return false;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
return false;
}
if (!Enum.TryParse(args[0], true, out parsedFlag))
{
shell.WriteLine($"{args[0]} is not a valid damage flag.");
return false;
}
parsedEntity = player.AttachedEntity;
flag = parsedFlag;
break;
}
case 2:
{
if (!EntityUid.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} isn't a valid entity id.");
return false;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out parsedEntity))
{
shell.WriteLine($"No entity found with id {id}.");
return false;
}
if (!Enum.TryParse(args[1], true, out parsedFlag))
{
shell.WriteLine($"{args[1]} is not a valid damage flag.");
return false;
}
break;
}
default:
shell.WriteLine(Help);
return false;
}
if (!parsedEntity.TryGetComponent(out parsedDamageable))
{
shell.WriteLine($"Entity {parsedEntity.Name} doesn't have a {nameof(IDamageableComponent)}");
return false;
}
if (parsedDamageable.HasFlag(parsedFlag) && adding)
{
shell.WriteLine($"Entity {parsedEntity.Name} already has damage flag {parsedFlag}.");
return false;
}
else if (!parsedDamageable.HasFlag(parsedFlag) && !adding)
{
shell.WriteLine($"Entity {parsedEntity.Name} doesn't have damage flag {parsedFlag}.");
return false;
}
entity = parsedEntity;
flag = parsedFlag;
damageable = parsedDamageable;
return true;
}
}
}

View File

@@ -1,70 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Damage
{
[AdminCommand(AdminFlags.Admin)]
public class GodModeCommand : IConsoleCommand
{
public string Command => "godmode";
public string Description => "Makes your entity or another invulnerable to almost anything. May have irreversible changes.";
public string Help => $"Usage: {Command} / {Command} <entityUid>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
IEntity entity;
switch (args.Length)
{
case 0:
if (player == null)
{
shell.WriteLine("An entity needs to be specified when the command isn't used by a player.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("An entity needs to be specified when you aren't attached to an entity.");
return;
}
entity = player.AttachedEntity;
break;
case 1:
if (!EntityUid.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} isn't a valid entity id.");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var parsedEntity))
{
shell.WriteLine($"No entity found with id {id}.");
return;
}
entity = parsedEntity;
break;
default:
shell.WriteLine(Help);
return;
}
var godmodeSystem = EntitySystem.Get<GodmodeSystem>();
var enabled = godmodeSystem.ToggleGodmode(entity);
shell.WriteLine(enabled
? $"Enabled godmode for entity {entity.Name} with id {entity.Uid}"
: $"Disabled godmode for entity {entity.Name} with id {entity.Uid}");
}
}
}

View File

@@ -1,28 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands.Damage
{
[AdminCommand(AdminFlags.Fun)]
public class RemoveDamageFlagCommand : DamageFlagCommand
{
public override string Command => "removedamageflag";
public override string Description => "Removes a damage flag from your entity or another.";
public override string Help => $"Usage: {Command} <flag> / {Command} <entityUid> <flag>";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (!TryGetEntity(shell, player, args, false, out var entity, out var flag, out var damageable))
{
return;
}
damageable.RemoveFlag(flag);
shell.WriteLine($"Removed damage flag {flag} from entity {entity.Name}");
}
}
}

View File

@@ -1,57 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Disposal;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Content.Server.Commands.Disposal
{
[AdminCommand(AdminFlags.Debug)]
public class TubeConnectionsCommand : IConsoleCommand
{
public string Command => "tubeconnections";
public string Description => Loc.GetString("Shows all the directions that a tube can connect in.");
public string Help => $"Usage: {Command} <entityUid>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player?.AttachedEntity == null)
{
shell.WriteLine(Loc.GetString("Only players can use this command"));
return;
}
if (args.Length < 1)
{
shell.WriteLine(Help);
return;
}
if (!EntityUid.TryParse(args[0], out var id))
{
shell.WriteLine(Loc.GetString("{0} isn't a valid entity uid", args[0]));
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var entity))
{
shell.WriteLine(Loc.GetString("No entity exists with uid {0}", id));
return;
}
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube))
{
shell.WriteLine(Loc.GetString("Entity with uid {0} doesn't have a {1} component", id, nameof(IDisposalTubeComponent)));
return;
}
tube.PopupDirections(player.AttachedEntity);
}
}
}

View File

@@ -1,35 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Power;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Admin)]
public class DrainAllBatteriesCommand : IConsoleCommand
{
public string Command => "drainallbatteries";
public string Description => "Drains *all* batteries. Useful to make sure that an engine provides enough power to sustain the station.";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
{
shell.WriteLine($"Invalid amount of arguments: {args.Length}.\n{Help}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(BatteryComponent))))
{
ent.GetComponent<BatteryComponent>().CurrentCharge = 0;
}
shell.WriteLine("Done!");
}
}
}

View File

@@ -1,42 +0,0 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Entities
{
[AdminCommand(AdminFlags.Spawn)]
public class DeleteEntityCommand : IConsoleCommand
{
public string Command => "deleteentity";
public string Description => "Deletes an entity with the given id.";
public string Help => $"Usage: {Command} <id>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine($"Invalid amount of arguments.\n{Help}");
return;
}
if (!EntityUid.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid entity id.");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(id, out var entity))
{
shell.WriteLine($"No entity found with id {id}.");
return;
}
entity.Delete();
shell.WriteLine($"Deleted entity with id {id}.");
}
}
}

View File

@@ -1,59 +0,0 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Prototypes.EntityList;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.EntityList
{
[AdminCommand(AdminFlags.Spawn)]
public class SpawnEntityListCommand : IConsoleCommand
{
public string Command => "spawnentitylist";
public string Description => "Spawns a list of entities around you";
public string Help => $"Usage: {Command} <entityListPrototypeId>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError($"Invalid arguments.\n{Help}");
return;
}
if (shell.Player is not IPlayerSession player)
{
shell.WriteError("You must be a player to run this command.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteError("You must have an entity to run this command.");
return;
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
if (!prototypeManager.TryIndex(args[0], out EntityListPrototype? prototype))
{
shell.WriteError($"No {nameof(EntityListPrototype)} found with id {args[0]}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var i = 0;
foreach (var entity in prototype.Entities(prototypeManager))
{
entityManager.SpawnEntity(entity.ID, player.AttachedEntity.Transform.Coordinates);
i++;
}
shell.WriteLine($"Spawned {i} entities.");
}
}
}

View File

@@ -1,71 +0,0 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Mapping)]
public class FindEntitiesWithComponents : IConsoleCommand
{
public string Command => "findentitieswithcomponents";
public string Description => "Finds entities with all of the specified components.";
public string Help => $"{Command} <componentName1> <componentName2>...";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length == 0)
{
shell.WriteLine($"Invalid amount of arguments: {args.Length}.\n{Help}");
return;
}
var components = new List<Type>();
var componentFactory = IoCManager.Resolve<IComponentFactory>();
var invalidArgs = new List<string>();
foreach (var arg in args)
{
if (!componentFactory.TryGetRegistration(arg, out var registration))
{
invalidArgs.Add(arg);
continue;
}
components.Add(registration.Type);
}
if (invalidArgs.Count > 0)
{
shell.WriteLine($"No component found for component names: {string.Join(", ", invalidArgs)}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
var query = new MultipleTypeEntityQuery(components);
var entityIds = new HashSet<string>();
foreach (var entity in entityManager.GetEntities(query))
{
if (entity.Prototype == null)
{
continue;
}
entityIds.Add(entity.Prototype.ID);
}
if (entityIds.Count == 0)
{
shell.WriteLine($"No entities found with components {string.Join(", ", args)}.");
return;
}
shell.WriteLine($"{entityIds.Count} entities found:\n{string.Join("\n", entityIds)}");
}
}
}

View File

@@ -1,53 +0,0 @@
using System;
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class DelayStartCommand : IConsoleCommand
{
public string Command => "delaystart";
public string Description => "Delays the round start.";
public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
if (args.Length == 0)
{
var paused = ticker.TogglePause();
shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
return;
}
if (args.Length != 1)
{
shell.WriteLine("Need zero or one arguments.");
return;
}
if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
{
shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
return;
}
var time = TimeSpan.FromSeconds(seconds);
if (!ticker.DelayStart(time))
{
shell.WriteLine("An unknown error has occurred.");
}
}
}
}

View File

@@ -1,31 +0,0 @@
using System;
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class EndRoundCommand : IConsoleCommand
{
public string Command => "endround";
public string Description => "Ends the round and moves the server to PostRound.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.InRound)
{
shell.WriteLine("This can only be executed while the game is in a round.");
return;
}
ticker.EndRound();
}
}
}

View File

@@ -1,96 +0,0 @@
using Content.Server.Administration;
using Content.Shared.GameObjects.Components;
using Content.Server.GameObjects.Components;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Mapping)]
class FixRotationsCommand : IConsoleCommand
{
// ReSharper disable once StringLiteralTypo
public string Command => "fixrotations";
public string Description => "Sets the rotation of all occluders, low walls and windows to south.";
public string Help => $"Usage: {Command} <gridId> | {Command}";
public void Execute(IConsoleShell shell, string argsOther, string[] args)
{
var player = shell.Player as IPlayerSession;
GridId gridId;
switch (args.Length)
{
case 0:
if (player?.AttachedEntity == null)
{
shell.WriteLine("Only a player can run this command.");
return;
}
gridId = player.AttachedEntity.Transform.GridID;
break;
case 1:
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
gridId = new GridId(id);
break;
default:
shell.WriteLine(Help);
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
{
shell.WriteLine($"No grid exists with id {gridId}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
var changed = 0;
foreach (var childUid in gridEntity.Transform.ChildEntityUids)
{
if (!entityManager.TryGetEntity(childUid, out var childEntity))
{
continue;
}
var valid = false;
valid |= childEntity.HasComponent<OccluderComponent>();
valid |= childEntity.HasComponent<SharedCanBuildWindowOnTopComponent>();
valid |= childEntity.HasComponent<WindowComponent>();
if (!valid)
{
continue;
}
if (childEntity.Transform.LocalRotation != Angle.Zero)
{
childEntity.Transform.LocalRotation = Angle.Zero;
changed++;
}
}
shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect.");
}
}
}

View File

@@ -1,43 +0,0 @@
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class ForcePresetCommand : IConsoleCommand
{
public string Command => "forcepreset";
public string Description => "Forces a specific game preset to start for the current lobby.";
public string Help => $"Usage: {Command} <preset>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var name = args[0];
if (!ticker.TryGetPreset(name, out var type))
{
shell.WriteLine($"No preset exists with name {name}.");
return;
}
ticker.SetStartPreset(type, true);
shell.WriteLine($"Forced the game to start with preset {name}.");
}
}
}

View File

@@ -1,48 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Content.Shared;
using Content.Shared.Administration;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
public class GoLobbyCommand : IConsoleCommand
{
public string Command => "golobby";
public string Description => "Enables the lobby and restarts the round.";
public string Help => $"Usage: {Command} / {Command} <preset>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
Type? preset = null;
var presetName = string.Join(" ", args);
var ticker = IoCManager.Resolve<IGameTicker>();
if (args.Length > 0)
{
if (!ticker.TryGetPreset(presetName, out preset))
{
shell.WriteLine($"No preset found with name {presetName}");
return;
}
}
var config = IoCManager.Resolve<IConfigurationManager>();
config.SetCVar(CCVars.GameLobbyEnabled, true);
ticker.RestartRound();
if (preset != null)
{
ticker.SetStartPreset(preset);
}
shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
}
}
}

View File

@@ -1,59 +0,0 @@
using System.Collections.Generic;
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.GameTicking
{
[AnyCommand]
class JoinGameCommand : IConsoleCommand
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public string Command => "joingame";
public string Description => "";
public string Help => "";
public JoinGameCommand()
{
IoCManager.InjectDependencies(this);
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
var output = string.Join(".", args);
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{
shell.WriteLine("Round has not started.");
return;
}
else if(ticker.RunLevel == GameRunLevel.InRound)
{
string ID = args[0];
var positions = ticker.GetAvailablePositions();
if(positions.GetValueOrDefault(ID, 0) == 0) //n < 0 is treated as infinite
{
var jobPrototype = _prototypeManager.Index<JobPrototype>(ID);
shell.WriteLine($"{jobPrototype.Name} has no available slots.");
return;
}
ticker.MakeJoinGame(player, args[0]);
return;
}
ticker.MakeJoinGame(player);
}
}
}

View File

@@ -1,80 +0,0 @@
// ReSharper disable once RedundantUsingDirective
// Used to warn the player in big red letters in debug mode
using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
class MappingCommand : IConsoleCommand
{
public string Command => "mapping";
public string Description => "Creates and teleports you to a new uninitialized map for mapping.";
public string Help => $"Usage: {Command} <mapname> / {Command} <id> <mapname>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("Only players can use this command");
return;
}
#if DEBUG
shell.WriteError("WARNING: The server is using a debug build. You are risking losing your changes.");
#endif
var mapManager = IoCManager.Resolve<IMapManager>();
int mapId;
string mapName;
switch (args.Length)
{
case 1:
if (player.AttachedEntity == null)
{
shell.WriteLine("The map name argument cannot be omitted if you have no entity.");
return;
}
mapId = (int) mapManager.NextMapId();
mapName = args[0];
break;
case 2:
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
mapId = id;
mapName = args[1];
break;
default:
shell.WriteLine(Help);
return;
}
shell.ExecuteCommand($"addmap {mapId} false");
shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true");
shell.ExecuteCommand("aghost");
shell.ExecuteCommand($"tp 0 0 {mapId}");
var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int) g.Index).First();
var pauseManager = IoCManager.Resolve<IPauseManager>();
pauseManager.SetMapPaused(newGrid.ParentMapId, true);
shell.WriteLine($"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map.");
}
}
}

View File

@@ -1,23 +0,0 @@
using System;
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
public class NewRoundCommand : IConsoleCommand
{
public string Command => "restartround";
public string Description => "Moves the server from PostRound to a new PreRoundLobby.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.RestartRound();
}
}
}

View File

@@ -1,28 +0,0 @@
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AnyCommand]
class ObserveCommand : IConsoleCommand
{
public string Command => "observe";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.MakeObserve(player);
}
}
}

View File

@@ -1,61 +0,0 @@
using Content.Server.Interfaces.GameTicking;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Network;
namespace Content.Server.Commands.GameTicking
{
class RespawnCommand : IConsoleCommand
{
public string Command => "respawn";
public string Description => "Respawns a player, kicking them back to the lobby.";
public string Help => "respawn [player]";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (args.Length > 1)
{
shell.WriteLine("Must provide <= 1 argument.");
return;
}
var playerMgr = IoCManager.Resolve<IPlayerManager>();
var ticker = IoCManager.Resolve<IGameTicker>();
NetUserId userId;
if (args.Length == 0)
{
if (player == null)
{
shell.WriteLine("If not a player, an argument must be given.");
return;
}
userId = player.UserId;
}
else if (!playerMgr.TryGetUserId(args[0], out userId))
{
shell.WriteLine("Unknown player");
return;
}
if (!playerMgr.TryGetSessionById(userId, out var targetPlayer))
{
if (!playerMgr.TryGetPlayerData(userId, out var data))
{
shell.WriteLine("Unknown player");
return;
}
data.ContentData()?.WipeMind();
shell.WriteLine("Player is not currently online, but they will respawn if they come back online");
return;
}
ticker.Respawn(targetPlayer);
}
}
}

View File

@@ -1,29 +0,0 @@
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class SetGamePresetCommand : IConsoleCommand
{
public string Command => "setgamepreset";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.SetStartPreset(args[0]);
}
}
}

View File

@@ -1,31 +0,0 @@
using System;
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class StartRoundCommand : IConsoleCommand
{
public string Command => "startround";
public string Description => "Ends PreRoundLobby state and starts the round.";
public string Help => String.Empty;
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = IoCManager.Resolve<IGameTicker>();
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
return;
}
ticker.StartRound();
}
}
}

View File

@@ -1,113 +0,0 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Maps;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Mapping)]
class TileWallsCommand : IConsoleCommand
{
// ReSharper disable once StringLiteralTypo
public string Command => "tilewalls";
public string Description => "Puts an underplating tile below every wall on a grid.";
public string Help => $"Usage: {Command} <gridId> | {Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
GridId gridId;
switch (args.Length)
{
case 0:
if (player?.AttachedEntity == null)
{
shell.WriteLine("Only a player can run this command.");
return;
}
gridId = player.AttachedEntity.Transform.GridID;
break;
case 1:
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine($"{args[0]} is not a valid integer.");
return;
}
gridId = new GridId(id);
break;
default:
shell.WriteLine(Help);
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
{
shell.WriteLine($"No grid exists with id {gridId}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var underplating = tileDefinitionManager["underplating"];
var underplatingTile = new Tile(underplating.TileId);
var changed = 0;
foreach (var childUid in gridEntity.Transform.ChildEntityUids)
{
if (!entityManager.TryGetEntity(childUid, out var childEntity))
{
continue;
}
var prototype = childEntity.Prototype;
while (true)
{
if (prototype?.Parent == null)
{
break;
}
prototype = prototypeManager.Index<EntityPrototype>(prototype.Parent);
}
if (prototype?.ID != "base_wall")
{
continue;
}
if (!childEntity.Transform.Anchored)
{
continue;
}
var tile = grid.GetTileRef(childEntity.Transform.Coordinates);
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
if (tileDef.Name == "underplating")
{
continue;
}
grid.SetTile(childEntity.Transform.Coordinates, underplatingTile);
changed++;
}
shell.WriteLine($"Changed {changed} tiles.");
}
}
}

View File

@@ -1,37 +0,0 @@
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AdminCommand(AdminFlags.Server)]
class ToggleDisallowLateJoinCommand : IConsoleCommand
{
public string Command => "toggledisallowlatejoin";
public string Description => "Allows or disallows latejoining during mid-game.";
public string Help => $"Usage: {Command} <disallow>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Need exactly one argument.");
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
if (bool.TryParse(args[0], out var result))
{
ticker.ToggleDisallowLateJoin(bool.Parse(args[0]));
shell.WriteLine(result ? "Late joining has been disabled." : "Late joining has been enabled.");
}
else
{
shell.WriteLine("Invalid argument.");
}
}
}
}

View File

@@ -1,28 +0,0 @@
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GameTicking
{
[AnyCommand]
class ToggleReadyCommand : IConsoleCommand
{
public string Command => "toggleready";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
return;
}
var ticker = IoCManager.Resolve<IGameTicker>();
ticker.ToggleReady(player, bool.Parse(args[0]));
}
}
}

View File

@@ -1,63 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Observer.GhostRoles;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.GhostRoles
{
[AdminCommand(AdminFlags.Fun)]
public class MakeGhostRoleCommand : IConsoleCommand
{
public string Command => "makeghostrole";
public string Description => "Turns an entity into a ghost role.";
public string Help => $"Usage: {Command} <entity uid> <name> <description>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 3)
{
shell.WriteLine($"Invalid amount of arguments.\n{Help}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!EntityUid.TryParse(args[0], out var uid))
{
shell.WriteLine($"{args[0]} is not a valid entity uid.");
return;
}
if (!entityManager.TryGetEntity(uid, out var entity))
{
shell.WriteLine($"No entity found with uid {uid}");
return;
}
if (entity.TryGetComponent(out MindComponent? mind) &&
mind.HasMind)
{
shell.WriteLine($"Entity {entity.Name} with id {uid} already has a mind.");
return;
}
var name = args[1];
var description = args[2];
if (entity.EnsureComponent(out GhostTakeoverAvailableComponent takeOver))
{
shell.WriteLine($"Entity {entity.Name} with id {uid} already has a {nameof(GhostTakeoverAvailableComponent)}");
return;
}
takeOver.RoleName = name;
takeOver.RoleDescription = description;
shell.WriteLine($"Made entity {entity.Name} a ghost role.");
}
}
}

View File

@@ -1,30 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Debug)]
public class HideContainedContextCommand : IConsoleCommand
{
public string Command => "hidecontainedcontext";
public string Description => $"Reverts the effects of {ShowContainedContextCommand.CommandName}";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("You need to be a player to use this command.");
return;
}
EntitySystem.Get<VerbSystem>().RemoveContainerVisibility(player);
}
}
}

View File

@@ -1,43 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Nutrition;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Server.Player;
using Robust.Shared.Console;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Debug)]
public class Hungry : IConsoleCommand
{
public string Command => "hungry";
public string Description => "Makes you hungry.";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("You cannot use this command unless you are a player.");
return;
}
if (player.AttachedEntity == null)
{
shell.WriteLine("You cannot use this command without an entity.");
return;
}
if (!player.AttachedEntity.TryGetComponent(out HungerComponent? hunger))
{
shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component.");
return;
}
var hungryThreshold = hunger.HungerThresholds[HungerThreshold.Starving];
hunger.CurrentHunger = hungryThreshold;
}
}
}

View File

@@ -1,224 +0,0 @@
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Damage;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Fun)]
class HurtCommand : IConsoleCommand
{
public string Command => "hurt";
public string Description => "Ouch";
public string Help => $"Usage: {Command} <type/?> <amount> (<entity uid/_>) (<ignoreResistances>)";
private string DamageTypes()
{
var msg = new StringBuilder();
foreach (var dClass in Enum.GetNames(typeof(DamageClass)))
{
msg.Append($"\n{dClass}");
var types = Enum.Parse<DamageClass>(dClass).ToTypes();
if (types.Count > 0)
{
msg.Append(": ");
msg.AppendJoin('|', types);
}
}
return $"Damage Types:{msg}";
}
private delegate void Damage(IDamageableComponent damageable, bool ignoreResistances);
private bool TryParseEntity(IConsoleShell shell, IPlayerSession? player, string arg,
[NotNullWhen(true)] out IEntity? entity)
{
entity = null;
if (arg == "_")
{
var playerEntity = player?.AttachedEntity;
if (playerEntity == null)
{
shell.WriteLine($"You must have a player entity to use this command without specifying an entity.\n{Help}");
return false;
}
entity = playerEntity;
return true;
}
if (!EntityUid.TryParse(arg, out var entityUid))
{
shell.WriteLine($"{arg} is not a valid entity uid.\n{Help}");
return false;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(entityUid, out var parsedEntity))
{
shell.WriteLine($"No entity found with uid {entityUid}");
return false;
}
entity = parsedEntity;
return true;
}
private bool TryParseDamageArgs(
IConsoleShell shell,
IPlayerSession? player,
string[] args,
[NotNullWhen(true)] out Damage? func)
{
if (!int.TryParse(args[1], out var amount))
{
shell.WriteLine($"{args[1]} is not a valid damage integer.");
func = null;
return false;
}
if (Enum.TryParse<DamageClass>(args[0], true, out var damageClass))
{
func = (damageable, ignoreResistances) =>
{
if (!damageable.DamageClasses.ContainsKey(damageClass))
{
shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageClass}");
return;
}
if (!damageable.ChangeDamage(damageClass, amount, ignoreResistances))
{
shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage.");
return;
}
shell.WriteLine($"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageClass} damage{(ignoreResistances ? ", ignoring resistances." : ".")}");
};
return true;
}
// Fall back to DamageType
else if (Enum.TryParse<DamageType>(args[0], true, out var damageType))
{
func = (damageable, ignoreResistances) =>
{
if (!damageable.DamageTypes.ContainsKey(damageType))
{
shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} can not be damaged with damage class {damageType}");
return;
}
if (!damageable.ChangeDamage(damageType, amount, ignoreResistances))
{
shell.WriteLine($"Entity {damageable.Owner.Name} with id {damageable.Owner.Uid} received no damage.");
return;
}
shell.WriteLine($"Damaged entity {damageable.Owner.Name} with id {damageable.Owner.Uid} for {amount} {damageType} damage{(ignoreResistances ? ", ignoring resistances." : ".")}");
};
return true;
}
else
{
shell.WriteLine($"{args[0]} is not a valid damage class or type.");
var types = DamageTypes();
shell.WriteLine(types);
func = null;
return false;
}
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
bool ignoreResistances;
IEntity entity;
Damage? damageFunc;
switch (args.Length)
{
// Check if we have enough for the dmg types to show
case var n when n > 0 && (args[0] == "?" || args[0] == "¿"):
var types = DamageTypes();
if (args[0] == "¿")
{
types = types.Replace('e', 'é');
}
shell.WriteLine(types);
return;
// Not enough args
case var n when n < 2:
shell.WriteLine($"Invalid number of arguments ({args.Length}).\n{Help}");
return;
case var n when n >= 2 && n <= 4:
if (!TryParseDamageArgs(shell, player, args, out damageFunc))
{
return;
}
var entityUid = n == 2 ? "_" : args[2];
if (!TryParseEntity(shell, player, entityUid, out var parsedEntity))
{
return;
}
entity = parsedEntity;
if (n == 4)
{
if (!bool.TryParse(args[3], out ignoreResistances))
{
shell.WriteLine($"{args[3]} is not a valid boolean value for ignoreResistances.\n{Help}");
return;
}
}
else
{
ignoreResistances = false;
}
break;
default:
shell.WriteLine($"Invalid amount of arguments ({args.Length}).\n{Help}");
return;
}
if (!entity.TryGetComponent(out IDamageableComponent? damageable))
{
shell.WriteLine($"Entity {entity.Name} with id {entity.Uid} does not have a {nameof(IDamageableComponent)}.");
return;
}
damageFunc(damageable, ignoreResistances);
}
}
}

View File

@@ -1,71 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Interactable;
using Content.Shared.Administration;
using Content.Shared.Maps;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.Commands.Interactable
{
/// <summary>
/// <see cref="TilePryingComponent.TryPryTile"/>
/// </summary>
[AdminCommand(AdminFlags.Debug)]
class TilePryCommand : IConsoleCommand
{
public string Command => "tilepry";
public string Description => "Pries up all tiles in a radius around the user.";
public string Help => $"Usage: {Command} <radius>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player?.AttachedEntity == null)
{
return;
}
if (args.Length != 1)
{
shell.WriteLine(Help);
return;
}
if (!int.TryParse(args[0], out var radius))
{
shell.WriteLine($"{args[0]} isn't a valid integer.");
return;
}
if (radius < 0)
{
shell.WriteLine("Radius must be positive.");
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
var playerGrid = player.AttachedEntity.Transform.GridID;
var mapGrid = mapManager.GetGrid(playerGrid);
var playerPosition = player.AttachedEntity.Transform.Coordinates;
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
for (var i = -radius; i <= radius; i++)
{
for (var j = -radius; j <= radius; j++)
{
var tile = mapGrid.GetTileRef(playerPosition.Offset((i, j)));
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
if (!tileDef.CanCrowbar) continue;
var underplating = tileDefinitionManager["underplating"];
mapGrid.SetTile(coordinates, new Tile(underplating.TileId));
}
}
}
}
}

View File

@@ -1,57 +0,0 @@
using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.MachineLinking
{
[AdminCommand(AdminFlags.Debug)]
public class SignalLinkerCommand : IConsoleCommand
{
public string Command => "signallink";
public string Description => "Turns on signal linker mode. Click a transmitter to tune that signal and then click on each receiver to tune them to the transmitter signal.";
public string Help => "signallink (on/off)";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = (IPlayerSession?) shell.Player;
if (player == null)
{
shell.WriteError("This command cannot be run locally.");
return;
}
bool? enable = null;
if (args.Length > 0)
{
if (args[0] == "on")
enable = true;
else if (args[0] == "off")
enable = false;
else if (bool.TryParse(args[0], out var boolean))
enable = boolean;
else if (int.TryParse(args[0], out var num))
{
if (num == 1)
enable = true;
else if (num == 0)
enable = false;
}
}
if (!IoCManager.Resolve<IEntitySystemManager>().TryGetEntitySystem<SignalLinkerSystem>(out var system))
{
return;
}
var ret = system.SignalLinkerKeybind(player.UserId, enable);
shell.WriteLine(ret ? "Enabled" : "Disabled");
}
}
}

View File

@@ -1,66 +0,0 @@
#nullable enable
using System.Threading;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Movement;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Mobs.Speech;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Fun)]
public class MakeSentientCommand : IConsoleCommand
{
public string Command => "makesentient";
public string Description => "Makes an entity sentient (able to be controlled by a player)";
public string Help => "makesentient <entity id>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Wrong number of arguments.");
return;
}
if (!int.TryParse(args[0], out var id))
{
shell.WriteLine("Invalid argument.");
return;
}
var entId = new EntityUid(id);
var entityManager = IoCManager.Resolve<IEntityManager>();
if (!entityManager.TryGetEntity(entId, out var entity) || entity.Deleted)
{
shell.WriteLine("Invalid entity specified!");
return;
}
MakeSentient(entity);
}
public static void MakeSentient(IEntity entity)
{
if(entity.HasComponent<AiControllerComponent>())
entity.RemoveComponent<AiControllerComponent>();
// Delay spawning these components to avoid race conditions with the deferred removal of AiController.
Timer.Spawn(100, () =>
{
entity.EnsureComponent<MindComponent>();
entity.EnsureComponent<SharedPlayerInputMoverComponent>();
entity.EnsureComponent<SharedPlayerMobMoverComponent>();
entity.EnsureComponent<SharedSpeechComponent>();
entity.EnsureComponent<SharedEmotingComponent>();
});
}
}
}

View File

@@ -1,50 +0,0 @@
using Content.Server.Administration;
using Content.Server.Mobs.Roles;
using Content.Server.Players;
using Content.Shared.Administration;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Mobs
{
[AdminCommand(AdminFlags.Fun)]
public class AddRoleCommand : IConsoleCommand
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public string Command => "addrole";
public string Description => "Adds a role to a player's mind.";
public string Help => "addrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
{
shell.WriteLine("Can't find that mind");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find that mind");
return;
}
var role = new Job(mind, _prototypeManager.Index<JobPrototype>(args[1]));
mind.AddRole(role);
}
}
}

View File

@@ -1,53 +0,0 @@
using System.Text;
using Content.Server.Administration;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Mobs
{
[AdminCommand(AdminFlags.Admin)]
public class MindInfoCommand : IConsoleCommand
{
public string Command => "mindinfo";
public string Description => "Lists info for the mind of a specific player.";
public string Help => "mindinfo <session ID>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteLine("Expected exactly 1 argument.");
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetSessionByUsername(args[0], out var data))
{
shell.WriteLine("Can't find that mind");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find that mind");
return;
}
var builder = new StringBuilder();
builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedComponent?.Owner?.Uid);
foreach (var role in mind.AllRoles)
{
builder.AppendFormat("{0} ", role.Name);
}
shell.WriteLine(builder.ToString());
}
}
}

View File

@@ -1,51 +0,0 @@
using Content.Server.Administration;
using Content.Server.Mobs.Roles;
using Content.Server.Players;
using Content.Shared.Administration;
using Content.Shared.Roles;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Mobs
{
[AdminCommand(AdminFlags.Fun)]
public class RemoveRoleCommand : IConsoleCommand
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public string Command => "rmrole";
public string Description => "Removes a role from a player's mind.";
public string Help => "rmrole <session ID> <Role Type>\nThat role type is the actual C# type name.";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
{
shell.WriteLine("Can't find that mind");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find that mind");
return;
}
var role = new Job(mind, _prototypeManager.Index<JobPrototype>(args[1]));
mind.RemoveRole(role);
}
}
}

View File

@@ -1,28 +0,0 @@
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Interfaces;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Notify
{
[AdminCommand(AdminFlags.Debug)]
public class PopupMsgCommand : IConsoleCommand
{
public string Command => "srvpopupmsg";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entityMgr = IoCManager.Resolve<IEntityManager>();
var source = EntityUid.Parse(args[0]);
var viewer = EntityUid.Parse(args[1]);
var msg = args[2];
entityMgr.GetEntity(source).PopupMessage(entityMgr.GetEntity(viewer), msg);
}
}
}

View File

@@ -1,56 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Objectives;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands.Objectives
{
[AdminCommand(AdminFlags.Admin)]
public class AddObjectiveCommand : IConsoleCommand
{
public string Command => "addobjective";
public string Description => "Adds an objective to the player's mind.";
public string Help => "addobjective <username> <objectiveID>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (!mgr.TryGetPlayerDataByUsername(args[0], out var data))
{
shell.WriteLine("Can't find the playerdata.");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find the mind.");
return;
}
if (!IoCManager.Resolve<IPrototypeManager>()
.TryIndex<ObjectivePrototype>(args[1], out var objectivePrototype))
{
shell.WriteLine($"Can't find matching ObjectivePrototype {objectivePrototype}");
return;
}
if (!mind.TryAddObjective(objectivePrototype))
{
shell.WriteLine("Objective requirements dont allow that objective to be added.");
}
}
}
}

View File

@@ -1,52 +0,0 @@
#nullable enable
using System.Linq;
using Content.Server.Administration;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Objectives
{
[AdminCommand(AdminFlags.Admin)]
public class ListObjectivesCommand : IConsoleCommand
{
public string Command => "lsobjectives";
public string Description => "Lists all objectives in a players mind.";
public string Help => "lsobjectives [<username>]";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
IPlayerData? data;
if (args.Length == 0 && player != null)
{
data = player.Data;
}
else if (player == null || !IoCManager.Resolve<IPlayerManager>().TryGetPlayerDataByUsername(args[0], out data))
{
shell.WriteLine("Can't find the playerdata.");
return;
}
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find the mind.");
return;
}
shell.WriteLine($"Objectives for player {data.UserId}:");
var objectives = mind.AllObjectives.ToList();
if (objectives.Count == 0)
{
shell.WriteLine("None.");
}
for (var i = 0; i < objectives.Count; i++)
{
shell.WriteLine($"- [{i}] {objectives[i]}");
}
}
}
}

View File

@@ -1,52 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Objectives
{
[AdminCommand(AdminFlags.Admin)]
public class RemoveObjectiveCommand : IConsoleCommand
{
public string Command => "rmobjective";
public string Description => "Removes an objective from the player's mind.";
public string Help => "rmobjective <username> <index>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Expected exactly 2 arguments.");
return;
}
var mgr = IoCManager.Resolve<IPlayerManager>();
if (mgr.TryGetPlayerDataByUsername(args[0], out var data))
{
var mind = data.ContentData()?.Mind;
if (mind == null)
{
shell.WriteLine("Can't find the mind.");
return;
}
if (int.TryParse(args[1], out var i))
{
shell.WriteLine(mind.TryRemoveObjective(i)
? "Objective successfully removed!"
: "Objective removing failed. Maybe the index is out of bounds? Check lsobjectives!");
}
else
{
shell.WriteLine($"Invalid index {args[1]}!");
}
}
else
{
shell.WriteLine("Can't find the playerdata.");
}
}
}
}

View File

@@ -1,42 +0,0 @@
#nullable enable
using System;
using Content.Server.Administration;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Observer
{
[AnyCommand]
public class Ghost : IConsoleCommand
{
public string Command => "ghost";
public string Description => "Give up on life and become a ghost.";
public string Help => "ghost";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell?.WriteLine("You have no session, you can't ghost.");
return;
}
var mind = player.ContentData()?.Mind;
if (mind == null)
{
shell?.WriteLine("You have no Mind, you can't ghost.");
return;
}
if (!IoCManager.Resolve<IGameTicker>().OnGhostAttempt(mind, true))
{
shell?.WriteLine("You can't ghost right now.");
return;
}
}
}
}

View File

@@ -1,288 +0,0 @@
// MIT License
// Copyright (c) 2019 Erin Catto
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.Physics;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Timing;
#nullable enable
namespace Content.Server.Commands.Physics
{
/*
* I didn't use blueprints because this is way easier to iterate upon as I can shit out testbed upon testbed on new maps
* and never have to leave my debugger.
*/
/// <summary>
/// Copies of Box2D's physics testbed for debugging.
/// </summary>
[AdminCommand(AdminFlags.Mapping)]
public class TestbedCommand : IConsoleCommand
{
public string Command => "testbed";
public string Description => "Loads a physics testbed and teleports your player there";
public string Help => $"{Command} <mapid> <test>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 2)
{
shell.WriteLine("Require 2 args for testbed!");
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
if (!int.TryParse(args[0], out var mapInt))
{
shell.WriteLine($"Unable to parse map {args[0]}");
return;
}
var mapId = new MapId(mapInt);
if (!mapManager.MapExists(mapId))
{
shell.WriteLine("Unable to find map {mapId}");
return;
}
if (shell.Player == null)
{
shell.WriteLine("No player found");
return;
}
var player = (IPlayerSession) shell.Player;
switch (args[1])
{
case "boxstack":
SetupPlayer(mapId, shell, player, mapManager);
CreateBoxStack(mapId);
break;
case "circlestack":
SetupPlayer(mapId, shell, player, mapManager);
CreateCircleStack(mapId);
break;
case "pyramid":
SetupPlayer(mapId, shell, player, mapManager);
CreatePyramid(mapId);
break;
default:
shell.WriteLine($"testbed {args[0]} not found!");
return;
}
shell.WriteLine($"Testbed on map {mapId}");
}
private void SetupPlayer(MapId mapId, IConsoleShell shell, IPlayerSession? player, IMapManager mapManager)
{
var pauseManager = IoCManager.Resolve<IPauseManager>();
pauseManager.SetMapPaused(mapId, false);
var map = EntitySystem.Get<SharedPhysicsSystem>().Maps[mapId].Gravity = new Vector2(0, -4.9f);
return;
}
private void CreateBoxStack(MapId mapId)
{
var entityManager = IoCManager.Resolve<IEntityManager>();
var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
var horizontalFixture = new Fixture(ground, horizontal)
{
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true
};
ground.AddFixture(horizontalFixture);
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
var verticalFixture = new Fixture(ground, vertical)
{
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true
};
ground.AddFixture(verticalFixture);
var xs = new[]
{
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
};
var columnCount = 1;
var rowCount = 15;
PolygonShape shape;
for (var j = 0; j < columnCount; j++)
{
for (var i = 0; i < rowCount; i++)
{
var x = 0.0f;
var box = entityManager.SpawnEntity(null,
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
box.BodyType = BodyType.Dynamic;
box.SleepingAllowed = false;
shape = new PolygonShape();
shape.SetAsBox(0.5f, 0.5f);
box.FixedRotation = false;
// TODO: Need to detect shape and work out if we need to use fixedrotation
var fixture = new Fixture(box, shape)
{
CollisionMask = (int) CollisionGroup.Impassable,
CollisionLayer = (int) CollisionGroup.Impassable,
Hard = true,
};
box.AddFixture(fixture);
}
}
}
private void CreateCircleStack(MapId mapId)
{
var entityManager = IoCManager.Resolve<IEntityManager>();
var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
var horizontal = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
var horizontalFixture = new Fixture(ground, horizontal)
{
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true
};
ground.AddFixture(horizontalFixture);
var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
var verticalFixture = new Fixture(ground, vertical)
{
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true
};
ground.AddFixture(verticalFixture);
var xs = new[]
{
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
};
var columnCount = 1;
var rowCount = 15;
PhysShapeCircle shape;
for (var j = 0; j < columnCount; j++)
{
for (var i = 0; i < rowCount; i++)
{
var x = 0.0f;
var box = entityManager.SpawnEntity(null,
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent<PhysicsComponent>();
box.BodyType = BodyType.Dynamic;
box.SleepingAllowed = false;
shape = new PhysShapeCircle {Radius = 0.5f};
box.FixedRotation = false;
// TODO: Need to detect shape and work out if we need to use fixedrotation
var fixture = new Fixture(box, shape)
{
CollisionMask = (int) CollisionGroup.Impassable,
CollisionLayer = (int) CollisionGroup.Impassable,
Hard = true,
};
box.AddFixture(fixture);
}
}
}
private void CreatePyramid(MapId mapId)
{
const byte count = 20;
// Setup ground
var entityManager = IoCManager.Resolve<IEntityManager>();
var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
var horizontal = new EdgeShape(new Vector2(-40, 0), new Vector2(40, 0));
var horizontalFixture = new Fixture(ground, horizontal)
{
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true
};
ground.AddFixture(horizontalFixture);
// Setup boxes
float a = 0.5f;
PolygonShape shape = new();
shape.SetAsBox(a, a);
var x = new Vector2(-7.0f, 0.75f);
Vector2 y;
Vector2 deltaX = new Vector2(0.5625f, 1.25f);
Vector2 deltaY = new Vector2(1.125f, 0.0f);
for (var i = 0; i < count; ++i)
{
y = x;
for (var j = i; j < count; ++j)
{
var box = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent<PhysicsComponent>();
box.BodyType = BodyType.Dynamic;
box.Owner.Transform.WorldPosition = y;
box.AddFixture(
new Fixture(box, shape) {
CollisionLayer = (int) CollisionGroup.Impassable,
CollisionMask = (int) CollisionGroup.Impassable,
Hard = true,
Mass = 5.0f,
});
y += deltaY;
}
x += deltaX;
}
}
}
}

View File

@@ -1,62 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Mapping)]
public class RemoveExtraComponents : IConsoleCommand
{
public string Command => "removeextracomponents";
public string Description => "Removes all components from all entities of the specified id if that component is not in its prototype.\nIf no id is specified, it matches all entities.";
public string Help => $"{Command} <entityId> / {Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var id = args.Length == 0 ? null : string.Join(" ", args);
var entityManager = IoCManager.Resolve<IEntityManager>();
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
EntityPrototype? prototype = null;
var checkPrototype = !string.IsNullOrEmpty(id);
if (checkPrototype && !prototypeManager.TryIndex(id!, out prototype))
{
shell.WriteError($"Can't find entity prototype with id \"{id}\"!");
return;
}
var entities = 0;
var components = 0;
foreach (var entity in entityManager.GetEntities())
{
if (checkPrototype && entity.Prototype != prototype || entity.Prototype == null)
{
continue;
}
var modified = false;
foreach (var component in entity.GetAllComponents())
{
if (entity.Prototype.Components.ContainsKey(component.Name))
continue;
entityManager.ComponentManager.RemoveComponent(entity.Uid, component);
components++;
modified = true;
}
if (modified)
entities++;
}
shell.WriteLine($"Removed {components} components from {entities} entities{(id == null ? "." : $" with id {id}")}");
}
}
}

View File

@@ -1,33 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Debug)]
public class ShowContainedContextCommand : IConsoleCommand
{
public const string CommandName = "showcontainedcontext";
// ReSharper disable once StringLiteralTypo
public string Command => CommandName;
public string Description => "Makes contained entities visible on the context menu, even when they shouldn't be.";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player == null)
{
shell.WriteLine("You need to be a player to use this command.");
return;
}
EntitySystem.Get<VerbSystem>().AddContainerVisibility(player);
}
}
}

View File

@@ -1,81 +0,0 @@
#nullable enable
using System.Linq;
using System.Text;
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs.Speech;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands.Speech
{
[AdminCommand(AdminFlags.Fun)]
public class AddAccent : IConsoleCommand
{
public string Command => "addaccent";
public string Description => "Add a speech component to the current player";
public string Help => $"{Command} <component>/?";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (player?.AttachedEntity == null)
{
shell.WriteLine("You don't have an entity!");
return;
}
if (args.Length == 0)
{
shell.WriteLine(Help);
return;
}
var compFactory = IoCManager.Resolve<IComponentFactory>();
if (args[0] == "?")
{
// Get all components that implement the ISpeechComponent except
var speeches = compFactory.GetAllRefTypes()
.Where(c => typeof(IAccentComponent).IsAssignableFrom(c) && c.IsClass);
var msg = new StringBuilder();
foreach(var s in speeches)
{
msg.Append($"{compFactory.GetRegistration(s).Name}\n");
}
shell.WriteLine(msg.ToString());
}
else
{
var name = args[0];
// Try to get the Component
if (!compFactory.TryGetRegistration(name, out var registration, true))
{
shell.WriteLine($"Accent {name} not found. Try {Command} ? to get a list of all applicable accents.");
return;
}
var type = registration.Type;
// Check if that already exists
if (player.AttachedEntity.HasComponent(type))
{
shell.WriteLine("You already have this accent!");
return;
}
// Generic fuckery
var ensure = typeof(IEntity).GetMethod("AddComponent");
if (ensure == null)
return;
var method = ensure.MakeGenericMethod(type);
method.Invoke(player.AttachedEntity, null);
}
}
}
}

View File

@@ -1,48 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.Components.Singularity;
using Content.Server.GameObjects.Components.PA;
using Content.Server.GameObjects.Components.Power.PowerNetComponents;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Commands
{
[AdminCommand(AdminFlags.Admin)]
public class StartSingularityEngineCommand : IConsoleCommand
{
public string Command => "startsingularityengine";
public string Description => "Automatically turns on the particle accelerator and containment field emitters.";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
{
shell.WriteLine($"Invalid amount of arguments: {args.Length}.\n{Help}");
return;
}
var entityManager = IoCManager.Resolve<IEntityManager>();
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(EmitterComponent))))
{
ent.GetComponent<EmitterComponent>().SwitchOn();
}
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(RadiationCollectorComponent))))
{
ent.GetComponent<RadiationCollectorComponent>().Collecting = true;
}
foreach (var ent in entityManager.GetEntities(new TypeEntityQuery(typeof(ParticleAcceleratorControlBoxComponent))))
{
var pacb = ent.GetComponent<ParticleAcceleratorControlBoxComponent>();
pacb.RescanParts();
pacb.SetStrength(ParticleAcceleratorPowerState.Level0);
pacb.SwitchOn();
}
shell.WriteLine("Done!");
}
}
}

View File

@@ -1,138 +0,0 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.GameObjects.EntitySystems.StationEvents;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
namespace Content.Server.Commands.StationEvents
{
[AdminCommand(AdminFlags.Server)]
public sealed class StationEventCommand : IConsoleCommand
{
public string Command => "events";
public string Description => "Provides admin control to station events";
public string Help => $"events <running/list/pause/resume/stop/run <eventName/random>>\n{RunningHelp}\n{ListHelp}\n{PauseHelp}\n{ResumeHelp}\n{RunHelp}";
private const string RunningHelp = "running: return the current running event";
private const string ListHelp = "list: return all event names that can be run";
private const string PauseHelp = "pause: stop all random events from running and any one currently running";
private const string ResumeHelp = "resume: allow random events to run again";
private const string RunHelp =
"run <eventName/random>: start a particular event now; <eventName> is case-insensitive and not localized";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player as IPlayerSession;
if (args.Length == 0)
{
shell.WriteLine($"Invalid amount of arguments.\n{Help}");
return;
}
switch (args[0])
{
case "list":
List(shell, player);
break;
case "running":
Running(shell, player);
break;
// Didn't use a "toggle" so it's explicit
case "pause":
Pause(shell, player);
break;
case "resume":
Resume(shell, player);
break;
case "stop":
Stop(shell, player);
break;
case "run":
if (args.Length != 2)
{
shell.WriteLine($"Need 2 arguments, there were {args.Length}.\n{RunHelp}");
break;
}
Run(shell, player, args[1]);
break;
default:
shell.WriteLine(Loc.GetString($"Invalid events command.\n{Help}"));
break;
}
}
private void Run(IConsoleShell shell, IPlayerSession? player, string eventName)
{
var stationSystem = EntitySystem.Get<StationEventSystem>();
var resultText = eventName == "random"
? stationSystem.RunRandomEvent()
: stationSystem.RunEvent(eventName);
shell.WriteLine(resultText);
}
private void Running(IConsoleShell shell, IPlayerSession? player)
{
var eventName = EntitySystem.Get<StationEventSystem>().CurrentEvent?.Name;
if (!string.IsNullOrEmpty(eventName))
{
shell.WriteLine(eventName);
}
else
{
shell.WriteLine(Loc.GetString("No station event running"));
}
}
private void List(IConsoleShell shell, IPlayerSession? player)
{
var resultText = "Random\n" + EntitySystem.Get<StationEventSystem>().GetEventNames();
shell.WriteLine(resultText);
}
private void Pause(IConsoleShell shell, IPlayerSession? player)
{
var stationEventSystem = EntitySystem.Get<StationEventSystem>();
if (!stationEventSystem.Enabled)
{
shell.WriteLine(Loc.GetString("Station events are already paused"));
}
else
{
stationEventSystem.Enabled = false;
shell.WriteLine(Loc.GetString("Station events paused"));
}
}
private void Resume(IConsoleShell shell, IPlayerSession? player)
{
var stationEventSystem = EntitySystem.Get<StationEventSystem>();
if (stationEventSystem.Enabled)
{
shell.WriteLine(Loc.GetString("Station events are already running"));
}
else
{
stationEventSystem.Enabled = true;
shell.WriteLine(Loc.GetString("Station events resumed"));
}
}
private void Stop(IConsoleShell shell, IPlayerSession? player)
{
var resultText = EntitySystem.Get<StationEventSystem>().StopEvent();
shell.WriteLine(resultText);
}
}
}