diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index e5083e3ae0..9e099872d6 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -7,7 +7,6 @@ using Content.Shared.Botany; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reagent; using Content.Shared.FixedPoint; -using Content.Shared.Interaction; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -15,9 +14,7 @@ using Robust.Shared.Timing; namespace Content.Server.Botany.Components { [RegisterComponent] -#pragma warning disable 618 - public sealed class PlantHolderComponent : Component, IInteractHand, IActivate -#pragma warning restore 618 + public sealed class PlantHolderComponent : Component { public const float HydroponicsSpeedMultiplier = 1f; public const float HydroponicsConsumptionMultiplier = 4f; @@ -629,17 +626,5 @@ namespace Content.Server.Botany.Components ForceUpdate = true; Update(); } - - bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) - { - // DoHarvest does the sanity checks. - return DoHarvest(eventArgs.User); - } - - void IActivate.Activate(ActivateEventArgs eventArgs) - { - // DoHarvest does the sanity checks. - DoHarvest(eventArgs.User); - } } } diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs index ca95f50188..ac99986fac 100644 --- a/Content.Server/Botany/Systems/PlantHolderSystem.cs +++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs @@ -32,6 +32,7 @@ namespace Content.Server.Botany.Systems base.Initialize(); SubscribeLocalEvent(OnExamine); SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnInteractHand); } private void OnExamine(EntityUid uid, PlantHolderComponent component, ExaminedEvent args) @@ -257,5 +258,10 @@ namespace Content.Server.Botany.Systems EntityManager.QueueDeleteEntity(args.Used); } } + + private void OnInteractHand(EntityUid uid, PlantHolderComponent component, InteractHandEvent args) + { + component.DoHarvest(args.User); + } } } diff --git a/Content.Server/Buckle/Components/StrapComponent.cs b/Content.Server/Buckle/Components/StrapComponent.cs index ee10b169b3..2995436eaa 100644 --- a/Content.Server/Buckle/Components/StrapComponent.cs +++ b/Content.Server/Buckle/Components/StrapComponent.cs @@ -1,24 +1,17 @@ -using System.Collections.Generic; using System.Linq; using Content.Shared.Acts; using Content.Shared.Alert; using Content.Shared.Buckle.Components; using Content.Shared.DragDrop; -using Content.Shared.Interaction; using Content.Shared.Sound; -using Robust.Server.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Maths; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; + namespace Content.Server.Buckle.Components { [RegisterComponent] [ComponentReference(typeof(SharedStrapComponent))] - public sealed class StrapComponent : SharedStrapComponent, IInteractHand, ISerializationHooks, IDestroyAct + public sealed class StrapComponent : SharedStrapComponent, ISerializationHooks, IDestroyAct { [Dependency] private readonly IEntityManager _entityManager = default!; @@ -216,18 +209,6 @@ namespace Content.Server.Buckle.Components return new StrapComponentState(Position); } - bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) - { - var entManager = IoCManager.Resolve(); - - if (!entManager.TryGetComponent(eventArgs.User, out var buckle)) - { - return false; - } - - return buckle.ToggleBuckle(eventArgs.User, Owner); - } - public override bool DragDropOn(DragDropEvent eventArgs) { var entManager = IoCManager.Resolve(); diff --git a/Content.Server/Buckle/Systems/StrapSystem.cs b/Content.Server/Buckle/Systems/StrapSystem.cs index 0e20cdbd24..62e363eb63 100644 --- a/Content.Server/Buckle/Systems/StrapSystem.cs +++ b/Content.Server/Buckle/Systems/StrapSystem.cs @@ -1,15 +1,12 @@ using Content.Server.Buckle.Components; using Content.Server.Interaction; -using Content.Shared.Body.Components; -using Content.Shared.MobState.Components; +using Content.Shared.Interaction; using Content.Shared.Storage; using Content.Shared.Verbs; using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Containers; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; + namespace Content.Server.Buckle.Systems { @@ -24,6 +21,7 @@ namespace Content.Server.Buckle.Systems SubscribeLocalEvent>(AddStrapVerbs); SubscribeLocalEvent(OnInsertAttempt); + SubscribeLocalEvent(OnInteractHand); } private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args) @@ -33,6 +31,14 @@ namespace Content.Server.Buckle.Systems args.Cancel(); } + private void OnInteractHand(EntityUid uid, StrapComponent component, InteractHandEvent args) + { + if (!TryComp(args.User, out var buckle)) + return; + + buckle.ToggleBuckle(args.User, uid); + } + // TODO ECS BUCKLE/STRAP These 'Strap' verbs are an incestuous mess of buckle component and strap component // functions. Whenever these are fully ECSed, maybe do it in a way that allows for these verbs to be handled in // a sensible manner in a single system? diff --git a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs index f5eb6122df..df18b5617e 100644 --- a/Content.Server/Singularity/Components/RadiationCollectorComponent.cs +++ b/Content.Server/Singularity/Components/RadiationCollectorComponent.cs @@ -1,66 +1,34 @@ -using System; using Content.Server.Power.Components; -using Content.Shared.Interaction; -using Content.Shared.Popups; using Content.Shared.Radiation; using Content.Shared.Singularity.Components; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; -using Robust.Shared.Timing; -using Robust.Shared.ViewVariables; namespace Content.Server.Singularity.Components { [RegisterComponent] - public sealed class RadiationCollectorComponent : Component, IInteractHand, IRadiationAct + public sealed class RadiationCollectorComponent : Component, IRadiationAct { - [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IEntityManager _entMan = default!; - private bool _enabled; - private TimeSpan _coolDownEnd; + public bool Enabled; + public TimeSpan CoolDownEnd; [ViewVariables(VVAccess.ReadWrite)] public bool Collecting { - get => _enabled; + get => Enabled; set { - if (_enabled == value) return; - _enabled = value; - SetAppearance(_enabled ? RadiationCollectorVisualState.Activating : RadiationCollectorVisualState.Deactivating); + if (Enabled == value) return; + Enabled = value; + SetAppearance(Enabled ? RadiationCollectorVisualState.Activating : RadiationCollectorVisualState.Deactivating); } } [ViewVariables(VVAccess.ReadWrite)] public float ChargeModifier = 30000f; - bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs) - { - var curTime = _gameTiming.CurTime; - - if(curTime < _coolDownEnd) - return true; - - if (!_enabled) - { - Owner.PopupMessage(eventArgs.User, Loc.GetString("radiation-collector-component-use-on")); - Collecting = true; - } - else - { - Owner.PopupMessage(eventArgs.User, Loc.GetString("radiation-collector-component-use-off")); - Collecting = false; - } - - _coolDownEnd = curTime + TimeSpan.FromSeconds(0.81f); - - return true; - } - void IRadiationAct.RadiationAct(float frameTime, SharedRadiationPulseComponent radiation) { - if (!_enabled) return; + if (!Enabled) return; // No idea if this is even vaguely accurate to the previous logic. // The maths is copied from that logic even though it works differently. @@ -73,7 +41,7 @@ namespace Content.Server.Singularity.Components } } - private void SetAppearance(RadiationCollectorVisualState state) + public void SetAppearance(RadiationCollectorVisualState state) { if (IoCManager.Resolve().TryGetComponent(Owner, out var appearance)) { diff --git a/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs new file mode 100644 index 0000000000..18a0c4a390 --- /dev/null +++ b/Content.Server/Singularity/EntitySystems/RadiationCollectorSystem.cs @@ -0,0 +1,41 @@ +using Content.Server.Singularity.Components; +using Content.Shared.Interaction; +using Content.Shared.Singularity.Components; +using Content.Server.Popups; +using Robust.Shared.Timing; +using Robust.Shared.Player; + +namespace Content.Server.Singularity.EntitySystems +{ + public sealed class RadiationCollectorSystem : EntitySystem + { + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly PopupSystem _popupSystem = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractHand); + } + + private void OnInteractHand(EntityUid uid, RadiationCollectorComponent component, InteractHandEvent args) + { + var curTime = _gameTiming.CurTime; + + if(curTime < component.CoolDownEnd) + return; + + if (!component.Enabled) + { + _popupSystem.PopupEntity(Loc.GetString("radiation-collector-component-use-on"), uid, Filter.Pvs(args.User)); + component.Collecting = true; + } + else + { + _popupSystem.PopupEntity(Loc.GetString("radiation-collector-component-use-off"), uid, Filter.Pvs(args.User)); + component.Collecting = false; + } + + component.CoolDownEnd = curTime + TimeSpan.FromSeconds(0.81f); + } + } +} diff --git a/Content.Shared/Interaction/IInteractHand.cs b/Content.Shared/Interaction/InteractHand.cs similarity index 61% rename from Content.Shared/Interaction/IInteractHand.cs rename to Content.Shared/Interaction/InteractHand.cs index 2ef7e881d0..c4b9b99ffd 100644 --- a/Content.Shared/Interaction/IInteractHand.cs +++ b/Content.Shared/Interaction/InteractHand.cs @@ -1,24 +1,7 @@ -using System; using JetBrains.Annotations; -using Robust.Shared.Analyzers; -using Robust.Shared.GameObjects; namespace Content.Shared.Interaction { - /// - /// This interface gives components behavior when being clicked on by a user with an empty hand - /// who is in range and has unobstructed reach of the target entity (allows inside blockers). - /// - [RequiresExplicitImplementation] - public interface IInteractHand - { - /// - /// Called when a player directly interacts with an empty hand when user is in range of the target entity. - /// - [Obsolete("Use InteractHandEvent instead")] - bool InteractHand(InteractHandEventArgs eventArgs); - } - public sealed class InteractHandEventArgs : EventArgs, ITargetedInteractEventArgs { public InteractHandEventArgs(EntityUid user, EntityUid target) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index a86c3a980a..191c1592e0 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -272,17 +272,6 @@ namespace Content.Shared.Interaction if (message.Handled) return; - var interactHandEventArgs = new InteractHandEventArgs(user, target); - var interactHandComps = AllComps(target).ToList(); - foreach (var interactHandComp in interactHandComps) - { - // If an InteractHand returns a status completion we finish our interaction -#pragma warning disable 618 - if (interactHandComp.InteractHand(interactHandEventArgs)) -#pragma warning restore 618 - return; - } - // Else we run Activate. InteractionActivate(user, target, checkCanInteract: false, @@ -439,7 +428,7 @@ namespace Content.Shared.Interaction CollisionGroup collisionMask = CollisionGroup.Impassable, Ignored? predicate = null, bool popup = false) - {; + {; Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false); var inRange = InRangeUnobstructed(Transform(origin).MapPosition, other, range, collisionMask, combinedPredicate);