From be853b2529c8db655667ff16f2aa96ceb6e11b02 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Sat, 12 Feb 2022 19:14:24 -0500 Subject: [PATCH] Refactor drone tool checks (#6643) --- Content.Client/Drone/DroneSystem.cs | 4 +++ Content.Server/Drone/DroneSystem.cs | 30 ------------------- .../Drone/Components/DroneToolComponent.cs | 2 ++ Content.Shared/Drone/SharedDroneSystem.cs | 16 ++++++++-- 4 files changed, 20 insertions(+), 32 deletions(-) create mode 100644 Content.Client/Drone/DroneSystem.cs diff --git a/Content.Client/Drone/DroneSystem.cs b/Content.Client/Drone/DroneSystem.cs new file mode 100644 index 0000000000..ab00c0f7b1 --- /dev/null +++ b/Content.Client/Drone/DroneSystem.cs @@ -0,0 +1,4 @@ +using Content.Shared.Drone; +// yeah this is just required for prediction + +public sealed class DroneSystem : SharedDroneSystem {} diff --git a/Content.Server/Drone/DroneSystem.cs b/Content.Server/Drone/DroneSystem.cs index 9fdd4a94b8..2d8de11d87 100644 --- a/Content.Server/Drone/DroneSystem.cs +++ b/Content.Server/Drone/DroneSystem.cs @@ -1,21 +1,13 @@ using Content.Shared.Drone; using Content.Server.Drone.Components; using Content.Shared.Drone.Components; -using Content.Shared.Interaction.Events; -using Content.Shared.Inventory.Events; -using Content.Shared.MobState.Components; using Content.Shared.MobState; -using Content.Shared.DragDrop; using Content.Shared.Examine; using Content.Server.Popups; using Content.Server.Mind.Components; using Content.Server.Ghost.Roles.Components; using Content.Server.Hands.Components; using Content.Shared.Body.Components; -using Content.Server.Actions.Events; -using Robust.Shared.IoC; -using Robust.Shared.GameObjects; -using Robust.Shared.Localization; using Robust.Shared.Player; using Content.Shared.Tag; @@ -29,8 +21,6 @@ namespace Content.Server.Drone { base.Initialize(); SubscribeLocalEvent(OnMobStateChanged); - SubscribeLocalEvent(OnDisarmAttempt); - SubscribeLocalEvent(OnDropAttempt); SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnMindAdded); SubscribeLocalEvent(OnMindRemoved); @@ -66,16 +56,6 @@ namespace Content.Server.Drone } } - private void OnDisarmAttempt(EntityUid uid, DroneComponent drone, DisarmAttemptEvent args) - { - TryComp(args.TargetUid, out var hands); - var item = hands?.GetActiveHandItem; - if (TryComp(item?.Owner, out var itemInHand)) - { - args.Cancel(); - } - } - private void OnMindAdded(EntityUid uid, DroneComponent drone, MindAddedMessage args) { UpdateDroneAppearance(uid, DroneStatus.On); @@ -110,16 +90,6 @@ namespace Content.Server.Drone EnsureComp(uid); } - private void OnDropAttempt(EntityUid uid, DroneComponent drone, DropAttemptEvent args) - { - TryComp(uid, out var hands); - var item = hands?.GetActiveHandItem; - if (TryComp(item?.Owner, out var itemInHand)) - { - args.Cancel(); - } - } - private void UpdateDroneAppearance(EntityUid uid, DroneStatus status) { if (TryComp(uid, out var appearance)) diff --git a/Content.Shared/Drone/Components/DroneToolComponent.cs b/Content.Shared/Drone/Components/DroneToolComponent.cs index f25955e827..c43e3c5c45 100644 --- a/Content.Shared/Drone/Components/DroneToolComponent.cs +++ b/Content.Shared/Drone/Components/DroneToolComponent.cs @@ -1,8 +1,10 @@ using Robust.Shared.GameObjects; using Robust.Shared.Analyzers; +using Robust.Shared.GameStates; namespace Content.Shared.Drone.Components { [RegisterComponent] + [NetworkedComponent] public sealed class DroneToolComponent : Component {} } diff --git a/Content.Shared/Drone/SharedDroneSystem.cs b/Content.Shared/Drone/SharedDroneSystem.cs index e29534d3f3..1b29087a7a 100644 --- a/Content.Shared/Drone/SharedDroneSystem.cs +++ b/Content.Shared/Drone/SharedDroneSystem.cs @@ -1,11 +1,23 @@ -using System; -using Robust.Shared.GameObjects; using Robust.Shared.Serialization; +using Robust.Shared.Containers; +using Content.Shared.Drone.Components; namespace Content.Shared.Drone { public abstract class SharedDroneSystem : EntitySystem { + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnRemoveAttempt); + } + + private void OnRemoveAttempt(EntityUid uid, DroneToolComponent tool, ContainerGettingRemovedAttemptEvent args) + { + args.Cancel(); + } + + [Serializable, NetSerializable] public enum DroneVisuals : byte {