Drone Interaction Checks & Cleanup (#6731)
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
using Content.Shared.Drone;
|
|
||||||
// yeah this is just required for prediction
|
|
||||||
|
|
||||||
public sealed class DroneSystem : SharedDroneSystem {}
|
|
||||||
@@ -1,13 +1,16 @@
|
|||||||
using Content.Shared.Drone;
|
using Content.Shared.Drone;
|
||||||
using Content.Server.Drone.Components;
|
using Content.Server.Drone.Components;
|
||||||
using Content.Shared.Drone.Components;
|
|
||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
|
using Content.Shared.MobState.Components;
|
||||||
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Interaction.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.Ghost.Roles.Components;
|
using Content.Server.Ghost.Roles.Components;
|
||||||
using Content.Server.Hands.Components;
|
using Content.Server.Hands.Components;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Emoting;
|
using Content.Shared.Emoting;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
@@ -21,6 +24,8 @@ namespace Content.Server.Drone
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<DroneComponent, InteractionAttemptEvent>(OnInteractionAttempt);
|
||||||
|
SubscribeLocalEvent<DroneComponent, UserOpenActivatableUIAttemptEvent>(OnActivateUIAttempt);
|
||||||
SubscribeLocalEvent<DroneComponent, MobStateChangedEvent>(OnMobStateChanged);
|
SubscribeLocalEvent<DroneComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||||
SubscribeLocalEvent<DroneComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<DroneComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<DroneComponent, MindAddedMessage>(OnMindAdded);
|
SubscribeLocalEvent<DroneComponent, MindAddedMessage>(OnMindAdded);
|
||||||
@@ -28,6 +33,19 @@ namespace Content.Server.Drone
|
|||||||
SubscribeLocalEvent<DroneComponent, EmoteAttemptEvent>(OnEmoteAttempt);
|
SubscribeLocalEvent<DroneComponent, EmoteAttemptEvent>(OnEmoteAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (HasComp<MobStateComponent>(args.Target) && !HasComp<DroneComponent>(args.Target))
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnActivateUIAttempt(EntityUid uid, DroneComponent component, UserOpenActivatableUIAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExamined(EntityUid uid, DroneComponent component, ExaminedEvent args)
|
private void OnExamined(EntityUid uid, DroneComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (args.IsInDetailsRange)
|
if (args.IsInDetailsRange)
|
||||||
@@ -75,7 +93,7 @@ namespace Content.Server.Drone
|
|||||||
foreach (var entry in drone.Tools)
|
foreach (var entry in drone.Tools)
|
||||||
{
|
{
|
||||||
var item = EntityManager.SpawnEntity(entry.PrototypeId, spawnCoord);
|
var item = EntityManager.SpawnEntity(entry.PrototypeId, spawnCoord);
|
||||||
AddComp<DroneToolComponent>(item);
|
AddComp<UnremoveableComponent>(item);
|
||||||
hands.PutInHand(item);
|
hands.PutInHand(item);
|
||||||
drone.ToolUids.Add(item);
|
drone.ToolUids.Add(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Server.Administration.Managers;
|
using Content.Server.Administration.Managers;
|
||||||
using Content.Server.Ghost.Components;
|
using Content.Server.Ghost.Components;
|
||||||
using Content.Shared.ActionBlocker;
|
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Popups;
|
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
|
|
||||||
namespace Content.Server.UserInterface
|
namespace Content.Server.UserInterface
|
||||||
{
|
{
|
||||||
@@ -95,8 +89,10 @@ namespace Content.Server.UserInterface
|
|||||||
// If we've gotten this far, fire a cancellable event that indicates someone is about to activate this.
|
// If we've gotten this far, fire a cancellable event that indicates someone is about to activate this.
|
||||||
// This is so that stuff can require further conditions (like power).
|
// This is so that stuff can require further conditions (like power).
|
||||||
var oae = new ActivatableUIOpenAttemptEvent(user);
|
var oae = new ActivatableUIOpenAttemptEvent(user);
|
||||||
|
var uae = new UserOpenActivatableUIAttemptEvent(user);
|
||||||
|
RaiseLocalEvent(user, uae, false);
|
||||||
RaiseLocalEvent((aui).Owner, oae, false);
|
RaiseLocalEvent((aui).Owner, oae, false);
|
||||||
if (oae.Cancelled) return false;
|
if (oae.Cancelled || uae.Cancelled) return false;
|
||||||
|
|
||||||
SetCurrentSingleUser((aui).Owner, actor.PlayerSession, aui);
|
SetCurrentSingleUser((aui).Owner, actor.PlayerSession, aui);
|
||||||
ui.Toggle(actor.PlayerSession);
|
ui.Toggle(actor.PlayerSession);
|
||||||
@@ -131,6 +127,14 @@ namespace Content.Server.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UserOpenActivatableUIAttemptEvent : CancellableEntityEventArgs //have to one-up the already stroke-inducing name
|
||||||
|
{
|
||||||
|
public EntityUid User { get; }
|
||||||
|
public UserOpenActivatableUIAttemptEvent(EntityUid who)
|
||||||
|
{
|
||||||
|
User = who;
|
||||||
|
}
|
||||||
|
}
|
||||||
public sealed class ActivatableUIPlayerChangedEvent : EntityEventArgs
|
public sealed class ActivatableUIPlayerChangedEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Analyzers;
|
|
||||||
using Robust.Shared.GameStates;
|
|
||||||
|
|
||||||
namespace Content.Shared.Drone.Components
|
|
||||||
{
|
|
||||||
[RegisterComponent]
|
|
||||||
[NetworkedComponent]
|
|
||||||
public sealed class DroneToolComponent : Component {}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Containers;
|
|
||||||
using Content.Shared.Drone.Components;
|
|
||||||
|
|
||||||
namespace Content.Shared.Drone
|
namespace Content.Shared.Drone
|
||||||
{
|
{
|
||||||
@@ -9,15 +7,8 @@ namespace Content.Shared.Drone
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<DroneToolComponent, ContainerGettingRemovedAttemptEvent>(OnRemoveAttempt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRemoveAttempt(EntityUid uid, DroneToolComponent tool, ContainerGettingRemovedAttemptEvent args)
|
|
||||||
{
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum DroneVisuals : byte
|
public enum DroneVisuals : byte
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Interaction.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
[NetworkedComponent]
|
||||||
|
public sealed class UnremoveableComponent : Component {}
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ using Content.Shared.CombatMode;
|
|||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
|
using Content.Shared.Interaction.Helpers;
|
||||||
|
using Content.Shared.Interaction.Components;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
@@ -54,6 +56,7 @@ namespace Content.Shared.Interaction
|
|||||||
{
|
{
|
||||||
SubscribeLocalEvent<BoundUserInterfaceMessageAttempt>(OnBoundInterfaceInteractAttempt);
|
SubscribeLocalEvent<BoundUserInterfaceMessageAttempt>(OnBoundInterfaceInteractAttempt);
|
||||||
SubscribeAllEvent<InteractInventorySlotEvent>(HandleInteractInventorySlotEvent);
|
SubscribeAllEvent<InteractInventorySlotEvent>(HandleInteractInventorySlotEvent);
|
||||||
|
SubscribeLocalEvent<UnremoveableComponent, ContainerGettingRemovedAttemptEvent>(OnRemoveAttempt);
|
||||||
|
|
||||||
CommandBinds.Builder
|
CommandBinds.Builder
|
||||||
.Bind(ContentKeyFunctions.AltActivateItemInWorld,
|
.Bind(ContentKeyFunctions.AltActivateItemInWorld,
|
||||||
@@ -91,6 +94,15 @@ namespace Content.Shared.Interaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prevents an item with the Unremovable component from being removed from a container by almost any means
|
||||||
|
/// </summary>
|
||||||
|
private void OnRemoveAttempt(EntityUid uid, UnremoveableComponent item, ContainerGettingRemovedAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the event were a client uses an item in their inventory or in their hands, either by
|
/// Handles the event were a client uses an item in their inventory or in their hands, either by
|
||||||
/// alt-clicking it or pressing 'E' while hovering over it.
|
/// alt-clicking it or pressing 'E' while hovering over it.
|
||||||
|
|||||||
Reference in New Issue
Block a user