From 59bd648578e0ad28a9145fe1267be5d885318b36 Mon Sep 17 00:00:00 2001 From: wrexbe <81056464+wrexbe@users.noreply.github.com> Date: Fri, 3 Dec 2021 01:58:03 -0800 Subject: [PATCH] Cleaned shared ghost system (#5653) --- Content.Shared/Ghost/SharedGhostSystem.cs | 93 +++++++++++------------ 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 46e4dfa908..290c0a92e6 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -9,70 +9,48 @@ using Robust.Shared.Serialization; namespace Content.Shared.Ghost { + /// + /// System for the . + /// Prevents ghosts from interacting when is false. + /// public abstract class SharedGhostSystem : EntitySystem { public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnUseAttempt); - SubscribeLocalEvent(OnInteractAttempt); - SubscribeLocalEvent(OnEmoteAttempt); - SubscribeLocalEvent(OnAttackAttempt); - SubscribeLocalEvent(OnDropAttempt); - SubscribeLocalEvent(OnPickupAttempt); + SubscribeLocalEvent(OnAttempt); + SubscribeLocalEvent(OnAttempt); + SubscribeLocalEvent(OnAttempt); + SubscribeLocalEvent(OnAttempt); + SubscribeLocalEvent(OnAttempt); + SubscribeLocalEvent(OnAttempt); } - private void OnUseAttempt(EntityUid uid, SharedGhostComponent component, UseAttemptEvent args) + private void OnAttempt(EntityUid uid, SharedGhostComponent component, CancellableEntityEventArgs args) { if (!component.CanGhostInteract) args.Cancel(); } - private void OnInteractAttempt(EntityUid uid, SharedGhostComponent component, InteractionAttemptEvent args) + public void SetCanReturnToBody(SharedGhostComponent component, bool value) { - if (!component.CanGhostInteract) - args.Cancel(); - } - - private void OnEmoteAttempt(EntityUid uid, SharedGhostComponent component, EmoteAttemptEvent args) - { - args.Cancel(); - } - - private void OnAttackAttempt(EntityUid uid, SharedGhostComponent component, AttackAttemptEvent args) - { - args.Cancel(); - } - - private void OnDropAttempt(EntityUid uid, SharedGhostComponent component, DropAttemptEvent args) - { - if (!component.CanGhostInteract) - args.Cancel(); - } - - private void OnPickupAttempt(EntityUid uid, SharedGhostComponent component, PickupAttemptEvent args) - { - if (!component.CanGhostInteract) - args.Cancel(); - } - - public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn) - { - if (component.CanReturnToBody == canReturn) - { - return; - } - - component.CanReturnToBody = canReturn; - component.Dirty(); + component.CanReturnToBody = value; } } + /// + /// A client to server request to get places a ghost can warp to. + /// Response is sent via + /// [Serializable, NetSerializable] public class GhostWarpsRequestEvent : EntityEventArgs { } + /// + /// A server to client response for a . + /// Contains players, and locations a ghost can warp to + /// [Serializable, NetSerializable] public class GhostWarpsResponseEvent : EntityEventArgs { @@ -82,22 +60,37 @@ namespace Content.Shared.Ghost Players = players; } + /// + /// A list of location names that can be warped to. + /// public List Locations { get; } + /// + /// A dictionary containing the entity id, and name of players that can be warped to. + /// public Dictionary Players { get; } } + /// + /// A client to server request for their ghost to be warped to a location + /// [Serializable, NetSerializable] public class GhostWarpToLocationRequestEvent : EntityEventArgs { + /// + /// The location name to warp to. + /// public string Name { get; } - public GhostWarpToLocationRequestEvent(string name) + public GhostWarpToLocationRequestEvent(string locationName) { - Name = name; + Name = locationName; } } + /// + /// A client to server request for their ghost to be warped to an entity + /// [Serializable, NetSerializable] public class GhostWarpToTargetRequestEvent : EntityEventArgs { @@ -109,19 +102,25 @@ namespace Content.Shared.Ghost } } + /// + /// A client to server request for their ghost to return to body + /// [Serializable, NetSerializable] public class GhostReturnToBodyRequest : EntityEventArgs { } + /// + /// A server to client update with the available ghost role count + /// [Serializable, NetSerializable] public class GhostUpdateGhostRoleCountEvent : EntityEventArgs { public int AvailableGhostRoles { get; } - public GhostUpdateGhostRoleCountEvent(int v) + public GhostUpdateGhostRoleCountEvent(int availableGhostRoleCount) { - AvailableGhostRoles = v; + AvailableGhostRoles = availableGhostRoleCount; } } }