using Content.Server.Chat.Systems; using Content.Shared.Chat; using Content.Shared.Station.Components; using Content.Shared.Teleportation; using Content.Shared.Teleportation.Components; using Content.Shared.Teleportation.Systems; using Content.Shared.Timing; using Content.Shared.UserInterface; using Content.Shared.Warps; using Content.Shared.Whitelist; namespace Content.Server.Teleportation; /// /// /// public sealed partial class TeleportLocationsSystem : SharedTeleportLocationsSystem { [Dependency] private readonly ChatSystem _chat = default!; [Dependency] private readonly EntityWhitelistSystem _whitelist = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnBeforeUiOpen); } private void OnMapInit(Entity ent, ref MapInitEvent args) { UpdateTeleportPoints(ent); } private void OnBeforeUiOpen(Entity ent, ref BeforeActivatableUIOpenEvent args) { UpdateTeleportPoints(ent); } protected override void OnTeleportToLocationRequest(Entity ent, ref TeleportLocationDestinationMessage args) { if (!TryComp(ent.Owner, out UseDelayComponent? useDelay) || Delay.IsDelayed((ent.Owner,useDelay), ent.Comp.UseDelay)) // White Dream fix 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 /// /// Gets the teleport points to send to the BUI /// private void UpdateTeleportPoints(Entity ent) { ent.Comp.AvailableWarps.Clear(); var allEnts = AllEntityQuery(); while (allEnts.MoveNext(out var warpEnt, out var warpPointComp)) { if (_whitelist.IsBlacklistPass(warpPointComp.Blacklist, warpEnt) || string.IsNullOrWhiteSpace(warpPointComp.Location)) continue; if (ent.Comp.StationOnly && !HasComp(Transform(warpEnt).GridUid)) // White Dream continue; ent.Comp.AvailableWarps.Add(new TeleportPoint(warpPointComp.Location, GetNetEntity(warpEnt))); } Dirty(ent); } }