mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* WarpPoints locale * string * Revert "string" This reverts commit 0148e4193dafce43f793da1f3306b6246d602824. * Mothership Core * fix * merge fix --------- Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using Content.Server.Chat.Systems;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Teleportation;
|
|
using Content.Shared.Teleportation.Components;
|
|
using Content.Shared.Teleportation.Systems;
|
|
using Content.Shared.UserInterface;
|
|
using Content.Shared.Warps;
|
|
using Content.Shared.Whitelist;
|
|
|
|
namespace Content.Server.Teleportation;
|
|
|
|
/// <summary>
|
|
/// <inheritdoc cref="SharedTeleportLocationsSystem"/>
|
|
/// </summary>
|
|
public sealed partial class TeleportLocationsSystem : SharedTeleportLocationsSystem
|
|
{
|
|
[Dependency] private ChatSystem _chat = default!;
|
|
[Dependency] private EntityWhitelistSystem _whitelist = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<TeleportLocationsComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<TeleportLocationsComponent, BeforeActivatableUIOpenEvent>(OnBeforeUiOpen);
|
|
}
|
|
|
|
private void OnMapInit(Entity<TeleportLocationsComponent> ent, ref MapInitEvent args)
|
|
{
|
|
UpdateTeleportPoints(ent);
|
|
}
|
|
|
|
private void OnBeforeUiOpen(Entity<TeleportLocationsComponent> ent, ref BeforeActivatableUIOpenEvent args)
|
|
{
|
|
UpdateTeleportPoints(ent);
|
|
}
|
|
|
|
protected override void OnTeleportToLocationRequest(Entity<TeleportLocationsComponent> ent, ref TeleportLocationDestinationMessage args)
|
|
{
|
|
if (Delay.IsDelayed(ent.Owner, TeleportDelay))
|
|
return;
|
|
|
|
if (!string.IsNullOrWhiteSpace(ent.Comp.Speech))
|
|
{
|
|
var msg = Loc.GetString(ent.Comp.Speech, ("location", args.PointName));
|
|
_chat.TrySendInGameICMessage(args.Actor, msg, InGameICChatType.Speak, ChatTransmitRange.Normal);
|
|
}
|
|
|
|
base.OnTeleportToLocationRequest(ent, ref args);
|
|
}
|
|
|
|
// If it's in shared this doesn't populate the points on the UI
|
|
/// <summary>
|
|
/// Gets the teleport points to send to the BUI
|
|
/// </summary>
|
|
private void UpdateTeleportPoints(Entity<TeleportLocationsComponent> ent)
|
|
{
|
|
ent.Comp.AvailableWarps.Clear();
|
|
|
|
var allEnts = AllEntityQuery<WarpPointComponent>();
|
|
|
|
// Selecting suitable entities with the warpPoint component using whitelist
|
|
while (allEnts.MoveNext(out var warpEnt, out var warpPointComp))
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(warpPointComp.Location))
|
|
continue;
|
|
|
|
if (!_whitelist.CheckBoth(warpEnt, ent.Comp.Blacklist, ent.Comp.Whitelist))
|
|
|
|
continue;
|
|
|
|
ent.Comp.AvailableWarps.Add(new TeleportPoint(Loc.GetString(warpPointComp.Location), GetNetEntity(warpEnt)));
|
|
}
|
|
|
|
Dirty(ent);
|
|
}
|
|
}
|