Drone Interaction Checks & Cleanup (#6731)

This commit is contained in:
Rane
2022-02-18 17:57:31 -05:00
committed by GitHub
parent 9f439f1d36
commit 67661ddbdb
7 changed files with 51 additions and 32 deletions

View File

@@ -1,13 +1,16 @@
using Content.Shared.Drone;
using Content.Server.Drone.Components;
using Content.Shared.Drone.Components;
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.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.UserInterface;
using Content.Shared.Emoting;
using Robust.Shared.Player;
using Content.Shared.Tag;
@@ -21,6 +24,8 @@ namespace Content.Server.Drone
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DroneComponent, InteractionAttemptEvent>(OnInteractionAttempt);
SubscribeLocalEvent<DroneComponent, UserOpenActivatableUIAttemptEvent>(OnActivateUIAttempt);
SubscribeLocalEvent<DroneComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<DroneComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<DroneComponent, MindAddedMessage>(OnMindAdded);
@@ -28,6 +33,19 @@ namespace Content.Server.Drone
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)
{
if (args.IsInDetailsRange)
@@ -75,7 +93,7 @@ namespace Content.Server.Drone
foreach (var entry in drone.Tools)
{
var item = EntityManager.SpawnEntity(entry.PrototypeId, spawnCoord);
AddComp<DroneToolComponent>(item);
AddComp<UnremoveableComponent>(item);
hands.PutInHand(item);
drone.ToolUids.Add(item);
}