2024-06-26 05:13:42 +03:00
|
|
|
using Content.Shared._White.Antag;
|
2021-10-21 13:03:14 +11:00
|
|
|
using Content.Shared.Emoting;
|
2023-02-14 00:29:34 +11:00
|
|
|
using Content.Shared.Hands;
|
2021-10-21 13:03:14 +11:00
|
|
|
using Content.Shared.Interaction.Events;
|
|
|
|
|
using Content.Shared.Item;
|
2023-09-24 13:34:08 -07:00
|
|
|
using Content.Shared.Popups;
|
2024-06-26 05:13:42 +03:00
|
|
|
using Content.Shared.Roles;
|
2021-06-18 09:56:23 +02:00
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Ghost
|
|
|
|
|
{
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2023-08-25 18:50:46 +10:00
|
|
|
/// System for the <see cref="GhostComponent"/>.
|
|
|
|
|
/// Prevents ghosts from interacting when <see cref="GhostComponent.CanGhostInteract"/> is false.
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
public abstract class SharedGhostSystem : EntitySystem
|
|
|
|
|
{
|
2023-09-24 13:34:08 -07:00
|
|
|
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
|
|
|
|
|
2021-10-21 13:03:14 +11:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2023-08-25 18:50:46 +10:00
|
|
|
SubscribeLocalEvent<GhostComponent, UseAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<GhostComponent, InteractionAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<GhostComponent, EmoteAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<GhostComponent, DropAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<GhostComponent, PickupAttemptEvent>(OnAttempt);
|
2021-10-21 13:03:14 +11:00
|
|
|
}
|
|
|
|
|
|
2023-08-25 18:50:46 +10:00
|
|
|
private void OnAttempt(EntityUid uid, GhostComponent component, CancellableEntityEventArgs args)
|
2021-10-21 13:03:14 +11:00
|
|
|
{
|
|
|
|
|
if (!component.CanGhostInteract)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-25 18:50:46 +10:00
|
|
|
public void SetTimeOfDeath(EntityUid uid, TimeSpan value, GhostComponent? component)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
component.TimeOfDeath = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCanReturnToBody(EntityUid uid, bool value, GhostComponent? component = null)
|
2023-06-21 13:04:07 +12:00
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
component.CanReturnToBody = value;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-25 18:50:46 +10:00
|
|
|
public void SetCanReturnToBody(GhostComponent component, bool value)
|
2021-10-21 13:03:14 +11:00
|
|
|
{
|
2021-12-03 01:58:03 -08:00
|
|
|
component.CanReturnToBody = value;
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2025-03-21 02:20:37 +05:00
|
|
|
public virtual void SetVisible(Entity<GhostComponent?> ghost, bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(ghost.Owner, ref ghost.Comp))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ghost.Comp.Visible = visible;
|
|
|
|
|
Dirty(ghost);
|
|
|
|
|
}
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// A client to server request to get places a ghost can warp to.
|
|
|
|
|
/// Response is sent via <see cref="GhostWarpsResponseEvent"/>
|
|
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostWarpsRequestEvent : EntityEventArgs
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-26 05:13:42 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// An player body a ghost can warp to.
|
|
|
|
|
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public struct GhostWarpPlayer
|
|
|
|
|
{
|
|
|
|
|
public GhostWarpPlayer(NetEntity entity, string playerName, string playerJobName, string playerDepartmentID, bool isGhost, bool isLeft, bool isDead, bool isAlive)
|
|
|
|
|
{
|
|
|
|
|
Entity = entity;
|
|
|
|
|
Name = playerName;
|
|
|
|
|
JobName = playerJobName;
|
|
|
|
|
DepartmentID = playerDepartmentID;
|
|
|
|
|
|
|
|
|
|
IsGhost = isGhost;
|
|
|
|
|
IsLeft = isLeft;
|
|
|
|
|
IsDead = isDead;
|
|
|
|
|
IsAlive = isAlive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The entity representing the warp point.
|
|
|
|
|
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public NetEntity Entity { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display player name to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display player job to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
|
|
public string JobName { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display player department to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DepartmentID { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Is player is ghost
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsGhost { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Is player body alive
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsAlive { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Is player body dead
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsDead { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Is player left from body
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsLeft { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public struct GhostWarpGlobalAntagonist
|
|
|
|
|
{
|
|
|
|
|
public GhostWarpGlobalAntagonist(NetEntity entity, string playerName, string antagonistName, string antagonistDescription, string prototypeID)
|
|
|
|
|
{
|
|
|
|
|
Entity = entity;
|
|
|
|
|
Name = playerName;
|
|
|
|
|
AntagonistName = antagonistName;
|
|
|
|
|
AntagonistDescription = antagonistDescription;
|
|
|
|
|
PrototypeID = prototypeID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The entity representing the warp point.
|
|
|
|
|
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public NetEntity Entity { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display player name to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display antagonist name to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AntagonistName { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display antagonist description to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string AntagonistDescription { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A antagonist prototype id
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string PrototypeID { get; }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2022-09-10 14:47:17 -07:00
|
|
|
/// An individual place a ghost can warp to.
|
|
|
|
|
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
[Serializable, NetSerializable]
|
2024-06-26 05:13:42 +03:00
|
|
|
public struct GhostWarpPlace
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2024-06-26 05:13:42 +03:00
|
|
|
public GhostWarpPlace(NetEntity entity, string name, string description)
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2022-09-10 14:47:17 -07:00
|
|
|
Entity = entity;
|
2024-06-26 05:13:42 +03:00
|
|
|
Name = name;
|
|
|
|
|
Description = description;
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2023-02-14 00:29:34 +11:00
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2022-09-10 14:47:17 -07:00
|
|
|
/// The entity representing the warp point.
|
|
|
|
|
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Entity { get; }
|
|
|
|
|
|
2022-09-10 14:47:17 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// The display name to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
2024-06-26 05:13:42 +03:00
|
|
|
public string Name { get; }
|
2023-09-11 09:42:41 +10:00
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2024-06-26 05:13:42 +03:00
|
|
|
/// The display name to be surfaced in the ghost warps menu
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2024-06-26 05:13:42 +03:00
|
|
|
public string Description { get; }
|
2021-06-18 09:56:23 +02:00
|
|
|
|
2024-06-26 05:13:42 +03:00
|
|
|
}
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2022-09-10 14:47:17 -07:00
|
|
|
/// A server to client response for a <see cref="GhostWarpsRequestEvent"/>.
|
|
|
|
|
/// Contains players, and locations a ghost can warp to
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
[Serializable, NetSerializable]
|
2024-07-06 09:34:29 +03:00
|
|
|
public sealed class GhostWarpsResponseEvent : EntityEventArgs // WD edit
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2024-06-26 05:13:42 +03:00
|
|
|
public GhostWarpsResponseEvent(List<GhostWarpPlayer> players, List<GhostWarpPlace> places, List<GhostWarpGlobalAntagonist> antagonists)
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2024-06-26 05:13:42 +03:00
|
|
|
Players = players;
|
|
|
|
|
Places = places;
|
|
|
|
|
Antagonists = antagonists;
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2022-09-10 14:47:17 -07:00
|
|
|
|
2024-06-26 05:13:42 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// A list of players to teleport.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<GhostWarpPlayer> Players { get; }
|
|
|
|
|
|
2022-09-10 14:47:17 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// A list of warp points.
|
|
|
|
|
/// </summary>
|
2024-06-26 05:13:42 +03:00
|
|
|
public List<GhostWarpPlace> Places { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of antagonists to teleport.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<GhostWarpGlobalAntagonist> Antagonists { get; }
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// A client to server request for their ghost to be warped to an entity
|
|
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostWarpToTargetRequestEvent : EntityEventArgs
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Target { get; }
|
2021-06-18 09:56:23 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public GhostWarpToTargetRequestEvent(NetEntity target)
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
|
|
|
|
Target = target;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-25 21:39:44 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// A client to server request for their ghost to be warped to the most followed entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class GhostnadoRequestEvent : EntityEventArgs;
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// A client to server request for their ghost to return to body
|
|
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostReturnToBodyRequest : EntityEventArgs
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
|
|
|
|
}
|
2021-11-03 23:48:12 +00:00
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
|
|
|
|
/// A server to client update with the available ghost role count
|
|
|
|
|
/// </summary>
|
2021-11-03 23:48:12 +00:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostUpdateGhostRoleCountEvent : EntityEventArgs
|
2021-11-03 23:48:12 +00:00
|
|
|
{
|
|
|
|
|
public int AvailableGhostRoles { get; }
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
public GhostUpdateGhostRoleCountEvent(int availableGhostRoleCount)
|
2021-11-03 23:48:12 +00:00
|
|
|
{
|
2021-12-03 01:58:03 -08:00
|
|
|
AvailableGhostRoles = availableGhostRoleCount;
|
2021-11-03 23:48:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-28 07:13:28 +06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class GhostReturnToRoundRequest : EntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2024-06-26 05:13:42 +03:00
|
|
|
|