mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 22:18:52 +03:00
Removed all unused variables i could find, built and tested on a simple upstart and clicking trough most systems. Change Loc references to localization. <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> "using Robust.Shared.Prototypes;" to "" "[dependency] private readonly ISpriteComponent" to "" </p> </details> --- No CL this isn't player facing. --------- Co-authored-by: ilmenwe <no@mail.com>
66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using Content.Shared.Body.Part;
|
|
using Content.Shared.Body.Systems;
|
|
using Content.Shared._Shitmed.Body.Events;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Network;
|
|
using System.Numerics;
|
|
|
|
namespace Content.Shared._Shitmed.BodyEffects.Subsystems;
|
|
|
|
public sealed class GenerateChildPartSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
|
|
[Dependency] private readonly INetManager _net = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GenerateChildPartComponent, BodyPartComponentsModifyEvent>(OnPartComponentsModify);
|
|
}
|
|
|
|
private void OnPartComponentsModify(EntityUid uid, GenerateChildPartComponent component, ref BodyPartComponentsModifyEvent args)
|
|
{
|
|
if (args.Add)
|
|
CreatePart(uid, component);
|
|
//else
|
|
//DeletePart(uid, component);
|
|
}
|
|
|
|
private void CreatePart(EntityUid uid, GenerateChildPartComponent component)
|
|
{
|
|
if (!TryComp(uid, out BodyPartComponent? partComp)
|
|
|| partComp.Body is null
|
|
|| component.Active)
|
|
return;
|
|
|
|
// I pinky swear to also move this to the server side properly next update :)
|
|
if (_net.IsServer)
|
|
{
|
|
var childPart = Spawn(component.Id, new EntityCoordinates(partComp.Body.Value, Vector2.Zero));
|
|
|
|
if (!TryComp(childPart, out BodyPartComponent? childPartComp))
|
|
return;
|
|
|
|
var slotName = _bodySystem.GetSlotFromBodyPart(childPartComp);
|
|
_bodySystem.TryCreatePartSlot(uid, slotName, childPartComp.PartType, out var _);
|
|
_bodySystem.AttachPart(uid, slotName, childPart, partComp, childPartComp);
|
|
component.ChildPart = childPart;
|
|
component.Active = true;
|
|
Dirty(childPart, childPartComp);
|
|
}
|
|
}
|
|
|
|
// Still unusued, gotta figure out what I want to do with this function outside of fuckery with mantis blades.
|
|
private void DeletePart(EntityUid uid, GenerateChildPartComponent component)
|
|
{
|
|
if (!TryComp(uid, out BodyPartComponent? partComp))
|
|
return;
|
|
|
|
_bodySystem.DropSlotContents((uid, partComp));
|
|
var ev = new BodyPartDroppedEvent((uid, partComp));
|
|
RaiseLocalEvent(uid, ref ev);
|
|
QueueDel(uid);
|
|
}
|
|
}
|
|
|