Default warp point names (#21017)

This commit is contained in:
Leon Friedrich
2023-10-16 16:39:39 +11:00
committed by GitHub
parent 422544035d
commit 1f0c9314fd
6 changed files with 53 additions and 21 deletions

View File

@@ -59,9 +59,7 @@ namespace Content.Server.Administration.Commands
var currentMap = _entManager.GetComponent<TransformComponent>(playerEntity).MapID; var currentMap = _entManager.GetComponent<TransformComponent>(playerEntity).MapID;
var currentGrid = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid; var currentGrid = _entManager.GetComponent<TransformComponent>(playerEntity).GridUid;
var found = _entManager.EntityQuery<WarpPointComponent>(true) var found = GetWarpPointByName(location)
.Where(p => p.Location == location)
.Select(p => (_entManager.GetComponent<TransformComponent>(p.Owner).Coordinates, p.Follow))
.OrderBy(p => p.Item1, Comparer<EntityCoordinates>.Create((a, b) => .OrderBy(p => p.Item1, Comparer<EntityCoordinates>.Create((a, b) =>
{ {
// Sort so that warp points on the same grid/map are first. // Sort so that warp points on the same grid/map are first.
@@ -133,11 +131,28 @@ namespace Content.Server.Administration.Commands
private IEnumerable<string> GetWarpPointNames() private IEnumerable<string> GetWarpPointNames()
{ {
return _entManager.EntityQuery<WarpPointComponent>(true) List<string> points = new(_entManager.Count<WarpPointComponent>());
.Select(p => p.Location) var query = _entManager.AllEntityQueryEnumerator<WarpPointComponent, MetaDataComponent>();
.Where(p => p != null) while (query.MoveNext(out _, out var warp, out var meta))
.OrderBy(p => p) {
.Distinct()!; points.Add(warp.Location ?? meta.EntityName);
}
points.Sort();
return points;
}
private List<(EntityCoordinates, bool)> GetWarpPointByName(string name)
{
List<(EntityCoordinates, bool)> points = new();
var query = _entManager.AllEntityQueryEnumerator<WarpPointComponent, MetaDataComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var warp, out var meta, out var xform))
{
if (name == (warp.Location ?? meta.EntityName))
points.Add((xform.Coordinates, warp.Follow));
}
return points;
} }
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) public CompletionResult GetCompletion(IConsoleShell shell, string[] args)

View File

@@ -297,8 +297,7 @@ namespace Content.Server.Ghost
while (allQuery.MoveNext(out var uid, out var warp)) while (allQuery.MoveNext(out var uid, out var warp))
{ {
if (warp.Location != null) yield return new GhostWarp(GetNetEntity(uid), warp.Location ?? Name(uid), true);
yield return new GhostWarp(GetNetEntity(uid), warp.Location, true);
} }
} }

View File

@@ -170,12 +170,10 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
// choose spider charge detonation point // choose spider charge detonation point
var warps = new List<EntityUid>(); var warps = new List<EntityUid>();
var query = EntityQueryEnumerator<BombingTargetComponent, WarpPointComponent, TransformComponent>(); var query = EntityQueryEnumerator<BombingTargetComponent, WarpPointComponent>();
var map = Transform(uid).MapID; while (query.MoveNext(out var warpUid, out _, out var warp))
while (query.MoveNext(out var warpUid, out _, out var warp, out var xform))
{ {
if (warp.Location != null) warps.Add(warpUid);
warps.Add(warpUid);
} }
if (warps.Count > 0) if (warps.Count > 0)

View File

@@ -58,14 +58,13 @@ public sealed class NinjaConditionsSystem : EntitySystem
{ {
if (!TryComp<NinjaRoleComponent>(mindId, out var role) || if (!TryComp<NinjaRoleComponent>(mindId, out var role) ||
role.SpiderChargeTarget == null || role.SpiderChargeTarget == null ||
!TryComp<WarpPointComponent>(role.SpiderChargeTarget, out var warp) || !TryComp<WarpPointComponent>(role.SpiderChargeTarget, out var warp))
warp.Location == null)
{ {
// this should never really happen but eh // this should never really happen but eh
return Loc.GetString("objective-condition-spider-charge-title-no-target"); return Loc.GetString("objective-condition-spider-charge-title-no-target");
} }
return Loc.GetString("objective-condition-spider-charge-title", ("location", warp.Location)); return Loc.GetString("objective-condition-spider-charge-title", ("location", warp.Location ?? Name(role.SpiderChargeTarget.Value)));
} }
// steal research // steal research

View File

@@ -6,12 +6,13 @@ namespace Content.Server.Warps
[RegisterComponent] [RegisterComponent]
public sealed partial class WarpPointComponent : Component public sealed partial class WarpPointComponent : Component
{ {
[ViewVariables(VVAccess.ReadWrite)] [DataField("location")] public string? Location { get; set; } [ViewVariables(VVAccess.ReadWrite), DataField]
public string? Location;
/// <summary> /// <summary>
/// If true, ghosts warping to this entity will begin following it. /// If true, ghosts warping to this entity will begin following it.
/// </summary> /// </summary>
[DataField("follow")] [DataField]
public bool Follow = false; public bool Follow;
} }
} }

View File

@@ -13,6 +13,8 @@
name: warp point (beacon) name: warp point (beacon)
components: components:
- type: NavMapBeacon - type: NavMapBeacon
- type: WarpPoint
location: beacon
- type: entity - type: entity
parent: WarpPoint parent: WarpPoint
@@ -21,6 +23,8 @@
suffix: ninja bombing target suffix: ninja bombing target
components: components:
- type: BombingTarget - type: BombingTarget
- type: WarpPoint
location: bombing target
- type: Sprite - type: Sprite
layers: layers:
- state: pink - state: pink
@@ -36,6 +40,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: bar text: bar
color: "#791500" color: "#791500"
- type: WarpPoint
location: bar
- type: entity - type: entity
id: WarpPointBeaconCargo id: WarpPointBeaconCargo
@@ -45,6 +51,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: cargo text: cargo
color: "#A46106" color: "#A46106"
- type: WarpPoint
location: cargo
- type: entity - type: entity
id: WarpPointBeaconCommand id: WarpPointBeaconCommand
@@ -54,6 +62,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: command text: command
color: "#334E6D" color: "#334E6D"
- type: WarpPoint
location: command
- type: entity - type: entity
id: WarpPointBeaconEngineering id: WarpPointBeaconEngineering
@@ -63,6 +73,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: engineering text: engineering
color: "#EFB341" color: "#EFB341"
- type: WarpPoint
location: engineering
- type: entity - type: entity
id: WarpPointBeaconMedical id: WarpPointBeaconMedical
@@ -72,6 +84,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: medical text: medical
color: "#52B4E9" color: "#52B4E9"
- type: WarpPoint
location: medical
- type: entity - type: entity
id: WarpPointBeaconNeutral id: WarpPointBeaconNeutral
@@ -81,6 +95,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: neutral text: neutral
color: "#D4D4D4" color: "#D4D4D4"
- type: WarpPoint
location: neutral
- type: entity - type: entity
id: WarpPointBeaconScience id: WarpPointBeaconScience
@@ -90,6 +106,8 @@
- type: NavMapBeacon - type: NavMapBeacon
text: science text: science
color: "#D381C9" color: "#D381C9"
- type: WarpPoint
location: science
- type: entity - type: entity
id: WarpPointBeaconService id: WarpPointBeaconService
@@ -99,3 +117,5 @@
- type: NavMapBeacon - type: NavMapBeacon
text: service text: service
color: "#9FED58" color: "#9FED58"
- type: WarpPoint
location: service