Refactor drone tool checks (#6643)
This commit is contained in:
4
Content.Client/Drone/DroneSystem.cs
Normal file
4
Content.Client/Drone/DroneSystem.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
using Content.Shared.Drone;
|
||||||
|
// yeah this is just required for prediction
|
||||||
|
|
||||||
|
public sealed class DroneSystem : SharedDroneSystem {}
|
||||||
@@ -1,21 +1,13 @@
|
|||||||
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.Drone.Components;
|
||||||
using Content.Shared.Interaction.Events;
|
|
||||||
using Content.Shared.Inventory.Events;
|
|
||||||
using Content.Shared.MobState.Components;
|
|
||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
using Content.Shared.DragDrop;
|
|
||||||
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.Actions.Events;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
|
|
||||||
@@ -29,8 +21,6 @@ namespace Content.Server.Drone
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<DroneComponent, MobStateChangedEvent>(OnMobStateChanged);
|
SubscribeLocalEvent<DroneComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||||
SubscribeLocalEvent<DroneComponent, DisarmAttemptEvent>(OnDisarmAttempt);
|
|
||||||
SubscribeLocalEvent<DroneComponent, DropAttemptEvent>(OnDropAttempt);
|
|
||||||
SubscribeLocalEvent<DroneComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<DroneComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<DroneComponent, MindAddedMessage>(OnMindAdded);
|
SubscribeLocalEvent<DroneComponent, MindAddedMessage>(OnMindAdded);
|
||||||
SubscribeLocalEvent<DroneComponent, MindRemovedMessage>(OnMindRemoved);
|
SubscribeLocalEvent<DroneComponent, MindRemovedMessage>(OnMindRemoved);
|
||||||
@@ -66,16 +56,6 @@ namespace Content.Server.Drone
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisarmAttempt(EntityUid uid, DroneComponent drone, DisarmAttemptEvent args)
|
|
||||||
{
|
|
||||||
TryComp<HandsComponent>(args.TargetUid, out var hands);
|
|
||||||
var item = hands?.GetActiveHandItem;
|
|
||||||
if (TryComp<DroneToolComponent>(item?.Owner, out var itemInHand))
|
|
||||||
{
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnMindAdded(EntityUid uid, DroneComponent drone, MindAddedMessage args)
|
private void OnMindAdded(EntityUid uid, DroneComponent drone, MindAddedMessage args)
|
||||||
{
|
{
|
||||||
UpdateDroneAppearance(uid, DroneStatus.On);
|
UpdateDroneAppearance(uid, DroneStatus.On);
|
||||||
@@ -110,16 +90,6 @@ namespace Content.Server.Drone
|
|||||||
EnsureComp<GhostTakeoverAvailableComponent>(uid);
|
EnsureComp<GhostTakeoverAvailableComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDropAttempt(EntityUid uid, DroneComponent drone, DropAttemptEvent args)
|
|
||||||
{
|
|
||||||
TryComp<HandsComponent>(uid, out var hands);
|
|
||||||
var item = hands?.GetActiveHandItem;
|
|
||||||
if (TryComp<DroneToolComponent>(item?.Owner, out var itemInHand))
|
|
||||||
{
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateDroneAppearance(EntityUid uid, DroneStatus status)
|
private void UpdateDroneAppearance(EntityUid uid, DroneStatus status)
|
||||||
{
|
{
|
||||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Analyzers;
|
using Robust.Shared.Analyzers;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Drone.Components
|
namespace Content.Shared.Drone.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
|
[NetworkedComponent]
|
||||||
public sealed class DroneToolComponent : Component {}
|
public sealed class DroneToolComponent : Component {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,23 @@
|
|||||||
using System;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
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
|
||||||
{
|
{
|
||||||
public abstract class SharedDroneSystem : EntitySystem
|
public abstract class SharedDroneSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
public override void 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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user