Files
OldThink/Content.Server/Engineering/EntitySystems/DisassembleOnAltVerbSystem.cs
Jabak 381d904d4b почти важно (#135)
* Add data field for id card microwave behaviour (#28087)

* Move replacement chance from ReplacementAccentComponent to ReplacementAccentPrototype (#28049)

Move replacement chance to ReplacementAccentPrototype

* Resolves Bible summon message being sent to all users (#28104)

* Changed PopupEntity overload used to ensure message is only sent to user

* Updated uid for PopupEntity call

* Updating _popupSystem.PopupEntity call in AttemptSummon

* Random book story generator refactor (#28082)

* Randomized book overhaul

* Fix prototype names

* Improved setting paper content

* Praise Ratvar

* Fix activatable UI popup message spam (#28123)

Fixed activatable UI popup message spam

* Modify battery assert to avoid floating point errors (#28007)

* Update component query benchmarks (#27967)

* Add more component query benchmarks.

* Rename benchmark

* Use non-generic `TryComp()` for metadata & transform (#28133)

* sleeper agent appear later into the round and only once (#28160)

---------

Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com>
Co-authored-by: double_b <40827162+benjamin-burges@users.noreply.github.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Killerqu00 <47712032+Killerqu00@users.noreply.github.com>
2024-10-04 11:27:12 +03:00

70 lines
2.3 KiB
C#

using Content.Server.Engineering.Components;
using Content.Shared.DoAfter;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Verbs;
using JetBrains.Annotations;
namespace Content.Server.Engineering.EntitySystems
{
[UsedImplicitly]
public sealed class DisassembleOnAltVerbSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DisassembleOnAltVerbComponent, GetVerbsEvent<AlternativeVerb>>(AddDisassembleVerb);
}
private void AddDisassembleVerb(EntityUid uid, DisassembleOnAltVerbComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanInteract || !args.CanAccess || args.Hands == null)
return;
AlternativeVerb verb = new()
{
Act = () =>
{
AttemptDisassemble(uid, args.User, args.Target, component);
},
Text = Loc.GetString("disassemble-system-verb-disassemble"),
Priority = 2
};
args.Verbs.Add(verb);
}
public async void AttemptDisassemble(EntityUid uid, EntityUid user, EntityUid target, DisassembleOnAltVerbComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
if (string.IsNullOrEmpty(component.Prototype))
return;
if (component.DoAfterTime > 0 && TryGet<SharedDoAfterSystem>(out var doAfterSystem))
{
var doAfterArgs = new DoAfterArgs(EntityManager, user, component.DoAfterTime, new AwaitedDoAfterEvent(), null)
{
BreakOnMove = true,
};
var result = await doAfterSystem.WaitDoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished)
return;
}
if (component.Deleted || Deleted(uid))
return;
if (!TryComp(uid, out TransformComponent? transformComp))
return;
var entity = EntityManager.SpawnEntity(component.Prototype, transformComp.Coordinates);
_handsSystem.TryPickup(user, entity);
EntityManager.DeleteEntity(uid);
}
}
}