Reduce action blocker uses and add target entity to CanInteract (#6655)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Clothing.Components;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions.Behaviors.Item;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -50,10 +51,11 @@ namespace Content.Server.Light.Components
|
||||
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public class ToggleLightAction : IToggleItemAction
|
||||
public sealed class ToggleLightAction : IToggleItemAction
|
||||
{
|
||||
public bool DoToggleAction(ToggleItemActionEventArgs args)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(args.Performer, args.Item)) return false;
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<HandheldLightComponent?>(args.Item, out var lightComponent)) return false;
|
||||
if (lightComponent.Activated == args.ToggledOn) return false;
|
||||
return EntitySystem.Get<HandheldLightSystem>().ToggleStatus(args.Performer, lightComponent);
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Content.Server.Light.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public sealed class HandheldLightSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||
|
||||
@@ -96,7 +95,6 @@ namespace Content.Server.Light.EntitySystems
|
||||
/// <returns>True if the light's status was toggled, false otherwise.</returns>
|
||||
public bool ToggleStatus(EntityUid user, HandheldLightComponent component)
|
||||
{
|
||||
if (!_blocker.CanUse(user)) return false;
|
||||
return component.Activated ? TurnOff(component) : TurnOn(user, component);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,8 @@ using Robust.Shared.Player;
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class LightReplacerSystem : EntitySystem
|
||||
public sealed class LightReplacerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly PoweredLightSystem _poweredLight = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
|
||||
@@ -42,7 +41,6 @@ namespace Content.Server.Light.EntitySystems
|
||||
return;
|
||||
|
||||
// standard interaction checks
|
||||
if (!_blocker.CanUse(eventArgs.User)) return;
|
||||
if (!eventArgs.CanReach) return;
|
||||
|
||||
// behaviour will depends on target type
|
||||
@@ -64,9 +62,6 @@ namespace Content.Server.Light.EntitySystems
|
||||
if (eventArgs.Handled)
|
||||
return;
|
||||
|
||||
// standard interaction checks
|
||||
if (!_blocker.CanInteract(eventArgs.User)) return;
|
||||
|
||||
var usedUid = eventArgs.Used;
|
||||
|
||||
// want to insert a new light bulb?
|
||||
|
||||
Reference in New Issue
Block a user