Cleaned shared ghost system (#5653)
This commit is contained in:
@@ -9,70 +9,48 @@ using Robust.Shared.Serialization;
|
|||||||
|
|
||||||
namespace Content.Shared.Ghost
|
namespace Content.Shared.Ghost
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// System for the <see cref="SharedGhostComponent"/>.
|
||||||
|
/// Prevents ghosts from interacting when <see cref="SharedGhostComponent.CanGhostInteract"/> is false.
|
||||||
|
/// </summary>
|
||||||
public abstract class SharedGhostSystem : EntitySystem
|
public abstract class SharedGhostSystem : EntitySystem
|
||||||
{
|
{
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SharedGhostComponent, UseAttemptEvent>(OnUseAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, UseAttemptEvent>(OnAttempt);
|
||||||
SubscribeLocalEvent<SharedGhostComponent, InteractionAttemptEvent>(OnInteractAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, InteractionAttemptEvent>(OnAttempt);
|
||||||
SubscribeLocalEvent<SharedGhostComponent, EmoteAttemptEvent>(OnEmoteAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, EmoteAttemptEvent>(OnAttempt);
|
||||||
SubscribeLocalEvent<SharedGhostComponent, AttackAttemptEvent>(OnAttackAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, AttackAttemptEvent>(OnAttempt);
|
||||||
SubscribeLocalEvent<SharedGhostComponent, DropAttemptEvent>(OnDropAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, DropAttemptEvent>(OnAttempt);
|
||||||
SubscribeLocalEvent<SharedGhostComponent, PickupAttemptEvent>(OnPickupAttempt);
|
SubscribeLocalEvent<SharedGhostComponent, PickupAttemptEvent>(OnAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUseAttempt(EntityUid uid, SharedGhostComponent component, UseAttemptEvent args)
|
private void OnAttempt(EntityUid uid, SharedGhostComponent component, CancellableEntityEventArgs args)
|
||||||
{
|
{
|
||||||
if (!component.CanGhostInteract)
|
if (!component.CanGhostInteract)
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInteractAttempt(EntityUid uid, SharedGhostComponent component, InteractionAttemptEvent args)
|
public void SetCanReturnToBody(SharedGhostComponent component, bool value)
|
||||||
{
|
{
|
||||||
if (!component.CanGhostInteract)
|
component.CanReturnToBody = value;
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEmoteAttempt(EntityUid uid, SharedGhostComponent component, EmoteAttemptEvent args)
|
|
||||||
{
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnAttackAttempt(EntityUid uid, SharedGhostComponent component, AttackAttemptEvent args)
|
|
||||||
{
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDropAttempt(EntityUid uid, SharedGhostComponent component, DropAttemptEvent args)
|
|
||||||
{
|
|
||||||
if (!component.CanGhostInteract)
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPickupAttempt(EntityUid uid, SharedGhostComponent component, PickupAttemptEvent args)
|
|
||||||
{
|
|
||||||
if (!component.CanGhostInteract)
|
|
||||||
args.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetCanReturnToBody(SharedGhostComponent component, bool canReturn)
|
|
||||||
{
|
|
||||||
if (component.CanReturnToBody == canReturn)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
component.CanReturnToBody = canReturn;
|
|
||||||
component.Dirty();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client to server request to get places a ghost can warp to.
|
||||||
|
/// Response is sent via <see cref="GhostWarpsResponseEvent"/>
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostWarpsRequestEvent : EntityEventArgs
|
public class GhostWarpsRequestEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A server to client response for a <see cref="GhostWarpsRequestEvent"/>.
|
||||||
|
/// Contains players, and locations a ghost can warp to
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostWarpsResponseEvent : EntityEventArgs
|
public class GhostWarpsResponseEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
@@ -82,22 +60,37 @@ namespace Content.Shared.Ghost
|
|||||||
Players = players;
|
Players = players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of location names that can be warped to.
|
||||||
|
/// </summary>
|
||||||
public List<string> Locations { get; }
|
public List<string> Locations { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A dictionary containing the entity id, and name of players that can be warped to.
|
||||||
|
/// </summary>
|
||||||
public Dictionary<EntityUid, string> Players { get; }
|
public Dictionary<EntityUid, string> Players { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client to server request for their ghost to be warped to a location
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostWarpToLocationRequestEvent : EntityEventArgs
|
public class GhostWarpToLocationRequestEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The location name to warp to.
|
||||||
|
/// </summary>
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
public GhostWarpToLocationRequestEvent(string name)
|
public GhostWarpToLocationRequestEvent(string locationName)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = locationName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client to server request for their ghost to be warped to an entity
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostWarpToTargetRequestEvent : EntityEventArgs
|
public class GhostWarpToTargetRequestEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
@@ -109,19 +102,25 @@ namespace Content.Shared.Ghost
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A client to server request for their ghost to return to body
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostReturnToBodyRequest : EntityEventArgs
|
public class GhostReturnToBodyRequest : EntityEventArgs
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A server to client update with the available ghost role count
|
||||||
|
/// </summary>
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class GhostUpdateGhostRoleCountEvent : EntityEventArgs
|
public class GhostUpdateGhostRoleCountEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
public int AvailableGhostRoles { get; }
|
public int AvailableGhostRoles { get; }
|
||||||
|
|
||||||
public GhostUpdateGhostRoleCountEvent(int v)
|
public GhostUpdateGhostRoleCountEvent(int availableGhostRoleCount)
|
||||||
{
|
{
|
||||||
AvailableGhostRoles = v;
|
AvailableGhostRoles = availableGhostRoleCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user