|
@@ -91,6 +91,7 @@ public override void Initialize()
|
|
|
|
|
|
|
|
SubscribeNetworkEvent<GhostWarpsRequestEvent>(OnGhostWarpsRequest);
|
|
SubscribeNetworkEvent<GhostWarpsRequestEvent>(OnGhostWarpsRequest);
|
|
|
SubscribeNetworkEvent<GhostReturnToBodyRequest>(OnGhostReturnToBodyRequest);
|
|
SubscribeNetworkEvent<GhostReturnToBodyRequest>(OnGhostReturnToBodyRequest);
|
|
|
|
|
+ SubscribeNetworkEvent<GhostReturnToLobbyRequest>(OnGhostReturnToLobbyRequest);
|
|
|
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
|
|
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
|
|
|
SubscribeNetworkEvent<GhostnadoRequestEvent>(OnGhostnadoRequest);
|
|
SubscribeNetworkEvent<GhostnadoRequestEvent>(OnGhostnadoRequest);
|
|
|
|
|
|
|
@@ -192,8 +193,8 @@ private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentSt
|
|
|
|
|
|
|
|
if (_gameTicker.RunLevel != GameRunLevel.PostRound)
|
|
if (_gameTicker.RunLevel != GameRunLevel.PostRound)
|
|
|
{
|
|
{
|
|
|
- _visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Ghost, false);
|
|
|
|
|
- _visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Normal, false);
|
|
|
|
|
|
|
+ _visibilitySystem.AddLayer((uid, visibility), (int)VisibilityFlags.Ghost, false);
|
|
|
|
|
+ _visibilitySystem.RemoveLayer((uid, visibility), (int)VisibilityFlags.Normal, false);
|
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -211,8 +212,8 @@ private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentS
|
|
|
// Entity can't be seen by ghosts anymore.
|
|
// Entity can't be seen by ghosts anymore.
|
|
|
if (TryComp(uid, out VisibilityComponent? visibility))
|
|
if (TryComp(uid, out VisibilityComponent? visibility))
|
|
|
{
|
|
{
|
|
|
- _visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Ghost, false);
|
|
|
|
|
- _visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Normal, false);
|
|
|
|
|
|
|
+ _visibilitySystem.RemoveLayer((uid, visibility), (int)VisibilityFlags.Ghost, false);
|
|
|
|
|
+ _visibilitySystem.AddLayer((uid, visibility), (int)VisibilityFlags.Normal, false);
|
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -269,7 +270,7 @@ private void DeleteEntity(EntityUid uid)
|
|
|
|
|
|
|
|
private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySessionEventArgs args)
|
|
private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySessionEventArgs args)
|
|
|
{
|
|
{
|
|
|
- if (args.SenderSession.AttachedEntity is not {Valid: true} attached
|
|
|
|
|
|
|
+ if (args.SenderSession.AttachedEntity is not { Valid: true } attached
|
|
|
|| !_ghostQuery.TryComp(attached, out var ghost)
|
|
|| !_ghostQuery.TryComp(attached, out var ghost)
|
|
|
|| !ghost.CanReturnToBody
|
|
|| !ghost.CanReturnToBody
|
|
|
|| !TryComp(attached, out ActorComponent? actor))
|
|
|| !TryComp(attached, out ActorComponent? actor))
|
|
@@ -281,11 +282,16 @@ private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySess
|
|
|
_mind.UnVisit(actor.PlayerSession);
|
|
_mind.UnVisit(actor.PlayerSession);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void OnGhostReturnToLobbyRequest(GhostReturnToLobbyRequest msg, EntitySessionEventArgs args)
|
|
|
|
|
+ {
|
|
|
|
|
+ _gameTicker.PlayerJoinLobby(args.SenderSession);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#region Warp
|
|
#region Warp
|
|
|
|
|
|
|
|
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
|
|
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
|
|
|
{
|
|
{
|
|
|
- if (args.SenderSession.AttachedEntity is not {Valid: true} entity
|
|
|
|
|
|
|
+ if (args.SenderSession.AttachedEntity is not { Valid: true } entity
|
|
|
|| !_ghostQuery.HasComp(entity))
|
|
|| !_ghostQuery.HasComp(entity))
|
|
|
{
|
|
{
|
|
|
Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
|
Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
|
@@ -298,7 +304,7 @@ private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventA
|
|
|
|
|
|
|
|
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
|
|
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
|
|
|
{
|
|
{
|
|
|
- if (args.SenderSession.AttachedEntity is not {Valid: true} attached
|
|
|
|
|
|
|
+ if (args.SenderSession.AttachedEntity is not { Valid: true } attached
|
|
|
|| !_ghostQuery.HasComp(attached))
|
|
|| !_ghostQuery.HasComp(attached))
|
|
|
{
|
|
{
|
|
|
Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
|
Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
|
@@ -318,14 +324,14 @@ private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, Entit
|
|
|
|
|
|
|
|
private void OnGhostnadoRequest(GhostnadoRequestEvent msg, EntitySessionEventArgs args)
|
|
private void OnGhostnadoRequest(GhostnadoRequestEvent msg, EntitySessionEventArgs args)
|
|
|
{
|
|
{
|
|
|
- if (args.SenderSession.AttachedEntity is not {} uid
|
|
|
|
|
|
|
+ if (args.SenderSession.AttachedEntity is not { } uid
|
|
|
|| !_ghostQuery.HasComp(uid))
|
|
|| !_ghostQuery.HasComp(uid))
|
|
|
{
|
|
{
|
|
|
Log.Warning($"User {args.SenderSession.Name} tried to ghostnado without being a ghost.");
|
|
Log.Warning($"User {args.SenderSession.Name} tried to ghostnado without being a ghost.");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (_followerSystem.GetMostGhostFollowed() is not {} target)
|
|
|
|
|
|
|
+ if (_followerSystem.GetMostGhostFollowed() is not { } target)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
WarpTo(uid, target);
|
|
WarpTo(uid, target);
|
|
@@ -362,7 +368,7 @@ private IEnumerable<GhostWarp> GetPlayerWarps(EntityUid except)
|
|
|
{
|
|
{
|
|
|
foreach (var player in _playerManager.Sessions)
|
|
foreach (var player in _playerManager.Sessions)
|
|
|
{
|
|
{
|
|
|
- if (player.AttachedEntity is not {Valid: true} attached)
|
|
|
|
|
|
|
+ if (player.AttachedEntity is not { Valid: true } attached)
|
|
|
continue;
|
|
continue;
|
|
|
|
|
|
|
|
if (attached == except) continue;
|
|
if (attached == except) continue;
|
|
@@ -406,13 +412,13 @@ public void MakeVisible(bool visible)
|
|
|
|
|
|
|
|
if (visible)
|
|
if (visible)
|
|
|
{
|
|
{
|
|
|
- _visibilitySystem.AddLayer((uid, vis), (int) VisibilityFlags.Normal, false);
|
|
|
|
|
- _visibilitySystem.RemoveLayer((uid, vis), (int) VisibilityFlags.Ghost, false);
|
|
|
|
|
|
|
+ _visibilitySystem.AddLayer((uid, vis), (int)VisibilityFlags.Normal, false);
|
|
|
|
|
+ _visibilitySystem.RemoveLayer((uid, vis), (int)VisibilityFlags.Ghost, false);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- _visibilitySystem.AddLayer((uid, vis), (int) VisibilityFlags.Ghost, false);
|
|
|
|
|
- _visibilitySystem.RemoveLayer((uid, vis), (int) VisibilityFlags.Normal, false);
|
|
|
|
|
|
|
+ _visibilitySystem.AddLayer((uid, vis), (int)VisibilityFlags.Ghost, false);
|
|
|
|
|
+ _visibilitySystem.RemoveLayer((uid, vis), (int)VisibilityFlags.Normal, false);
|
|
|
}
|
|
}
|
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: vis);
|
|
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: vis);
|
|
|
}
|
|
}
|