Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Make LP Bravo and Pirate Cove admin-only warp points. (new-frontiers-…
Browse files Browse the repository at this point in the history
…14#2120)

* Admin-only warp points

* Remove unused admin dependency
  • Loading branch information
whatston3 authored Sep 30, 2024
1 parent a1660bf commit f724b9e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers; // Frontier
using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
Expand Down Expand Up @@ -62,6 +63,7 @@ public sealed class GhostSystem : SharedGhostSystem
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly IAdminManager _admin = default!; // Frontier

private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
Expand Down Expand Up @@ -292,7 +294,10 @@ private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventA
return;
}

var response = new GhostWarpsResponseEvent(GetPlayerWarps(entity).Concat(GetLocationWarps()).ToList());
// Frontier: get admin status for entity.
bool isAdmin = _admin.IsAdmin(entity);

var response = new GhostWarpsResponseEvent(GetPlayerWarps(entity).Concat(GetLocationWarps(isAdmin)).ToList()); // Frontier: add isAdmin
RaiseNetworkEvent(response, args.SenderSession.Channel);
}

Expand All @@ -313,6 +318,17 @@ private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, Entit
return;
}

// Frontier: check admin status when warping to admin-only warp points
if (_admin.IsAdmin(attached) &&
TryComp<WarpPointComponent>(target, out var warpPoint) &&
warpPoint.AdminOnly)
{
Log.Warning($"User {args.SenderSession.Name} tried to warp to an admin-only warp point: {msg.Target}");
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(attached):player} tried to warp to admin warp point {EntityManager.ToPrettyString(msg.Target)}");
return;
}
// End Frontier

WarpTo(attached, target);
}

Expand Down Expand Up @@ -346,12 +362,15 @@ private void WarpTo(EntityUid uid, EntityUid target)
_physics.SetLinearVelocity(uid, Vector2.Zero, body: physics);
}

private IEnumerable<GhostWarp> GetLocationWarps()
private IEnumerable<GhostWarp> GetLocationWarps(bool isAdmin) // Frontier: add isAdmin
{
var allQuery = AllEntityQuery<WarpPointComponent>();

while (allQuery.MoveNext(out var uid, out var warp))
{
if (warp.AdminOnly && !isAdmin) // Frontier: skip admin-only warp points if not an admin
continue; // Frontier

yield return new GhostWarp(GetNetEntity(uid), warp.Location ?? Name(uid), true);
}
}
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Warps/WarpPointComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ public sealed partial class WarpPointComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("useStationName")]
public bool UseStationName;

/// <summary>
/// Frontier - If true, warp point can only be used by admins
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("adminOnly")]
public bool AdminOnly;
// End Frontier
}
}
7 changes: 7 additions & 0 deletions Content.Shared/Ghost/SharedGhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint)
/// Whether this warp represents a warp point or a player
/// </summary>
public bool IsWarpPoint { get; }

// Frontier: warp point hiding
/// <summary>
/// Whether this warp requires admin access to warp to
/// </summary>
public bool AdminOnly { get; }
// End Frontier
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Entities/Markers/warp_point.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
components:
- type: WarpPoint
location: "Listening Point: Bravo"
adminOnly: true

- type: entity
id: WarpPointNFLodge
Expand Down Expand Up @@ -124,6 +125,7 @@
components:
- type: WarpPoint
location: Pirate's Cove
adminOnly: true

- type: entity
id: WarpPointNFGrifty
Expand Down

0 comments on commit f724b9e

Please sign in to comment.