Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vis_contents invisibility #2155

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions OpenDreamClient/Rendering/DreamViewOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void DrawAll(OverlayDrawArgs args, EntityUid eye, Vector2i viewportSize)
}

//handles underlays, overlays, appearance flags, images. Adds them to the result list, so they can be sorted and drawn with DrawIcon()
private void ProcessIconComponents(DreamIcon icon, Vector2 position, EntityUid uid, bool isScreen, ref int tieBreaker, List<RendererMetaData> result, RendererMetaData? parentIcon = null, bool keepTogether = false, Vector3? turfCoords = null) {
private void ProcessIconComponents(DreamIcon icon, Vector2 position, EntityUid uid, bool isScreen, ref int tieBreaker, List<RendererMetaData> result, sbyte seeVis, RendererMetaData? parentIcon = null, bool keepTogether = false, Vector3? turfCoords = null) {
if (icon.Appearance is null) //in the event that appearance hasn't loaded yet
return;

Expand Down Expand Up @@ -281,10 +281,10 @@ private void ProcessIconComponents(DreamIcon icon, Vector2 position, EntityUid u
tieBreaker++;

if (!keepTogether || (underlay.Appearance.AppearanceFlags & AppearanceFlags.KeepApart) != 0) { //KEEP_TOGETHER wasn't set on our parent, or KEEP_APART
ProcessIconComponents(underlay, current.Position, uid, isScreen, ref tieBreaker, result, current);
ProcessIconComponents(underlay, current.Position, uid, isScreen, ref tieBreaker, result, seeVis, current);
} else {
current.KeepTogetherGroup ??= new();
ProcessIconComponents(underlay, current.Position, uid, isScreen, ref tieBreaker, current.KeepTogetherGroup, current, keepTogether);
ProcessIconComponents(underlay, current.Position, uid, isScreen, ref tieBreaker, current.KeepTogetherGroup, seeVis, current, keepTogether);
}
}

Expand All @@ -299,10 +299,10 @@ private void ProcessIconComponents(DreamIcon icon, Vector2 position, EntityUid u
tieBreaker++;

if (!keepTogether || (overlay.Appearance.AppearanceFlags & AppearanceFlags.KeepApart) != 0) { //KEEP_TOGETHER wasn't set on our parent, or KEEP_APART
ProcessIconComponents(overlay, current.Position, uid, isScreen, ref tieBreaker, result, current);
ProcessIconComponents(overlay, current.Position, uid, isScreen, ref tieBreaker, result, seeVis, current);
} else {
current.KeepTogetherGroup ??= new();
ProcessIconComponents(overlay, current.Position, uid, isScreen, ref tieBreaker, current.KeepTogetherGroup, current, keepTogether);
ProcessIconComponents(overlay, current.Position, uid, isScreen, ref tieBreaker, current.KeepTogetherGroup, seeVis, current, keepTogether);
}
}

Expand All @@ -320,16 +320,19 @@ private void ProcessIconComponents(DreamIcon icon, Vector2 position, EntityUid u
current.MainIcon = sprite.Icon;
current.Position = current.Position + (sprite.Icon.Appearance.TotalPixelOffset / (float)EyeManager.PixelsPerMeter);
} else
ProcessIconComponents(sprite.Icon, current.Position, uid, isScreen, ref tieBreaker, result, current);
ProcessIconComponents(sprite.Icon, current.Position, uid, isScreen, ref tieBreaker, result, seeVis, current);
}
}

foreach (var visContent in icon.Appearance.VisContents) {
EntityUid visContentEntity = _entityManager.GetEntity(visContent);
if (!_spriteQuery.TryGetComponent(visContentEntity, out var sprite))
continue;
var transform = _xformQuery.GetComponent(visContentEntity);
if (!sprite.IsVisible(transform, seeVis))
continue;

ProcessIconComponents(sprite.Icon, position, visContentEntity, false, ref tieBreaker, result, current, keepTogether);
ProcessIconComponents(sprite.Icon, position, visContentEntity, false, ref tieBreaker, result, seeVis, current, keepTogether);

// TODO: click uid should be set to current.uid again
// TODO: vis_flags
Expand Down Expand Up @@ -607,7 +610,7 @@ private void DrawPlanes(DrawingHandleWorld handle, Box2 worldAABB) {
return _tileInfo;
}

private void CollectVisibleSprites(ViewAlgorithm.Tile?[,] tiles, EntityUid gridUid, MapGridComponent grid, TileRef eyeTile, int seeVis, SightFlags sight, Box2 worldAABB) {
private void CollectVisibleSprites(ViewAlgorithm.Tile?[,] tiles, EntityUid gridUid, MapGridComponent grid, TileRef eyeTile, sbyte seeVis, SightFlags sight, Box2 worldAABB) {
_spriteContainer.Clear();

// This exists purely because the tiebreaker var needs to exist somewhere
Expand All @@ -628,7 +631,7 @@ private void CollectVisibleSprites(ViewAlgorithm.Tile?[,] tiles, EntityUid gridU
tValue = 0;
//pass the turf coords for client.images lookup
Vector3 turfCoords = new Vector3(tileRef.X, tileRef.Y, (int) worldPos.MapId);
ProcessIconComponents(_appearanceSystem.GetTurfIcon((uint)tileRef.Tile.TypeId), worldPos.Position - Vector2.One, EntityUid.Invalid, false, ref tValue, _spriteContainer, turfCoords: turfCoords);
ProcessIconComponents(_appearanceSystem.GetTurfIcon((uint)tileRef.Tile.TypeId), worldPos.Position - Vector2.One, EntityUid.Invalid, false, ref tValue, _spriteContainer, seeVis, turfCoords: turfCoords);
}

// Visible entities
Expand Down Expand Up @@ -657,7 +660,7 @@ private void CollectVisibleSprites(ViewAlgorithm.Tile?[,] tiles, EntityUid gridU
}

tValue = 0;
ProcessIconComponents(sprite.Icon, worldPos - new Vector2(0.5f), entity, false, ref tValue, _spriteContainer);
ProcessIconComponents(sprite.Icon, worldPos - new Vector2(0.5f), entity, false, ref tValue, _spriteContainer, seeVis);
}
}

Expand All @@ -679,7 +682,7 @@ private void CollectVisibleSprites(ViewAlgorithm.Tile?[,] tiles, EntityUid gridU
for (int x = 0; x < sprite.ScreenLocation.RepeatX; x++) {
for (int y = 0; y < sprite.ScreenLocation.RepeatY; y++) {
tValue = 0;
ProcessIconComponents(sprite.Icon, position + iconSize * new Vector2(x, y), uid, true, ref tValue, _spriteContainer);
ProcessIconComponents(sprite.Icon, position + iconSize * new Vector2(x, y), uid, true, ref tValue, _spriteContainer, seeVis);
}
}
}
Expand Down
Loading