ECS dragdrop (#12973)
* ECS dragdrop No more excuses. * AAAAAAAAAAAAAA * kry * events * aaaaaaaaaa * HUH * Fix stripping * aaaaaa * spoike * asease * fix table vaulting * ded * rebiew * aaaaaaaaaaaaa * drag * aeaeae * weh
This commit is contained in:
@@ -31,8 +31,8 @@ public sealed partial class BuckleSystem
|
||||
SubscribeLocalEvent<BuckleComponent, InteractHandEvent>(HandleInteractHand);
|
||||
SubscribeLocalEvent<BuckleComponent, GetVerbsEvent<InteractionVerb>>(AddUnbuckleVerb);
|
||||
SubscribeLocalEvent<BuckleComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
||||
SubscribeLocalEvent<BuckleComponent, CanDropEvent>(OnBuckleCanDrop);
|
||||
SubscribeLocalEvent<BuckleComponent, DragDropEvent>(OnBuckleDragDrop);
|
||||
SubscribeLocalEvent<BuckleComponent, CanDropDraggedEvent>(OnBuckleCanDrop);
|
||||
SubscribeLocalEvent<BuckleComponent, DragDropDraggedEvent>(OnBuckleDragDrop);
|
||||
}
|
||||
|
||||
private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
@@ -104,12 +104,12 @@ public sealed partial class BuckleSystem
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
private void OnBuckleCanDrop(EntityUid uid, BuckleComponent component, CanDropEvent args)
|
||||
private void OnBuckleCanDrop(EntityUid uid, BuckleComponent component, ref CanDropDraggedEvent args)
|
||||
{
|
||||
args.Handled = HasComp<StrapComponent>(args.Target);
|
||||
}
|
||||
|
||||
private void OnBuckleDragDrop(EntityUid uid, BuckleComponent component, DragDropEvent args)
|
||||
private void OnBuckleDragDrop(EntityUid uid, BuckleComponent component, ref DragDropDraggedEvent args)
|
||||
{
|
||||
args.Handled = TryBuckle(uid, args.User, args.Target, component);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public sealed partial class BuckleSystem
|
||||
SubscribeLocalEvent<StrapComponent, DestructionEventArgs>((_,c,_) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, BreakageEventArgs>((_, c, _) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, ConstructionBeforeDeleteEvent>((_, c, _) => StrapRemoveAll(c));
|
||||
SubscribeLocalEvent<StrapComponent, DragDropEvent>(OnStrapDragDrop);
|
||||
SubscribeLocalEvent<StrapComponent, DragDropTargetEvent>(OnStrapDragDrop);
|
||||
}
|
||||
|
||||
private void OnStrapGetState(EntityUid uid, StrapComponent component, ref ComponentGetState args)
|
||||
@@ -185,9 +185,9 @@ public sealed partial class BuckleSystem
|
||||
Dirty(strap);
|
||||
}
|
||||
|
||||
private void OnStrapDragDrop(EntityUid uid, StrapComponent component, DragDropEvent args)
|
||||
private void OnStrapDragDrop(EntityUid uid, StrapComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
if (!StrapCanDragDropOn(uid, args.User, args.Target, args.Dragged, component))
|
||||
if (!StrapCanDragDropOn(uid, args.User, uid, args.Dragged, component))
|
||||
return;
|
||||
|
||||
args.Handled = TryBuckle(args.Dragged, args.User, uid);
|
||||
|
||||
@@ -58,7 +58,7 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||
SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbableVerb);
|
||||
SubscribeLocalEvent<ClimbableComponent, DragDropEvent>(OnClimbableDragDrop);
|
||||
SubscribeLocalEvent<ClimbableComponent, DragDropTargetEvent>(OnClimbableDragDrop);
|
||||
|
||||
SubscribeLocalEvent<ClimbingComponent, ClimbFinishedEvent>(OnClimbFinished);
|
||||
SubscribeLocalEvent<ClimbingComponent, EndCollideEvent>(OnClimbEndCollide);
|
||||
@@ -68,17 +68,17 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed);
|
||||
}
|
||||
|
||||
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, CanDragDropOnEvent args)
|
||||
protected override void OnCanDragDropOn(EntityUid uid, ClimbableComponent component, ref CanDropTargetEvent args)
|
||||
{
|
||||
base.OnCanDragDropOn(uid, component, args);
|
||||
base.OnCanDragDropOn(uid, component, ref args);
|
||||
|
||||
if (!args.CanDrop)
|
||||
return;
|
||||
|
||||
string reason;
|
||||
var canVault = args.User == args.Dragged
|
||||
? CanVault(component, args.User, args.Target, out reason)
|
||||
: CanVault(component, args.User, args.Dragged, args.Target, out reason);
|
||||
? CanVault(component, args.User, uid, out reason)
|
||||
: CanVault(component, args.User, args.Dragged, uid, out reason);
|
||||
|
||||
if (!canVault)
|
||||
_popupSystem.PopupEntity(reason, args.User, args.User);
|
||||
@@ -103,9 +103,9 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
});
|
||||
}
|
||||
|
||||
private void OnClimbableDragDrop(EntityUid uid, ClimbableComponent component, DragDropEvent args)
|
||||
private void OnClimbableDragDrop(EntityUid uid, ClimbableComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
TryMoveEntity(component, args.User, args.Dragged, args.Target);
|
||||
TryMoveEntity(component, args.User, args.Dragged, uid);
|
||||
}
|
||||
|
||||
private void TryMoveEntity(ClimbableComponent component, EntityUid user, EntityUid entityToMove,
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
// Interactions
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ActivateInWorldEvent>(HandleActivate);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, AfterInteractUsingEvent>(HandleAfterInteractUsing);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DragDropEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DragDropTargetEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(HandleDestruction);
|
||||
|
||||
// Verbs
|
||||
@@ -391,7 +391,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
TryEjectContents(uid, component);
|
||||
}
|
||||
|
||||
private void HandleDragDropOn(EntityUid uid, DisposalUnitComponent component, DragDropEvent args)
|
||||
private void HandleDragDropOn(EntityUid uid, DisposalUnitComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
args.Handled = TryInsert(uid, args.Dragged, args.User);
|
||||
}
|
||||
|
||||
@@ -60,58 +60,38 @@ namespace Content.Server.Interaction
|
||||
}
|
||||
|
||||
#region Drag drop
|
||||
|
||||
private void HandleDragDropRequestEvent(DragDropRequestEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (!ValidateClientInput(args.SenderSession, msg.DropLocation, msg.Target, out var userEntity))
|
||||
{
|
||||
Logger.InfoS("system.interaction", $"DragDropRequestEvent input validation failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Deleted(msg.Dropped) || Deleted(msg.Target))
|
||||
if (Deleted(msg.Dragged) || Deleted(msg.Target))
|
||||
return;
|
||||
|
||||
if (!_actionBlockerSystem.CanInteract(userEntity.Value, msg.Target))
|
||||
return;
|
||||
var user = args.SenderSession.AttachedEntity;
|
||||
|
||||
var interactionArgs = new DragDropEvent(userEntity.Value, msg.DropLocation, msg.Dropped, msg.Target);
|
||||
if (user == null || !_actionBlockerSystem.CanInteract(user.Value, msg.Target))
|
||||
return;
|
||||
|
||||
// must be in range of both the target and the object they are drag / dropping
|
||||
// Client also does this check but ya know we gotta validate it.
|
||||
if (!InRangeUnobstructed(interactionArgs.User, interactionArgs.Dragged, popup: true)
|
||||
|| !InRangeUnobstructed(interactionArgs.User, interactionArgs.Target, popup: true))
|
||||
if (!InRangeUnobstructed(user.Value, msg.Dragged, popup: true)
|
||||
|| !InRangeUnobstructed(user.Value, msg.Target, popup: true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dragArgs = new DragDropDraggedEvent(user.Value, msg.Target);
|
||||
|
||||
// trigger dragdrops on the dropped entity
|
||||
RaiseLocalEvent(msg.Dropped, interactionArgs, true);
|
||||
RaiseLocalEvent(msg.Dragged, ref dragArgs);
|
||||
|
||||
if (interactionArgs.Handled)
|
||||
if (dragArgs.Handled)
|
||||
return;
|
||||
|
||||
foreach (var dragDrop in AllComps<IDraggable>(msg.Dropped))
|
||||
{
|
||||
if (dragDrop.CanDrop(interactionArgs) &&
|
||||
dragDrop.Drop(interactionArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
var dropArgs = new DragDropTargetEvent(user.Value, msg.Dragged);
|
||||
|
||||
// trigger dragdropons on the targeted entity
|
||||
RaiseLocalEvent(msg.Target, interactionArgs, false);
|
||||
|
||||
if (interactionArgs.Handled)
|
||||
return;
|
||||
|
||||
foreach (var dragDropOn in AllComps<IDragDropOn>(msg.Target))
|
||||
{
|
||||
if (dragDropOn.CanDragDropOn(interactionArgs) &&
|
||||
dragDropOn.DragDropOn(interactionArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
RaiseLocalEvent(msg.Target, ref dropArgs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using Content.Server.Kitchen.EntitySystems;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Kitchen.Components;
|
||||
|
||||
namespace Content.Server.Kitchen.Components
|
||||
{
|
||||
[RegisterComponent, Access(typeof(KitchenSpikeSystem))]
|
||||
[RegisterComponent, Access(typeof(KitchenSpikeSystem)), ComponentReference(typeof(SharedKitchenSpikeComponent))]
|
||||
public sealed class KitchenSpikeComponent : SharedKitchenSpikeComponent
|
||||
{
|
||||
public List<string?>? PrototypesToSpawn;
|
||||
@@ -16,11 +15,5 @@ namespace Content.Server.Kitchen.Components
|
||||
|
||||
// Prevents simultaneous spiking of two bodies (could be replaced with CancellationToken, but I don't see any situation where Cancel could be called)
|
||||
public bool InUse;
|
||||
|
||||
// ECS this out!, when DragDropSystem and InteractionSystem refactored
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Server.DoAfter;
|
||||
using Content.Server.Kitchen.Components;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -15,6 +14,7 @@ using Content.Shared.Storage;
|
||||
using Robust.Shared.Random;
|
||||
using static Content.Shared.Kitchen.Components.SharedKitchenSpikeComponent;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Kitchen;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Popups;
|
||||
@@ -22,7 +22,7 @@ using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
internal sealed class KitchenSpikeSystem : EntitySystem
|
||||
public sealed class KitchenSpikeSystem : SharedKitchenSpikeSystem
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||
@@ -37,13 +37,21 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, DragDropEvent>(OnDragDrop);
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, DragDropTargetEvent>(OnDragDrop);
|
||||
|
||||
//DoAfter
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, SpikingFinishedEvent>(OnSpikingFinished);
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, SpikingFailEvent>(OnSpikingFail);
|
||||
|
||||
SubscribeLocalEvent<KitchenSpikeComponent, SuicideEvent>(OnSuicide);
|
||||
|
||||
SubscribeLocalEvent<ButcherableComponent, CanDropDraggedEvent>(OnButcherableCanDrop);
|
||||
}
|
||||
|
||||
private void OnButcherableCanDrop(EntityUid uid, ButcherableComponent component, ref CanDropDraggedEvent args)
|
||||
{
|
||||
args.Handled = true;
|
||||
args.CanDrop |= component.Type != ButcheringType.Knife;
|
||||
}
|
||||
|
||||
private void OnSuicide(EntityUid uid, KitchenSpikeComponent component, SuicideEvent args)
|
||||
@@ -62,7 +70,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
component.InUse = false;
|
||||
|
||||
if (EntityManager.TryGetComponent<SharedButcherableComponent>(args.VictimUid, out var butcherable))
|
||||
if (EntityManager.TryGetComponent<ButcherableComponent>(args.VictimUid, out var butcherable))
|
||||
butcherable.BeingButchered = false;
|
||||
}
|
||||
|
||||
@@ -70,7 +78,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
{
|
||||
component.InUse = false;
|
||||
|
||||
if (EntityManager.TryGetComponent<SharedButcherableComponent>(args.VictimUid, out var butcherable))
|
||||
if (EntityManager.TryGetComponent<ButcherableComponent>(args.VictimUid, out var butcherable))
|
||||
butcherable.BeingButchered = false;
|
||||
|
||||
if (Spikeable(uid, args.UserUid, args.VictimUid, component, butcherable))
|
||||
@@ -79,9 +87,9 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDragDrop(EntityUid uid, KitchenSpikeComponent component, DragDropEvent args)
|
||||
private void OnDragDrop(EntityUid uid, KitchenSpikeComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
if(args.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
@@ -111,7 +119,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
private void Spike(EntityUid uid, EntityUid userUid, EntityUid victimUid,
|
||||
KitchenSpikeComponent? component = null, SharedButcherableComponent? butcherable = null)
|
||||
KitchenSpikeComponent? component = null, ButcherableComponent? butcherable = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component) || !Resolve(victimUid, ref butcherable))
|
||||
return;
|
||||
@@ -177,7 +185,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
private bool Spikeable(EntityUid uid, EntityUid userUid, EntityUid victimUid,
|
||||
KitchenSpikeComponent? component = null, SharedButcherableComponent? butcherable = null)
|
||||
KitchenSpikeComponent? component = null, ButcherableComponent? butcherable = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
@@ -208,7 +216,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
||||
}
|
||||
|
||||
public bool TrySpike(EntityUid uid, EntityUid userUid, EntityUid victimUid, KitchenSpikeComponent? component = null,
|
||||
SharedButcherableComponent? butcherable = null, MobStateComponent? mobState = null)
|
||||
ButcherableComponent? butcherable = null, MobStateComponent? mobState = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component) || component.InUse ||
|
||||
!Resolve(victimUid, ref butcherable) || butcherable.BeingButchered)
|
||||
|
||||
@@ -34,7 +34,7 @@ public sealed class SharpSystem : EntitySystem
|
||||
SubscribeLocalEvent<SharpButcherDoafterComplete>(OnDoafterComplete);
|
||||
SubscribeLocalEvent<SharpButcherDoafterCancelled>(OnDoafterCancelled);
|
||||
|
||||
SubscribeLocalEvent<SharedButcherableComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
|
||||
SubscribeLocalEvent<ButcherableComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
|
||||
}
|
||||
|
||||
private void OnAfterInteract(EntityUid uid, SharpComponent component, AfterInteractEvent args)
|
||||
@@ -47,7 +47,7 @@ public sealed class SharpSystem : EntitySystem
|
||||
|
||||
private void TryStartButcherDoafter(EntityUid knife, EntityUid target, EntityUid user)
|
||||
{
|
||||
if (!TryComp<SharedButcherableComponent>(target, out var butcher))
|
||||
if (!TryComp<ButcherableComponent>(target, out var butcher))
|
||||
return;
|
||||
|
||||
if (!TryComp<SharpComponent>(knife, out var sharp))
|
||||
@@ -79,7 +79,7 @@ public sealed class SharpSystem : EntitySystem
|
||||
|
||||
private void OnDoafterComplete(SharpButcherDoafterComplete ev)
|
||||
{
|
||||
if (!TryComp<SharedButcherableComponent>(ev.Entity, out var butcher))
|
||||
if (!TryComp<ButcherableComponent>(ev.Entity, out var butcher))
|
||||
return;
|
||||
|
||||
if (!TryComp<SharpComponent>(ev.Sharp, out var sharp))
|
||||
@@ -123,7 +123,7 @@ public sealed class SharpSystem : EntitySystem
|
||||
sharp.Butchering.Remove(ev.Entity);
|
||||
}
|
||||
|
||||
private void OnGetInteractionVerbs(EntityUid uid, SharedButcherableComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
private void OnGetInteractionVerbs(EntityUid uid, ButcherableComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (component.Type != ButcheringType.Knife || args.Hands == null)
|
||||
return;
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Content.Server.Medical.BiomassReclaimer
|
||||
{
|
||||
component.BloodReagent = stream.BloodReagent;
|
||||
}
|
||||
if (TryComp<SharedButcherableComponent>(toProcess, out var butcherableComponent))
|
||||
if (TryComp<ButcherableComponent>(toProcess, out var butcherableComponent))
|
||||
{
|
||||
component.SpawnedEntities = butcherableComponent.SpawnedEntities;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,5 @@ namespace Content.Server.Medical.Components
|
||||
|
||||
[DataField("partRatingCloningFailChanceMultiplier")]
|
||||
public float PartRatingFailMultiplier = 0.75f;
|
||||
|
||||
// ECS this out!, when DragDropSystem and InteractionSystem refactored
|
||||
public override bool DragDropOn(DragDropEvent eventArgs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Examine;
|
||||
@@ -54,6 +53,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CryoPodComponent, CanDropTargetEvent>(OnCryoPodCanDropOn);
|
||||
SubscribeLocalEvent<CryoPodComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<CryoPodComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
||||
SubscribeLocalEvent<CryoPodComponent, GotEmaggedEvent>(OnEmagged);
|
||||
@@ -63,7 +63,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
SubscribeLocalEvent<CryoPodComponent, CryoPodPryInterrupted>(OnCryoPodPryInterrupted);
|
||||
|
||||
SubscribeLocalEvent<CryoPodComponent, AtmosDeviceUpdateEvent>(OnCryoPodUpdateAtmosphere);
|
||||
SubscribeLocalEvent<CryoPodComponent, DragDropEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<CryoPodComponent, DragDropTargetEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<CryoPodComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<CryoPodComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<CryoPodComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
@@ -127,7 +127,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
|
||||
#region Interaction
|
||||
|
||||
private void HandleDragDropOn(EntityUid uid, CryoPodComponent cryoPodComponent, DragDropEvent args)
|
||||
private void HandleDragDropOn(EntityUid uid, CryoPodComponent cryoPodComponent, ref DragDropTargetEvent args)
|
||||
{
|
||||
if (cryoPodComponent.BodyContainer.ContainedEntity != null)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@ using Content.Server.MachineLinking.System;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Cloning.Components;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Server.Containers;
|
||||
@@ -42,11 +44,26 @@ namespace Content.Server.Medical
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DestructionEventArgs>(OnDestroyed);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DragDropEvent>(HandleDragDropOn);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, DragDropTargetEvent>(OnDragDropOn);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, PortDisconnectedEvent>(OnPortDisconnected);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||
SubscribeLocalEvent<MedicalScannerComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
||||
}
|
||||
|
||||
private void OnCanDragDropOn(EntityUid uid, MedicalScannerComponent component, ref CanDropTargetEvent args)
|
||||
{
|
||||
args.Handled = true;
|
||||
args.CanDrop |= CanScannerInsert(uid, args.Dragged, component);
|
||||
}
|
||||
|
||||
public bool CanScannerInsert(EntityUid uid, EntityUid target, MedicalScannerComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
|
||||
return HasComp<BodyComponent>(target);
|
||||
}
|
||||
|
||||
private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
|
||||
@@ -58,7 +75,7 @@ namespace Content.Server.Medical
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
if (!_blocker.CanInteract(args.Entity, scannerComponent.Owner))
|
||||
if (!_blocker.CanInteract(args.Entity, uid))
|
||||
return;
|
||||
|
||||
EjectBody(uid, scannerComponent);
|
||||
@@ -70,7 +87,7 @@ namespace Content.Server.Medical
|
||||
!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
IsOccupied(component) ||
|
||||
!component.CanInsert(args.Using.Value))
|
||||
!CanScannerInsert(uid, args.Using.Value, component))
|
||||
return;
|
||||
|
||||
string name = "Unknown";
|
||||
@@ -79,7 +96,7 @@ namespace Content.Server.Medical
|
||||
|
||||
InteractionVerb verb = new()
|
||||
{
|
||||
Act = () => InsertBody(component.Owner, args.Target, component),
|
||||
Act = () => InsertBody(uid, args.Target, component),
|
||||
Category = VerbCategory.Insert,
|
||||
Text = name
|
||||
};
|
||||
@@ -104,11 +121,11 @@ namespace Content.Server.Medical
|
||||
|
||||
// Self-insert verb
|
||||
if (!IsOccupied(component) &&
|
||||
component.CanInsert(args.User) &&
|
||||
CanScannerInsert(uid, args.User, component) &&
|
||||
_blocker.CanMove(args.User))
|
||||
{
|
||||
AlternativeVerb verb = new();
|
||||
verb.Act = () => InsertBody(component.Owner, args.User, component);
|
||||
verb.Act = () => InsertBody(uid, args.User, component);
|
||||
verb.Text = Loc.GetString("medical-scanner-verb-enter");
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
@@ -119,7 +136,7 @@ namespace Content.Server.Medical
|
||||
EjectBody(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void HandleDragDropOn(EntityUid uid, MedicalScannerComponent scannerComponent, DragDropEvent args)
|
||||
private void OnDragDropOn(EntityUid uid, MedicalScannerComponent scannerComponent, ref DragDropTargetEvent args)
|
||||
{
|
||||
InsertBody(uid, args.Dragged, scannerComponent);
|
||||
}
|
||||
@@ -141,9 +158,9 @@ namespace Content.Server.Medical
|
||||
}
|
||||
_cloningConsoleSystem.UpdateUserInterface(console);
|
||||
}
|
||||
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
|
||||
private MedicalScannerStatus GetStatus(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (TryComp<ApcPowerReceiverComponent>(scannerComponent.Owner, out var power) && power.Powered)
|
||||
if (this.IsPowered(uid, EntityManager))
|
||||
{
|
||||
var body = scannerComponent.BodyContainer.ContainedEntity;
|
||||
if (body == null)
|
||||
@@ -180,9 +197,9 @@ namespace Content.Server.Medical
|
||||
|
||||
private void UpdateAppearance(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||
{
|
||||
if (TryComp<AppearanceComponent>(scannerComponent.Owner, out var appearance))
|
||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
{
|
||||
_appearance.SetData(uid, MedicalScannerVisuals.Status, GetStatus(scannerComponent), appearance);
|
||||
_appearance.SetData(uid, MedicalScannerVisuals.Status, GetStatus(uid, scannerComponent), appearance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,11 +227,11 @@ namespace Content.Server.Medical
|
||||
if (scannerComponent.BodyContainer.ContainedEntity != null)
|
||||
return;
|
||||
|
||||
if (!TryComp<MobStateComponent>(user, out var comp))
|
||||
if (!HasComp<MobStateComponent>(user))
|
||||
return;
|
||||
|
||||
scannerComponent.BodyContainer.Insert(user);
|
||||
UpdateAppearance(scannerComponent.Owner, scannerComponent);
|
||||
UpdateAppearance(uid, scannerComponent);
|
||||
}
|
||||
|
||||
public void EjectBody(EntityUid uid, MedicalScannerComponent? scannerComponent)
|
||||
@@ -222,11 +239,12 @@ namespace Content.Server.Medical
|
||||
if (!Resolve(uid, ref scannerComponent))
|
||||
return;
|
||||
|
||||
if (scannerComponent.BodyContainer.ContainedEntity is not {Valid: true} contained) return;
|
||||
if (scannerComponent.BodyContainer.ContainedEntity is not {Valid: true} contained)
|
||||
return;
|
||||
|
||||
scannerComponent.BodyContainer.Remove(contained);
|
||||
_climbSystem.ForciblySetClimbing(contained, uid);
|
||||
UpdateAppearance(scannerComponent.Owner, scannerComponent);
|
||||
UpdateAppearance(uid, scannerComponent);
|
||||
}
|
||||
|
||||
private void OnRefreshParts(EntityUid uid, MedicalScannerComponent component, RefreshPartsEvent args)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using System.Threading;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Strip.Components;
|
||||
|
||||
namespace Content.Server.Strip
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedStrippableComponent))]
|
||||
[Access(typeof(StrippableSystem))]
|
||||
public sealed class StrippableComponent : SharedStrippableComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The strip delay for hands.
|
||||
/// </summary>
|
||||
[DataField("handDelay")]
|
||||
public float HandStripDelay = 4f;
|
||||
|
||||
public override bool Drop(DragDropEvent args)
|
||||
{
|
||||
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<StrippableSystem>().StartOpeningStripper(args.User, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Dictionary<EntityUid, CancellationTokenSource> CancelTokens = new();
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,11 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Strip;
|
||||
|
||||
namespace Content.Server.Strip
|
||||
{
|
||||
public sealed class StrippableSystem : EntitySystem
|
||||
public sealed class StrippableSystem : SharedStrippableSystem
|
||||
{
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
@@ -104,8 +105,10 @@ namespace Content.Server.Strip
|
||||
TakeItemFromHands(user, handId, component);
|
||||
}
|
||||
|
||||
public void StartOpeningStripper(EntityUid user, StrippableComponent component, bool openInCombat = false)
|
||||
public override void StartOpeningStripper(EntityUid user, StrippableComponent component, bool openInCombat = false)
|
||||
{
|
||||
base.StartOpeningStripper(user, component, openInCombat);
|
||||
|
||||
if (TryComp<SharedCombatModeComponent>(user, out var mode) && mode.IsInCombatMode && !openInCombat)
|
||||
return;
|
||||
|
||||
@@ -446,25 +449,5 @@ namespace Content.Server.Strip
|
||||
// hand update will trigger strippable update
|
||||
_adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):user} has stripped the item {ToPrettyString(held):item} from {ToPrettyString(component.Owner):target}");
|
||||
}
|
||||
|
||||
private sealed class OpenStrippingCompleteEvent
|
||||
{
|
||||
public readonly EntityUid User;
|
||||
|
||||
public OpenStrippingCompleteEvent(EntityUid user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class OpenStrippingCancelledEvent
|
||||
{
|
||||
public readonly EntityUid User;
|
||||
|
||||
public OpenStrippingCancelledEvent(EntityUid user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user