Files
tbd-station-14/Content.Server/Chat/ChatCommands.cs
DrSmugleaf 4b4e83d2bf Add changing the amount of hands on the GUI depending on your body parts (#1406)
* Multiple hands in gui first pass

* Remove IHandsComponent interface

* Create hand class and more hand textures

* Refactor ServerHandsComponent to use a single list of hands

* Seal SharedHand

* Fix picked up items not showing on top of the hand buttons

* Remove HandsGui buttons and panels dictionaries

* Fix items in hands rendering

* Fix wrong hand container comparison

* Fix not updating the location of duplicate hands

* Change ClientHandsComponent to use a SortedList instead of a dictionary

* More merge conflict fixes

* Change SortedList to List

* Fix hand button order

* Add item tooltip for more than 2 hands and updating when removing hands

* Add add hand and remove hand command

* Merge conflict fixes

* Remove nullable reference type from ContainerSlot

* Fix texture errors

* Fix error when reaching 0 hands

* Fix error when swapping hands with no hands

* Merged remove hand methods

* Fix item panel texture errors

* Merge conflict fixes

* Fix addhand and removehand command descriptions

* Add properly displaying tooltips for 2 hands

* Make hand indexes and locations consistent across the client and server

* Add dropping held entity if a hand is removed

* Change hand location to be calculated by index

* Made different hand gui updates more consistent

* Remove human body yml testing changes

* Sanitize addhand and removehand commands

* Merge conflict fixes

* Remove testing changes

* Revert body system changes

* Add missing imports

* Remove obsolete hands parameter in yml files

* Fix broken import

* Fix startup error and adding and removing hands on the same tick

* Make hand container id use an uint

In case someone gets more than 2 billion hands

* Rename hand component files

* Make hands state use an array
2020-07-25 15:11:16 +02:00

174 lines
6.6 KiB
C#

using Content.Server.GameObjects;
using Content.Server.GameObjects.Components.Observer;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Players;
using Content.Shared.GameObjects;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Enums;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using System.Linq;
using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.GUI;
namespace Content.Server.Chat
{
internal class SayCommand : IClientCommand
{
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, IPlayerSession player, string[] args)
{
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
return;
if (args.Length < 1)
return;
var chat = IoCManager.Resolve<IChatManager>();
var message = string.Join(" ", args);
if (player.AttachedEntity.HasComponent<GhostComponent>())
chat.SendDeadChat(player, message);
else
{
var mindComponent = player.ContentData().Mind;
chat.EntitySay(mindComponent.OwnedEntity, message);
}
}
}
internal class MeCommand : IClientCommand
{
public string Command => "me";
public string Description => "Perform an action.";
public string Help => "me <text>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
return;
if (args.Length < 1)
return;
var chat = IoCManager.Resolve<IChatManager>();
var action = string.Join(" ", args);
var mindComponent = player.ContentData().Mind;
chat.EntityMe(mindComponent.OwnedEntity, action);
}
}
internal class OOCCommand : IClientCommand
{
public string Command => "ooc";
public string Description => "Send Out Of Character chat messages.";
public string Help => "ooc <text>";
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
var chat = IoCManager.Resolve<IChatManager>();
chat.SendOOC(player, string.Join(" ", args));
}
}
internal class AdminChatCommand : IClientCommand
{
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, IPlayerSession player, string[] args)
{
var chat = IoCManager.Resolve<IChatManager>();
chat.SendAdminChat(player, string.Join(" ", args));
}
}
internal class SuicideCommand : IClientCommand
{
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, DamageableComponent damageableComponent, IEntity source, IEntity target)
{
SuicideKind kind = suicide.Suicide(target, chat);
if (kind != SuicideKind.Special)
{
damageableComponent.TakeDamage(kind switch
{
SuicideKind.Brute => DamageType.Brute,
SuicideKind.Heat => DamageType.Heat,
SuicideKind.Cold => DamageType.Cold,
SuicideKind.Acid => DamageType.Acid,
SuicideKind.Toxic => DamageType.Toxic,
SuicideKind.Electric => DamageType.Electric,
_ => DamageType.Brute
},
500, //TODO: needs to be a max damage of some sorts
source,
target);
}
}
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
{
if (player.Status != SessionStatus.InGame)
return;
var chat = IoCManager.Resolve<IChatManager>();
var owner = player.ContentData().Mind.OwnedMob.Owner;
var dmgComponent = owner.GetComponent<DamageableComponent>();
//TODO: needs to check if the mob is actually alive
//TODO: maybe set a suicided flag to prevent ressurection?
// Held item suicide
var handsComponent = owner.GetComponent<HandsComponent>();
var itemComponent = handsComponent.GetActiveHand;
if (itemComponent != null)
{
ISuicideAct 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 = owner.EntityManager.GetEntitiesInRange(owner, 1, true);
if (entities.Count() > 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
chat.EntityMe(owner, Loc.GetString("is attempting to bite {0:their} own tongue, looks like {0:theyre} trying to commit suicide!", owner)); //TODO: theyre macro
dmgComponent.TakeDamage(DamageType.Brute, 500, owner, owner); //TODO: dmg value needs to be a max damage of some sorts
}
}
}