diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 49d62e2e4a..22ede58269 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -1,6 +1,8 @@ using System.Linq; +using Content.Server.Ghost.Components; using Content.Server.Warps; using Content.Shared.Administration; +using Content.Shared.Follower; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Enums; @@ -56,8 +58,8 @@ namespace Content.Server.Administration.Commands var found = entMan.EntityQuery(true) .Where(p => p.Location == location) - .Select(p => entMan.GetComponent(p.Owner).Coordinates) - .OrderBy(p => p, Comparer.Create((a, b) => + .Select(p => (entMan.GetComponent(p.Owner).Coordinates, p.Follow)) + .OrderBy(p => p.Item1, Comparer.Create((a, b) => { // Sort so that warp points on the same grid/map are first. // So if you have two maps loaded with the same warp points, @@ -102,18 +104,26 @@ namespace Content.Server.Administration.Commands })) .FirstOrDefault(); - var entityUid = found.GetGridUid(entMan); - if (entityUid != EntityUid.Invalid) + var (coords, follow) = found; + + if (coords.EntityId == EntityUid.Invalid) { - entMan.GetComponent(playerEntity).Coordinates = found; - if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics)) - { - physics.LinearVelocity = Vector2.Zero; - } + shell.WriteError("That location does not exist!"); + return; } - else + + if (follow && entMan.HasComponent(playerEntity)) { - shell.WriteLine("That location does not exist!"); + entMan.EntitySysManager.GetEntitySystem().StartFollowingEntity(playerEntity, coords.EntityId); + return; + } + + var xform = entMan.GetComponent(playerEntity); + xform.Coordinates = coords; + xform.AttachToGridOrMap(); + if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics)) + { + physics.LinearVelocity = Vector2.Zero; } } } diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 4a91a38a05..389e3366f5 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -184,13 +184,26 @@ namespace Content.Server.Ghost return; } - if (FindLocation(msg.Name) is { } warp) + // TODO: why the fuck is this using the name instead of an entity id or something? + // at least it makes sense for the warp command to need to use names, but not this. + + if (FindLocation(msg.Name) is not { } warp) { - EntityManager.GetComponent(ghost.Owner).Coordinates = EntityManager.GetComponent(warp.Owner).Coordinates; + Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid warp: {msg.Name}"); + return; + } + + if (warp.Follow) + { + _followerSystem.StartFollowingEntity(attached, warp.Owner); return; } - Logger.Warning($"User {args.SenderSession.Name} tried to warp to an invalid warp: {msg.Name}"); + var xform = Transform(attached); + xform.Coordinates = Transform(warp.Owner).Coordinates; + xform.AttachToGridOrMap(); + if (TryComp(attached, out PhysicsComponent? physics)) + physics.LinearVelocity = Vector2.Zero; } private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args) diff --git a/Content.Server/Warps/WarpPointComponent.cs b/Content.Server/Warps/WarpPointComponent.cs index b4e4f7d61e..f903b52aec 100644 --- a/Content.Server/Warps/WarpPointComponent.cs +++ b/Content.Server/Warps/WarpPointComponent.cs @@ -7,5 +7,11 @@ namespace Content.Server.Warps public sealed class WarpPointComponent : Component { [ViewVariables(VVAccess.ReadWrite)] [DataField("location")] public string? Location { get; set; } + + /// + /// If true, ghosts warping to this entity will begin following it. + /// + [DataField("follow")] + public readonly bool Follow = false; } } diff --git a/Resources/Prototypes/Entities/Objects/Misc/dat_fukken_disk.yml b/Resources/Prototypes/Entities/Objects/Misc/dat_fukken_disk.yml index 4dde01f7cf..37049a2fce 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/dat_fukken_disk.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/dat_fukken_disk.yml @@ -13,6 +13,7 @@ price: 2000 - type: CargoSellBlacklist - type: WarpPoint + follow: true location: nuke disk - type: entity