2021-10-21 13:03:14 +11:00
|
|
|
using Content.Shared.DragDrop;
|
|
|
|
|
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;
|
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>
|
|
|
|
|
/// System for the <see cref="SharedGhostComponent"/>.
|
|
|
|
|
/// Prevents ghosts from interacting when <see cref="SharedGhostComponent.CanGhostInteract"/> is false.
|
|
|
|
|
/// </summary>
|
2021-06-18 09:56:23 +02:00
|
|
|
public abstract class SharedGhostSystem : EntitySystem
|
|
|
|
|
{
|
2021-10-21 13:03:14 +11:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2021-12-03 01:58:03 -08:00
|
|
|
SubscribeLocalEvent<SharedGhostComponent, UseAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<SharedGhostComponent, InteractionAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<SharedGhostComponent, EmoteAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<SharedGhostComponent, DropAttemptEvent>(OnAttempt);
|
|
|
|
|
SubscribeLocalEvent<SharedGhostComponent, PickupAttemptEvent>(OnAttempt);
|
2021-10-21 13:03:14 +11:00
|
|
|
}
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
private void OnAttempt(EntityUid uid, SharedGhostComponent component, CancellableEntityEventArgs args)
|
2021-10-21 13:03:14 +11:00
|
|
|
{
|
|
|
|
|
if (!component.CanGhostInteract)
|
|
|
|
|
args.Cancel();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 13:04:07 +12:00
|
|
|
public void SetCanReturnToBody(EntityUid uid, bool value, SharedGhostComponent? component = null)
|
|
|
|
|
{
|
|
|
|
|
if (!Resolve(uid, ref component))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
component.CanReturnToBody = value;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 01:58:03 -08:00
|
|
|
public void SetCanReturnToBody(SharedGhostComponent 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
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]
|
2022-09-10 14:47:17 -07:00
|
|
|
public struct GhostWarp
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2022-09-10 14:47:17 -07:00
|
|
|
public GhostWarp(EntityUid entity, string displayName, bool isWarpPoint)
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2022-09-10 14:47:17 -07:00
|
|
|
Entity = entity;
|
|
|
|
|
DisplayName = displayName;
|
|
|
|
|
IsWarpPoint = isWarpPoint;
|
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>
|
2022-09-10 14:47:17 -07:00
|
|
|
public EntityUid Entity { get; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The display name to be surfaced in the ghost warps menu
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string DisplayName { get; }
|
2021-12-03 01:58:03 -08:00
|
|
|
/// <summary>
|
2022-09-10 14:47:17 -07:00
|
|
|
/// Whether this warp represents a warp point or a player
|
2021-12-03 01:58:03 -08:00
|
|
|
/// </summary>
|
2022-09-10 14:47:17 -07:00
|
|
|
public bool IsWarpPoint { get; }
|
2021-06-18 09:56:23 +02: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]
|
2022-09-10 14:47:17 -07:00
|
|
|
public sealed class GhostWarpsResponseEvent : EntityEventArgs
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2022-09-10 14:47:17 -07:00
|
|
|
public GhostWarpsResponseEvent(List<GhostWarp> warps)
|
2021-06-18 09:56:23 +02:00
|
|
|
{
|
2022-09-10 14:47:17 -07:00
|
|
|
Warps = warps;
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|
2022-09-10 14:47:17 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A list of warp points.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<GhostWarp> Warps { 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
|
|
|
{
|
|
|
|
|
public EntityUid Target { get; }
|
|
|
|
|
|
|
|
|
|
public GhostWarpToTargetRequestEvent(EntityUid target)
|
|
|
|
|
{
|
|
|
|
|
Target = target;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
2021-06-18 09:56:23 +02:00
|
|
|
}
|