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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user