More DoAfter Changes (#14609)

* DoAfters

* Compact Clone()

* Fix mice and cuffables

* Try generalize attempt events

* moves climbabledoafter event to shared, fixes issue with climbable target

* Fix merge (cuffing)

* Make all events netserializable

* handful of doafter events moved

* moves the rest of the events to their respective shared folders

* Changes all mentions of server doafter to shared

* stop stripping cancellation

* fix merge errors

* draw paused doafters

* handle unpausing

* missing netserializable ref

* removes break on stun reference

* removes cuffing state reference

* Fix tools

* Fix door prying.

* Fix construction

* Fix dumping

* Fix wielding assert

* fix rev

* Fix test

* more test fixes

---------

Co-authored-by: keronshb <keronshb@live.com>
This commit is contained in:
Leon Friedrich
2023-04-03 13:13:48 +12:00
committed by GitHub
parent 9e66fac805
commit 19277a2276
170 changed files with 3042 additions and 2954 deletions

View File

@@ -1,5 +1,6 @@
using System.Linq;
using Content.Shared.Chat;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
@@ -11,6 +12,7 @@ using Content.Shared.Wires;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.Shared.Radio.EntitySystems;
@@ -40,16 +42,13 @@ public sealed class EncryptionKeySystem : EntitySystem
SubscribeLocalEvent<EncryptionKeyHolderComponent, EntInsertedIntoContainerMessage>(OnContainerModified);
SubscribeLocalEvent<EncryptionKeyHolderComponent, EntRemovedFromContainerMessage>(OnContainerModified);
SubscribeLocalEvent<EncryptionKeyHolderComponent, EncryptionRemovalFinishedEvent>(OnKeyRemoval);
SubscribeLocalEvent<EncryptionKeyHolderComponent, EncryptionRemovalCancelledEvent>(OnKeyCancelled);
}
private void OnKeyCancelled(EntityUid uid, EncryptionKeyHolderComponent component, EncryptionRemovalCancelledEvent args)
{
component.Removing = false;
}
private void OnKeyRemoval(EntityUid uid, EncryptionKeyHolderComponent component, EncryptionRemovalFinishedEvent args)
{
if (args.Cancelled)
return;
var contained = component.KeyContainer.ContainedEntities.ToArray();
_container.EmptyContainer(component.KeyContainer, reparent: false);
foreach (var ent in contained)
@@ -60,7 +59,6 @@ public sealed class EncryptionKeySystem : EntitySystem
// if tool use ever gets predicted this needs changing.
_popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User);
_audio.PlayPvs(component.KeyExtractionSound, uid);
component.Removing = false;
}
public void UpdateChannels(EntityUid uid, EncryptionKeyHolderComponent component)
@@ -91,14 +89,18 @@ public sealed class EncryptionKeySystem : EntitySystem
private void OnInteractUsing(EntityUid uid, EncryptionKeyHolderComponent component, InteractUsingEvent args)
{
if (!TryComp<ContainerManagerComponent>(uid, out var _) || args.Handled || component.Removing)
if ( args.Handled || !TryComp<ContainerManagerComponent>(uid, out var storage))
return;
args.Handled = true;
if (!component.KeysUnlocked)
{
if (_net.IsClient && _timing.IsFirstTimePredicted)
_popup.PopupEntity(Loc.GetString("encryption-keys-are-locked"), uid, args.User);
return;
}
if (TryComp<EncryptionKeyComponent>(args.Used, out var key))
{
TryInsertKey(uid, component, args);
@@ -154,14 +156,7 @@ public sealed class EncryptionKeySystem : EntitySystem
return;
}
if (_net.IsServer)
{
//This is honestly the poor mans fix because the InteractUsingEvent fires off 12 times
component.Removing = true;
var toolEvData = new ToolEventData(new EncryptionRemovalFinishedEvent(args.User), cancelledEv: new EncryptionRemovalCancelledEvent(), targetEntity: uid);
if (_tool.UseTool(args.Used, args.User, uid, 1f, new[] { component.KeysExtractionMethod }, toolEvData, toolComponent: tool))
args.Handled = true;
}
_tool.UseTool(args.Used, args.User, uid, 1f, component.KeysExtractionMethod, new EncryptionRemovalFinishedEvent(), toolComponent: tool);
}
private void OnStartup(EntityUid uid, EncryptionKeyHolderComponent component, ComponentStartup args)
@@ -244,18 +239,8 @@ public sealed class EncryptionKeySystem : EntitySystem
}
}
public sealed class EncryptionRemovalFinishedEvent : EntityEventArgs
[Serializable, NetSerializable]
public sealed class EncryptionRemovalFinishedEvent : SimpleDoAfterEvent
{
public EntityUid User;
public EncryptionRemovalFinishedEvent(EntityUid user)
{
User = user;
}
}
public sealed class EncryptionRemovalCancelledEvent : EntityEventArgs
{
}
}