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();
}
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)
{
if (!Resolve(uid, ref component))
return;
component.CanReturnToBody = value;
}
public void SetCanReturnToBody(GhostComponent component, bool value)
{
component.CanReturnToBody = value;
}
}
///
/// 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;
}
}
}