using Content.Shared.Emoting; using Content.Shared.Hands; using Content.Shared.Interaction.Events; using Content.Shared.Item; using Content.Shared.Popups; using Robust.Shared.Serialization; namespace Content.Shared.Ghost { /// /// System for the . /// Prevents ghosts from interacting when is false. /// public abstract class SharedGhostSystem : EntitySystem { [Dependency] protected readonly SharedPopupSystem Popup = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttemptInteract); SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); SubscribeLocalEvent(OnAttempt); } private void OnAttemptInteract(Entity ent, ref InteractionAttemptEvent args) { if (!ent.Comp.CanGhostInteract) args.Cancelled = true; } private void OnAttempt(EntityUid uid, GhostComponent component, CancellableEntityEventArgs args) { if (!component.CanGhostInteract) 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) { 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) { SetCanReturnToBody((uid, component), value); } [Obsolete("Use the Entity overload")] public void SetCanReturnToBody(GhostComponent component, bool 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); } } /// /// A client to server request to get places a ghost can warp to. /// Response is sent via /// [Serializable, NetSerializable] public sealed class GhostWarpsRequestEvent : EntityEventArgs { } /// /// An individual place a ghost can warp to. /// This is used as part of /// [Serializable, NetSerializable] public struct GhostWarp { public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint) { Entity = entity; DisplayName = displayName; IsWarpPoint = isWarpPoint; } /// /// The entity representing the warp point. /// This is passed back to the server in /// public NetEntity Entity { get; } /// /// The display name to be surfaced in the ghost warps menu /// public string DisplayName { get; } /// /// Whether this warp represents a warp point or a player /// public bool IsWarpPoint { get; } } /// /// A server to client response for a . /// Contains players, and locations a ghost can warp to /// [Serializable, NetSerializable] public sealed class GhostWarpsResponseEvent : EntityEventArgs { public GhostWarpsResponseEvent(List warps) { Warps = warps; } /// /// A list of warp points. /// public List Warps { get; } } /// /// A client to server request for their ghost to be warped to an entity /// [Serializable, NetSerializable] public sealed class GhostWarpToTargetRequestEvent : EntityEventArgs { public NetEntity Target { get; } public GhostWarpToTargetRequestEvent(NetEntity target) { Target = target; } } /// /// A client to server request for their ghost to be warped to the most followed entity. /// [Serializable, NetSerializable] public sealed class GhostnadoRequestEvent : EntityEventArgs; /// /// A client to server request for their ghost to return to body /// [Serializable, NetSerializable] public sealed class GhostReturnToBodyRequest : EntityEventArgs { } /// /// A server to client update with the available ghost role count /// [Serializable, NetSerializable] public sealed class GhostUpdateGhostRoleCountEvent : EntityEventArgs { public int AvailableGhostRoles { get; } public GhostUpdateGhostRoleCountEvent(int availableGhostRoleCount) { AvailableGhostRoles = availableGhostRoleCount; } } }