diff --git a/Content.Server/Administration/Commands/AGhostCommand.cs b/Content.Server/Administration/Commands/AGhostCommand.cs index 09c8d0eb50..1e3c00dffe 100644 --- a/Content.Server/Administration/Commands/AGhostCommand.cs +++ b/Content.Server/Administration/Commands/AGhostCommand.cs @@ -117,6 +117,6 @@ public sealed class AGhostCommand : LocalizedCommands } var comp = _entities.GetComponent(ghost); - ghostSystem.SetCanReturnToBody(comp, canReturn); + ghostSystem.SetCanReturnToBody((ghost, comp), canReturn); } } diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 0cccab64b6..8596927b28 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -489,10 +489,10 @@ namespace Content.Server.Ghost if (mind.Comp.TimeOfDeath.HasValue) { - SetTimeOfDeath(ghost, mind.Comp.TimeOfDeath!.Value, ghostComponent); + SetTimeOfDeath((ghost, ghostComponent), mind.Comp.TimeOfDeath!.Value); } - SetCanReturnToBody(ghostComponent, canReturn); + SetCanReturnToBody((ghost, ghostComponent), canReturn); if (canReturn) _minds.Visit(mind.Owner, ghost, mind.Comp); diff --git a/Content.Server/Mind/MindSystem.cs b/Content.Server/Mind/MindSystem.cs index 5601f19e58..71d38c688b 100644 --- a/Content.Server/Mind/MindSystem.cs +++ b/Content.Server/Mind/MindSystem.cs @@ -62,7 +62,7 @@ public sealed class MindSystem : SharedMindSystem { TransferTo(mindId, visiting, mind: mind); if (TryComp(visiting, out GhostComponent? ghostComp)) - _ghosts.SetCanReturnToBody(ghostComp, false); + _ghosts.SetCanReturnToBody((visiting, ghostComp), false); return; } @@ -214,7 +214,7 @@ public sealed class MindSystem : SharedMindSystem entity = Spawn(GameTicker.ObserverPrototypeName, position); component = EnsureComp(entity.Value); var ghostComponent = Comp(entity.Value); - _ghosts.SetCanReturnToBody(ghostComponent, false); + _ghosts.SetCanReturnToBody((entity.Value, ghostComponent), false); } var oldEntity = mind.OwnedEntity; diff --git a/Content.Shared/Ghost/GhostComponent.cs b/Content.Shared/Ghost/GhostComponent.cs index 6fbb59a711..84416f8abc 100644 --- a/Content.Shared/Ghost/GhostComponent.cs +++ b/Content.Shared/Ghost/GhostComponent.cs @@ -4,6 +4,10 @@ using Robust.Shared.Prototypes; namespace Content.Shared.Ghost; +/// +/// Represents an observer ghost. +/// Handles limiting interactions, using ghost abilities, ghost visibility, and ghost warping. +/// [RegisterComponent, NetworkedComponent, Access(typeof(SharedGhostSystem))] [AutoGenerateComponentState(true), AutoGenerateComponentPause] public sealed partial class GhostComponent : Component @@ -41,46 +45,47 @@ public sealed partial class GhostComponent : Component // End actions - [ViewVariables(VVAccess.ReadWrite), DataField, AutoPausedField] + /// + /// Time at which the player died and created this ghost. + /// Used to determine votekick eligibility. + /// + /// + /// May not reflect actual time of death if this entity has been paused, + /// but will give an accurate length of time since death. + /// + [DataField, AutoPausedField] public TimeSpan TimeOfDeath = TimeSpan.Zero; - [DataField("booRadius"), ViewVariables(VVAccess.ReadWrite)] + /// + /// Range of the Boo action. + /// + [DataField] public float BooRadius = 3; - [DataField("booMaxTargets"), ViewVariables(VVAccess.ReadWrite)] + /// + /// Maximum number of entities that can affected by the Boo action. + /// + [DataField] public int BooMaxTargets = 3; - // TODO: instead of this funny stuff just give it access and update in system dirtying when needed - [ViewVariables(VVAccess.ReadWrite)] - public bool CanGhostInteract - { - get => _canGhostInteract; - set - { - if (_canGhostInteract == value) return; - _canGhostInteract = value; - Dirty(); - } - } - + /// + /// Is this ghost allowed to interact with entities? + /// + /// + /// Used to allow admins ghosts to interact with the world. + /// Changed by . + /// [DataField("canInteract"), AutoNetworkedField] - private bool _canGhostInteract; + public bool CanGhostInteract; /// - /// Changed by + /// Is this ghost player allowed to return to their original body? /// - // TODO MIRROR change this to use friend classes when thats merged - [ViewVariables(VVAccess.ReadWrite)] - public bool CanReturnToBody - { - get => _canReturnToBody; - set - { - if (_canReturnToBody == value) return; - _canReturnToBody = value; - Dirty(); - } - } + /// + /// Changed by . + /// + [DataField, AutoNetworkedField] + public bool CanReturnToBody; /// /// Ghost color @@ -88,9 +93,6 @@ public sealed partial class GhostComponent : Component /// Used to allow admins to change ghost colors. Should be removed if the capability to edit existing sprite colors is ever added back. [DataField, AutoNetworkedField] public Color Color = Color.White; - - [DataField("canReturnToBody"), AutoNetworkedField] - private bool _canReturnToBody; } public sealed partial class ToggleFoVActionEvent : InstantActionEvent { } diff --git a/Content.Shared/Ghost/SharedGhostSystem.cs b/Content.Shared/Ghost/SharedGhostSystem.cs index 6e62bee131..7d3561a79f 100644 --- a/Content.Shared/Ghost/SharedGhostSystem.cs +++ b/Content.Shared/Ghost/SharedGhostSystem.cs @@ -37,25 +37,68 @@ namespace Content.Shared.Ghost args.Cancel(); } + /// + /// Sets the ghost's time of death. + /// + public void SetTimeOfDeath(Entity entity, TimeSpan value) + { + if (!Resolve(entity, ref entity.Comp)) + return; + + if (entity.Comp.TimeOfDeath == value) + return; + + entity.Comp.TimeOfDeath = value; + Dirty(entity); + } + + [Obsolete("Use the Entity overload")] public void SetTimeOfDeath(EntityUid uid, TimeSpan value, GhostComponent? component) { - if (!Resolve(uid, ref component)) - return; - - component.TimeOfDeath = value; + SetTimeOfDeath((uid, component), value); } + /// + /// Sets whether or not the ghost player is allowed to return to their original body. + /// + public void SetCanReturnToBody(Entity entity, bool value) + { + if (!Resolve(entity, ref entity.Comp)) + return; + + if (entity.Comp.CanReturnToBody == value) + return; + + entity.Comp.CanReturnToBody = value; + Dirty(entity); + } + + [Obsolete("Use the Entity overload")] public void SetCanReturnToBody(EntityUid uid, bool value, GhostComponent? component = null) { - if (!Resolve(uid, ref component)) - return; - - component.CanReturnToBody = value; + SetCanReturnToBody((uid, component), value); } + [Obsolete("Use the Entity overload")] public void SetCanReturnToBody(GhostComponent component, bool value) { - component.CanReturnToBody = value; + SetCanReturnToBody((component.Owner, component), value); + } + + + /// + /// Sets whether the ghost is allowed to interact with other entities. + /// + public void SetCanGhostInteract(Entity entity, bool value) + { + if (!Resolve(entity, ref entity.Comp)) + return; + + if (entity.Comp.CanGhostInteract == value) + return; + + entity.Comp.CanGhostInteract = value; + Dirty(entity); } }