Add doors to the station map (#23639)
* Add doors to the navmap * tweaksies * gah * draw primitive * draw primitive? at least take me out to dinner first! * Update Content.Client/Pinpointer/UI/NavMapControl.cs * casualties --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -33,6 +33,9 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
|
||||
component.Beacons.Clear();
|
||||
component.Beacons.AddRange(state.Beacons);
|
||||
|
||||
component.Airlocks.Clear();
|
||||
component.Airlocks.AddRange(state.Airlocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Client.Pinpointer.UI;
|
||||
public partial class NavMapControl : MapGridControl
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||
private readonly SharedTransformSystem _transformSystem = default!;
|
||||
private readonly SharedTransformSystem _transformSystem;
|
||||
|
||||
public EntityUid? Owner;
|
||||
public EntityUid? MapUid;
|
||||
@@ -37,7 +37,7 @@ public partial class NavMapControl : MapGridControl
|
||||
// Tracked data
|
||||
public Dictionary<EntityCoordinates, (bool Visible, Color Color)> TrackedCoordinates = new();
|
||||
public Dictionary<NetEntity, NavMapBlip> TrackedEntities = new();
|
||||
public Dictionary<Vector2i, List<NavMapLine>> TileGrid = default!;
|
||||
public Dictionary<Vector2i, List<NavMapLine>>? TileGrid = default!;
|
||||
|
||||
// Default colors
|
||||
public Color WallColor = new(102, 217, 102);
|
||||
@@ -207,7 +207,6 @@ public partial class NavMapControl : MapGridControl
|
||||
|
||||
// Find closest tracked entity in range
|
||||
var closestEntity = NetEntity.Invalid;
|
||||
var closestCoords = new EntityCoordinates();
|
||||
var closestDistance = float.PositiveInfinity;
|
||||
|
||||
foreach ((var currentEntity, var blip) in TrackedEntities)
|
||||
@@ -221,7 +220,6 @@ public partial class NavMapControl : MapGridControl
|
||||
continue;
|
||||
|
||||
closestEntity = currentEntity;
|
||||
closestCoords = blip.Coordinates;
|
||||
closestDistance = currentDistance;
|
||||
}
|
||||
|
||||
@@ -234,8 +232,7 @@ public partial class NavMapControl : MapGridControl
|
||||
else if (args.Function == EngineKeyFunctions.UIRightClick)
|
||||
{
|
||||
// Clear current selection with right click
|
||||
if (TrackedEntitySelectedAction != null)
|
||||
TrackedEntitySelectedAction.Invoke(null);
|
||||
TrackedEntitySelectedAction?.Invoke(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,6 +357,41 @@ public partial class NavMapControl : MapGridControl
|
||||
}
|
||||
}
|
||||
|
||||
var airlockBuffer = Vector2.One * (MinimapScale / 2.25f) * 0.75f;
|
||||
var airlockLines = new ValueList<Vector2>();
|
||||
var foobarVec = new Vector2(1, -1);
|
||||
|
||||
foreach (var airlock in _navMap.Airlocks)
|
||||
{
|
||||
var position = airlock.Position - offset;
|
||||
position = Scale(position with { Y = -position.Y });
|
||||
airlockLines.Add(position + airlockBuffer);
|
||||
airlockLines.Add(position - airlockBuffer * foobarVec);
|
||||
|
||||
airlockLines.Add(position + airlockBuffer);
|
||||
airlockLines.Add(position + airlockBuffer * foobarVec);
|
||||
|
||||
airlockLines.Add(position - airlockBuffer);
|
||||
airlockLines.Add(position + airlockBuffer * foobarVec);
|
||||
|
||||
airlockLines.Add(position - airlockBuffer);
|
||||
airlockLines.Add(position - airlockBuffer * foobarVec);
|
||||
|
||||
airlockLines.Add(position + airlockBuffer * -Vector2.UnitY);
|
||||
airlockLines.Add(position - airlockBuffer * -Vector2.UnitY);
|
||||
}
|
||||
|
||||
if (airlockLines.Count > 0)
|
||||
{
|
||||
if (!_sRGBLookUp.TryGetValue(WallColor, out var sRGB))
|
||||
{
|
||||
sRGB = Color.ToSrgb(WallColor);
|
||||
_sRGBLookUp[WallColor] = sRGB;
|
||||
}
|
||||
|
||||
handle.DrawPrimitives(DrawPrimitiveTopology.LineList, airlockLines.Span, sRGB);
|
||||
}
|
||||
|
||||
if (PostWallDrawingAction != null)
|
||||
PostWallDrawingAction.Invoke(handle);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Pinpointer;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
@@ -20,6 +21,7 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
[Dependency] private readonly IAdminLogManager _adminLog = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly TagSystem _tags = default!;
|
||||
[Dependency] private readonly MapSystem _map = default!;
|
||||
|
||||
private EntityQuery<PhysicsComponent> _physicsQuery;
|
||||
private EntityQuery<TagComponent> _tagQuery;
|
||||
@@ -41,6 +43,9 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
SubscribeLocalEvent<NavMapBeaconComponent, ComponentStartup>(OnNavMapBeaconStartup);
|
||||
SubscribeLocalEvent<NavMapBeaconComponent, AnchorStateChangedEvent>(OnNavMapBeaconAnchor);
|
||||
|
||||
SubscribeLocalEvent<NavMapDoorComponent, ComponentStartup>(OnNavMapDoorStartup);
|
||||
SubscribeLocalEvent<NavMapDoorComponent, AnchorStateChangedEvent>(OnNavMapDoorAnchor);
|
||||
|
||||
SubscribeLocalEvent<ConfigurableNavMapBeaconComponent, NavMapBeaconConfigureBuiMessage>(OnConfigureMessage);
|
||||
SubscribeLocalEvent<ConfigurableNavMapBeaconComponent, MapInitEvent>(OnConfigurableMapInit);
|
||||
SubscribeLocalEvent<ConfigurableNavMapBeaconComponent, ExaminedEvent>(OnConfigurableExamined);
|
||||
@@ -63,6 +68,16 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
RefreshNavGrid(uid);
|
||||
}
|
||||
|
||||
private void OnNavMapDoorStartup(Entity<NavMapDoorComponent> ent, ref ComponentStartup args)
|
||||
{
|
||||
RefreshNavGrid(ent);
|
||||
}
|
||||
|
||||
private void OnNavMapDoorAnchor(Entity<NavMapDoorComponent> ent, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
RefreshNavGrid(ent);
|
||||
}
|
||||
|
||||
private void OnConfigureMessage(Entity<ConfigurableNavMapBeaconComponent> ent, ref NavMapBeaconConfigureBuiMessage args)
|
||||
{
|
||||
if (args.Session.AttachedEntity is not { } user)
|
||||
@@ -190,6 +205,9 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
|
||||
private void OnGetState(EntityUid uid, NavMapComponent component, ref ComponentGetState args)
|
||||
{
|
||||
if (!TryComp<MapGridComponent>(uid, out var mapGrid))
|
||||
return;
|
||||
|
||||
var data = new Dictionary<Vector2i, int>(component.Chunks.Count);
|
||||
foreach (var (index, chunk) in component.Chunks)
|
||||
{
|
||||
@@ -222,11 +240,45 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
beacons.Add(new NavMapBeacon(beacon.Color, name, xform.LocalPosition));
|
||||
}
|
||||
|
||||
var airlockQuery = EntityQueryEnumerator<NavMapDoorComponent, TransformComponent>();
|
||||
var airlocks = new List<NavMapAirlock>();
|
||||
while (airlockQuery.MoveNext(out _, out _, out var xform))
|
||||
{
|
||||
if (xform.GridUid != uid || !xform.Anchored)
|
||||
continue;
|
||||
|
||||
var pos = _map.TileIndicesFor(uid, mapGrid, xform.Coordinates);
|
||||
var enumerator = _map.GetAnchoredEntitiesEnumerator(uid, mapGrid, pos);
|
||||
|
||||
var wallPresent = false;
|
||||
while (enumerator.MoveNext(out var ent))
|
||||
{
|
||||
if (!_physicsQuery.TryGetComponent(ent, out var body) ||
|
||||
!body.CanCollide ||
|
||||
!body.Hard ||
|
||||
body.BodyType != BodyType.Static ||
|
||||
!_tags.HasTag(ent.Value, "Wall", _tagQuery) &&
|
||||
!_tags.HasTag(ent.Value, "Window", _tagQuery))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
wallPresent = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (wallPresent)
|
||||
continue;
|
||||
|
||||
airlocks.Add(new NavMapAirlock(xform.LocalPosition));
|
||||
}
|
||||
|
||||
// TODO: Diffs
|
||||
args.State = new NavMapComponentState()
|
||||
{
|
||||
TileData = data,
|
||||
Beacons = beacons,
|
||||
Airlocks = airlocks
|
||||
};
|
||||
}
|
||||
|
||||
@@ -286,8 +338,8 @@ public sealed class NavMapSystem : SharedNavMapSystem
|
||||
!body.CanCollide ||
|
||||
!body.Hard ||
|
||||
body.BodyType != BodyType.Static ||
|
||||
(!_tags.HasTag(ent.Value, "Wall", _tagQuery) &&
|
||||
!_tags.HasTag(ent.Value, "Window", _tagQuery)))
|
||||
!_tags.HasTag(ent.Value, "Wall", _tagQuery) &&
|
||||
!_tags.HasTag(ent.Value, "Window", _tagQuery))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public sealed partial class NavMapComponent : Component
|
||||
public readonly Dictionary<Vector2i, NavMapChunk> Chunks = new();
|
||||
|
||||
[ViewVariables] public readonly List<SharedNavMapSystem.NavMapBeacon> Beacons = new();
|
||||
|
||||
[ViewVariables] public readonly List<SharedNavMapSystem.NavMapAirlock> Airlocks = new();
|
||||
}
|
||||
|
||||
public sealed class NavMapChunk
|
||||
|
||||
13
Content.Shared/Pinpointer/NavMapDoorComponent.cs
Normal file
13
Content.Shared/Pinpointer/NavMapDoorComponent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Pinpointer;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for objects which appear as doors on the navmap.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(SharedNavMapSystem))]
|
||||
public sealed partial class NavMapDoorComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -37,8 +37,13 @@ public abstract class SharedNavMapSystem : EntitySystem
|
||||
public Dictionary<Vector2i, int> TileData = new();
|
||||
|
||||
public List<NavMapBeacon> Beacons = new();
|
||||
|
||||
public List<NavMapAirlock> Airlocks = new();
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public readonly record struct NavMapBeacon(Color Color, string Text, Vector2 Position);
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public readonly record struct NavMapAirlock(Vector2 Position);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
- type: Weldable
|
||||
time: 3
|
||||
- type: Airlock
|
||||
- type: NavMapDoor
|
||||
- type: DoorBolt
|
||||
- type: Appearance
|
||||
- type: WiresVisuals
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
- type: Weldable
|
||||
time: 10
|
||||
- type: Airlock
|
||||
- type: NavMapDoor
|
||||
- type: DoorBolt
|
||||
- type: AccessReader
|
||||
- type: Appearance
|
||||
|
||||
@@ -57,10 +57,17 @@
|
||||
mode: NoSprite
|
||||
- type: Occluder
|
||||
|
||||
- type: entity
|
||||
parent: BaseMaterialDoor
|
||||
id: BaseMaterialDoorNavMap
|
||||
abstract: true
|
||||
components:
|
||||
- type: NavMapDoor
|
||||
|
||||
- type: entity
|
||||
id: MetalDoor
|
||||
name: metal door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
components:
|
||||
- type: Construction
|
||||
graph: DoorGraph
|
||||
@@ -69,7 +76,7 @@
|
||||
- type: entity
|
||||
id: WoodDoor
|
||||
name: wooden door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -106,7 +113,7 @@
|
||||
- type: entity
|
||||
id: PaperDoor
|
||||
name: paper door
|
||||
parent: WoodDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -129,7 +136,7 @@
|
||||
- type: entity
|
||||
id: PlasmaDoor
|
||||
name: plasma door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -155,7 +162,7 @@
|
||||
- type: entity
|
||||
id: GoldDoor
|
||||
name: gold door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -170,7 +177,7 @@
|
||||
- type: entity
|
||||
id: SilverDoor
|
||||
name: silver door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -185,7 +192,7 @@
|
||||
- type: entity
|
||||
id: BananiumDoor
|
||||
name: bananium door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, where will it lead?
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -205,7 +212,7 @@
|
||||
- type: entity
|
||||
id: WebDoor
|
||||
name: web door
|
||||
parent: BaseMaterialDoor
|
||||
parent: BaseMaterialDoorNavMap
|
||||
description: A door, leading to the lands of the spiders... or a spaced room.
|
||||
components:
|
||||
- type: Sprite
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
- type: ContainerFill
|
||||
containers:
|
||||
battery-container: [ PowerCellMedium ]
|
||||
- type: Tag
|
||||
tags:
|
||||
- Structure
|
||||
- Wall
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
battery-container: !type:Container
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
board: !type:Container
|
||||
- type: NavMapDoor
|
||||
- type: Door
|
||||
openDrawDepth: BlastDoors
|
||||
closedDrawDepth: BlastDoors
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
openUnlitVisible: true
|
||||
# needed so that windoors will close regardless of whether there are people in it; it doesn't crush after all
|
||||
safety: false
|
||||
- type: NavMapDoor
|
||||
- type: DoorBolt
|
||||
- type: Electrified
|
||||
enabled: false
|
||||
|
||||
Reference in New Issue
Block a user