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

@@ -0,0 +1,39 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Chat.Commands
{
[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

@@ -0,0 +1,56 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
namespace Content.Server.Chat.Commands
{
[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

@@ -0,0 +1,38 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.IoC;
namespace Content.Server.Chat.Commands
{
[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

@@ -0,0 +1,71 @@
#nullable enable
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.Ghost.Components;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
namespace Content.Server.Chat.Commands
{
[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

@@ -0,0 +1,130 @@
#nullable enable
using System.Linq;
using Content.Server.Act;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Server.Notification;
using Content.Server.Players;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Content.Shared.Notification;
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.Chat.Commands
{
[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);
}
}
}