Drone 1984 (#7009)
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
using Content.Shared.Drone;
|
||||
using Content.Server.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;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Emoting;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Drone
|
||||
{
|
||||
@@ -22,6 +23,7 @@ namespace Content.Server.Drone
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -37,9 +39,13 @@ namespace Content.Server.Drone
|
||||
|
||||
private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args)
|
||||
{
|
||||
if (HasComp<MobStateComponent>(args.Target) && !HasComp<DroneComponent>(args.Target))
|
||||
{
|
||||
if (NonDronesInRange(uid, component))
|
||||
args.Cancel();
|
||||
|
||||
if (HasComp<SharedItemComponent>(args.Target) && !HasComp<UnremoveableComponent>(args.Target))
|
||||
{
|
||||
if (!_tagSystem.HasAnyTag(args.Target.Value, "DroneUsable", "Trash"))
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +87,6 @@ namespace Content.Server.Drone
|
||||
private void OnMindAdded(EntityUid uid, DroneComponent drone, MindAddedMessage args)
|
||||
{
|
||||
UpdateDroneAppearance(uid, DroneStatus.On);
|
||||
_tagSystem.AddTag(uid, "DoorBumpOpener");
|
||||
_popupSystem.PopupEntity(Loc.GetString("drone-activated"), uid, Filter.Pvs(uid));
|
||||
|
||||
if (drone.AlreadyAwoken == false)
|
||||
@@ -108,7 +113,6 @@ namespace Content.Server.Drone
|
||||
private void OnMindRemoved(EntityUid uid, DroneComponent drone, MindRemovedMessage args)
|
||||
{
|
||||
UpdateDroneAppearance(uid, DroneStatus.Off);
|
||||
_tagSystem.RemoveTag(uid, "DoorBumpOpener");
|
||||
EnsureComp<GhostTakeoverAvailableComponent>(uid);
|
||||
}
|
||||
|
||||
@@ -130,5 +134,19 @@ namespace Content.Server.Drone
|
||||
appearance.SetData(DroneVisuals.Status, status);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NonDronesInRange(EntityUid uid, DroneComponent component)
|
||||
{
|
||||
var xform = Comp<TransformComponent>(uid);
|
||||
foreach (var entity in _lookup.GetEntitiesInRange(xform.MapID, xform.WorldPosition, component.InteractionBlockRange))
|
||||
{
|
||||
if (HasComp<MindComponent>(entity) && !HasComp<DroneComponent>(entity) && !HasComp<GhostComponent>(entity))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("drone-too-close"), uid, Filter.Entities(uid));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user