mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description The recently introduced bio-synthetic torso didn't actually do anything since the biofab just spawned the torso body part rather than a usable body. This fixes that. The bio-synthetic torso lathe recipe now spawns a limbless bio-synthetic human which can then have limbs attached like any other torso. The torso's name, sex, and pronouns can be set once, ideally to reflect the identity of the person being put into the body. Hopefully this will help biofabrication function as a potential alternative to cloning. --- <details><summary><h1>Media</h1></summary> <p>     The verbs disappear after you select a name/gender/sex.   </p> </details> --- # Changelog 🆑 - tweak: Made bio-synthetic torso work as a body (cherry picked from commit 2911f82360aeab153968cc444a90c0b5321f43e0)
74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System.Diagnostics;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.NameIdentifier;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.Renamable.Components;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
namespace Content.Shared.Renamable.EntitySystems;
|
|
|
|
public partial class SharedRenamableSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
|
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = null!;
|
|
private SharedPopupSystem? _popup;
|
|
private MetaDataSystem _metaData = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<RenamableComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
|
|
SubscribeLocalEvent<RenamableComponent, RenamableBuiMessage>(OnRename);
|
|
|
|
_popup = _entManager.System<SharedPopupSystem>();
|
|
_metaData = _entManager.System<MetaDataSystem>();
|
|
}
|
|
|
|
private void OnRename(Entity<RenamableComponent> entity, ref RenamableBuiMessage renameMessage)
|
|
{
|
|
_popup!.PopupPredicted(Loc.GetString("comp-renamable-rename", ("newname", renameMessage.Name)), entity, null);
|
|
|
|
var name = renameMessage.Name.Trim();
|
|
|
|
var metaData = MetaData(entity);
|
|
|
|
// don't change the name if the value doesn't actually change
|
|
if (metaData.EntityName.Equals(name, StringComparison.InvariantCulture))
|
|
return;
|
|
|
|
if (TryComp<NameIdentifierComponent>(entity, out var identifier))
|
|
name = $"{name} {identifier.FullIdentifier}";
|
|
|
|
_metaData.SetEntityName(entity, name, metaData);
|
|
if (entity.Comp.SingleUse)
|
|
RemCompDeferred<RenamableComponent>(entity);
|
|
}
|
|
|
|
private void OnGetVerbs(Entity<RenamableComponent> entity, ref GetVerbsEvent<Verb> args)
|
|
{
|
|
if (!args.CanAccess || !args.CanInteract || args.Hands == null)
|
|
return;
|
|
|
|
var entityUid = entity.Owner;
|
|
var user = args.User;
|
|
var renameVerb = new Verb
|
|
{
|
|
Text = Loc.GetString("verb-categories-rename"),
|
|
DoContactInteraction = true,
|
|
Act = () =>
|
|
{
|
|
_uiSystem.OpenUi(entityUid, SharedRenamableInterfaceKey.Key, user);
|
|
}
|
|
};
|
|
args.Verbs.Add(renameVerb);
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public sealed class RenamableBuiMessage(string name) : BoundUserInterfaceMessage
|
|
{
|
|
public string Name = name;
|
|
}
|