Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
52ba508
notifies client of eye/mob changes via network message for determinin…
Ruzihm Dec 15, 2025
ed29795
feedback
Ruzihm Dec 15, 2025
d6a4560
Merge branch 'master' into mob-sight
Ruzihm Dec 16, 2025
4a4b7fc
Update OpenDreamClient/Interface/DreamInterfaceManager.cs
Ruzihm Jan 14, 2026
fe4846e
Merge branch 'master' into mob-sight
Ruzihm Jan 14, 2026
434d423
first attempt at supporting turf eye
Ruzihm Jan 15, 2026
63d7ff7
some cleanup
Ruzihm Jan 15, 2026
b5b02bb
lint
Ruzihm Jan 15, 2026
af6dc0a
lint
Ruzihm Jan 15, 2026
952497f
stop changing attached entity for eye changes, store eye reference in…
Ruzihm Jan 15, 2026
f57645d
lint
Ruzihm Jan 15, 2026
2a1b4da
cleanup
Ruzihm Jan 15, 2026
88d4457
makes null eye stop rendering. annoyingly it doesn't clear the screen…
Ruzihm Jan 16, 2026
0cdcc18
lint
Ruzihm Jan 16, 2026
f0cac6d
null eye only shows certain screen elements
Ruzihm Jan 17, 2026
2811882
lint
Ruzihm Jan 17, 2026
c16563c
lint
Ruzihm Jan 17, 2026
20b94b3
lint
Ruzihm Jan 17, 2026
355c938
Merge branch 'master' into mob-sight
Ruzihm Jan 20, 2026
6471787
Merge branch 'master' into mob-sight
Ruzihm Jan 28, 2026
79ceec6
listen for RT eye adding event to overwrite current eye changes
Ruzihm Jan 28, 2026
d562c8d
Merge branch 'master' into mob-sight
Ruzihm May 8, 2026
c3955a5
lint
Ruzihm May 8, 2026
92ca72c
lint
Ruzihm May 8, 2026
8856a58
Merge branch 'master' into mob-sight
Ruzihm May 9, 2026
1fd4e32
lint
Ruzihm May 9, 2026
8e437c9
Update OpenDreamClient/DreamClientSystem.cs
Ruzihm May 16, 2026
cce3159
Update OpenDreamClient/DreamClientSystem.cs
Ruzihm May 16, 2026
93f6cde
remove onlyDrawScreenSprites from DrawMouseMap
Ruzihm May 16, 2026
d1fe093
DreamConnection.Eye from ClientObjectReference to DreamObjectAtom
Ruzihm May 16, 2026
f402d10
lint
Ruzihm May 16, 2026
b5b693f
Keeps mob verbs usable even if mob isn't in view, fixes out of bounds…
Ruzihm May 17, 2026
f020f50
Merge branch 'master' into mob-sight
Ruzihm May 23, 2026
a1ed778
Feedback
Ruzihm May 23, 2026
d8c318f
lint
Ruzihm May 23, 2026
bace554
lint
Ruzihm May 23, 2026
95d4699
lint
Ruzihm May 23, 2026
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
11 changes: 7 additions & 4 deletions OpenDreamClient/ClientVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public sealed class ClientVerbSystem : VerbSystem {
[Dependency] private readonly ITaskManager _taskManager = default!;
[Dependency] private readonly ITimerManager _timerManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly DreamClientSystem _dreamClientSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;

private EntityQuery<DMISpriteComponent> _spriteQuery;
Expand Down Expand Up @@ -83,8 +84,10 @@ public IEnumerable<VerbInfo> GetAllVerbs() {
/// <returns>The ID, src, and information of every executable verb</returns>
public IEnumerable<(int Id, ClientObjectReference Src, VerbInfo VerbInfo)> GetExecutableVerbs(bool ignoreHiddenAttr = false) {
sbyte? seeInvisibility = null;
if (_playerManager.LocalEntity != null) {
_sightQuery.TryGetComponent(_playerManager.LocalEntity.Value, out var mobSight);

EntityUid mob = _dreamClientSystem.MobUid;
if (mob.IsValid()) {
_sightQuery.TryGetComponent(mob, out var mobSight);

seeInvisibility = mobSight?.SeeInvisibility;
}
Expand Down Expand Up @@ -120,12 +123,12 @@ public IEnumerable<VerbInfo> GetAllVerbs() {
// Check the verb's "set src" allows us to execute this
switch (verb.Accessibility) {
case VerbAccessibility.Usr:
if (entity != _playerManager.LocalEntity)
if (entity != mob)
continue;

break;
case VerbAccessibility.InUsr:
if (_transformSystem.GetParentUid(entity) != _playerManager.LocalEntity)
if (_transformSystem.GetParentUid(entity) != mob)
continue;

break;
Expand Down
63 changes: 63 additions & 0 deletions OpenDreamClient/DreamClientSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
using OpenDreamClient.Interface;
using OpenDreamShared.Dream;
using OpenDreamShared.Network.Messages;
using Robust.Shared.Player;

namespace OpenDreamClient;

internal sealed class DreamClientSystem : EntitySystem {
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IDreamInterfaceManager _interfaceManager = default!;

// Current NetEntityof player's mob, or Invalid if could not be determined.
Comment thread Fixed
private NetEntity _mobNet = NetEntity.Invalid;

// Current Entity of player's mob, or Invalid if could not be determined.
private EntityUid _mobUid = EntityUid.Invalid;

// Sometimes we get mob info before we know all the net entities, so store the net entity and refer to it
public EntityUid MobUid {
get {
// if entity of mob is invalid but net entity isn't, try referring to known net entities
if (! _mobUid.IsValid() && _mobNet.IsValid() && _entityManager.TryGetEntity(_mobNet, out var ent)) {
_mobUid = ent.GetValueOrDefault(EntityUid.Invalid);
}

return _mobUid;
}
}
Comment thread
Ruzihm marked this conversation as resolved.
Outdated

// Current Entity of player's eye, or Invalid if could not be determined.
private ClientObjectReference _eyeRef = new(NetEntity.Invalid);

public ClientObjectReference EyeRef {
get {
if (_eyeRef.Type == ClientObjectReference.RefType.Entity && !_eyeRef.Entity.IsValid()) {
return new(_entityManager.GetNetEntity(MobUid));
} else {
return _eyeRef;
}
}
private set => _eyeRef = value;
}

public override void Initialize() {
SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttached);
}
Expand All @@ -15,4 +50,32 @@
// So we have to set it again
_interfaceManager.DefaultWindow?.Macro.SetActive();
}

public void RxNotifyMobEyeUpdate(MsgNotifyMobEyeUpdate msg) {
var prevMobNet = _mobNet;
_mobNet = msg.MobNetEntity;

if (prevMobNet != _mobNet) {
// mark mob cache as dirty/invalid
_mobUid = EntityUid.Invalid;
}
Comment thread
Ruzihm marked this conversation as resolved.
Outdated

var incomingEyeRef = msg.EyeRef;
Comment thread Fixed

switch (incomingEyeRef.Type) {
default:
EyeRef = new(msg.MobNetEntity);
break;
case ClientObjectReference.RefType.Entity:
if (incomingEyeRef.Entity.IsValid()) {
EyeRef = incomingEyeRef;
} else {
EyeRef = new(msg.MobNetEntity);
}
break;
Comment thread Fixed
case ClientObjectReference.RefType.Turf:
EyeRef = incomingEyeRef;
break;
}
}
}
4 changes: 3 additions & 1 deletion OpenDreamClient/Input/ContextMenu/ContextMenuPopup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal sealed partial class ContextMenuPopup : Popup {
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
private readonly ClientAppearanceSystem _appearanceSystem;
private readonly DreamClientSystem _dreamClientSystem;
private readonly ClientVerbSystem _verbSystem;
private readonly DMISpriteSystem _spriteSystem;
private readonly EntityLookupSystem _lookupSystem;
Expand All @@ -37,6 +38,7 @@ public ContextMenuPopup() {

_verbSystem = _entitySystemManager.GetEntitySystem<ClientVerbSystem>();
_appearanceSystem = _entitySystemManager.GetEntitySystem<ClientAppearanceSystem>();
_dreamClientSystem = _entitySystemManager.GetEntitySystem<DreamClientSystem>();
_spriteSystem = _entitySystemManager.GetEntitySystem<DMISpriteSystem>();
_lookupSystem = _entitySystemManager.GetEntitySystem<EntityLookupSystem>();
_mouseInputSystem = _entitySystemManager.GetEntitySystem<MouseInputSystem>();
Expand Down Expand Up @@ -115,7 +117,7 @@ public void SetActiveItem(ContextMenuItem item) {
private sbyte GetSeeInvisible() {
if (_playerManager.LocalSession == null)
return 127;
if (!_mobSightQuery.TryGetComponent(_playerManager.LocalSession.AttachedEntity, out DreamMobSightComponent? sight))
if (!_mobSightQuery.TryGetComponent(_dreamClientSystem.MobUid, out DreamMobSightComponent? sight))
return 127;

return sight.SeeInvisibility;
Expand Down
21 changes: 13 additions & 8 deletions OpenDreamClient/Interface/DreamInterfaceManager.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
using System.IO;
using System.Text;
using System.Globalization;
using OpenDreamShared.Network.Messages;
using OpenDreamClient.Interface.Controls;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.DMF;
using OpenDreamClient.Interface.Controls;
using OpenDreamClient.Interface.Prompts;
using OpenDreamClient.Resources;
using OpenDreamClient.Resources.ResourceTypes;
using OpenDreamShared.Dream;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.DMF;
using OpenDreamShared.Network.Messages;
using Robust.Client;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.ContentPack;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using SixLabors.ImageSharp;
using System.Globalization;
using System.IO;
using System.Linq;
using Robust.Shared.Map;
using System.Text;

namespace OpenDreamClient.Interface;

Expand Down Expand Up @@ -131,9 +131,14 @@ public void Initialize() {
_netManager.RegisterNetMessage<MsgLoadInterface>(RxLoadInterface);
_netManager.RegisterNetMessage<MsgAckLoadInterface>();
_netManager.RegisterNetMessage<MsgUpdateClientInfo>(RxUpdateClientInfo);
_netManager.RegisterNetMessage<MsgNotifyMobEyeUpdate>(RxNotifyMobEyeUpdate);
Comment thread
Ruzihm marked this conversation as resolved.
_clyde.OnWindowFocused += OnWindowFocused;
}

private void RxNotifyMobEyeUpdate(MsgNotifyMobEyeUpdate message) {
_entitySystemManager.GetEntitySystem<DreamClientSystem>().RxNotifyMobEyeUpdate(message);
}

private void RxUpdateStatPanels(MsgUpdateStatPanels message) {
DefaultInfo?.UpdateStatPanels(message);
}
Expand Down
69 changes: 48 additions & 21 deletions OpenDreamClient/Rendering/DreamViewOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System.Linq;
using OpenDreamClient.Interface;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Map;
using OpenDreamClient.Interface;
using OpenDreamClient.Rendering.Particles;
using OpenDreamShared.Dream;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
using OpenDreamShared.Rendering;
using OpenDreamClient.Rendering.Particles;
using Robust.Client.GameObjects;
using Robust.Shared.Map.Components;
using Robust.Shared.Profiling;
using Matrix3x2 = System.Numerics.Matrix3x2;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.RichText;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Profiling;
using Robust.Shared.Prototypes;
using System.Linq;
using Matrix3x2 = System.Numerics.Matrix3x2;

namespace OpenDreamClient.Rendering;

Expand Down Expand Up @@ -60,6 +60,7 @@ internal sealed partial class DreamViewOverlay : Overlay {
private readonly ClientScreenOverlaySystem _screenOverlaySystem;
private readonly ClientImagesSystem _imagesSystem;
private readonly DMISpriteSystem _spriteSystem;
private readonly DreamClientSystem _dreamClientSystem;

private readonly EntityQuery<DMISpriteComponent> _spriteQuery;
private readonly EntityQuery<TransformComponent> _xformQuery;
Expand Down Expand Up @@ -90,6 +91,7 @@ public DreamViewOverlay(RenderTargetPool renderTargetPool) {
_screenOverlaySystem = _entitySystemManager.GetEntitySystem<ClientScreenOverlaySystem>();
_imagesSystem = _entitySystemManager.GetEntitySystem<ClientImagesSystem>();
_spriteSystem = _entitySystemManager.GetEntitySystem<DMISpriteSystem>();
_dreamClientSystem = _entitySystemManager.GetEntitySystem<DreamClientSystem>();

_spriteQuery = _entityManager.GetEntityQuery<DMISpriteComponent>();
_xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
Expand Down Expand Up @@ -120,15 +122,21 @@ public DreamViewOverlay(RenderTargetPool renderTargetPool) {
protected override void Draw(in OverlayDrawArgs args) {
using var _ = _prof.Group("Dream View Overlay");

EntityUid? eye = _playerManager.LocalSession?.AttachedEntity;
if (eye == null)
var eyeRef = _dreamClientSystem.EyeRef;
if (eyeRef.Type == ClientObjectReference.RefType.Entity && !eyeRef.Entity.IsValid()) {
return;
}

EntityUid mob = _dreamClientSystem.MobUid;
if (!mob.IsValid()) {
return;
}

//Main drawing of sprites happens here
try {
var viewportSize = (Vector2i)(args.Viewport.Size / args.Viewport.RenderScale);

DrawAll(args, eye.Value, viewportSize);
DrawAll(args, mob, eyeRef, viewportSize);
} catch (Exception e) {
_sawmill.Error($"Error occurred while rendering frame. Error details:\n{e.Message}\n{e.StackTrace}");
}
Expand All @@ -145,20 +153,39 @@ protected override void Draw(in OverlayDrawArgs args) {
_rendererMetaDataRental.Push(_rendererMetaDataToReturn.Pop());
}

private void DrawAll(OverlayDrawArgs args, EntityUid eye, Vector2i viewportSize) {
if (!_xformQuery.TryGetComponent(eye, out var eyeTransform))
return;
private void DrawAll(OverlayDrawArgs args, EntityUid mob, ClientObjectReference eyeRef, Vector2i viewportSize) {
MapCoordinates eyeCoords;
DreamMobSightComponent? eyeSight;
Box2 worldAABB;

switch (eyeRef.Type) {
default:
return;
case ClientObjectReference.RefType.Turf:
eyeCoords = new MapCoordinates(new(eyeRef.TurfX, eyeRef.TurfY), new(eyeRef.TurfZ));
_mobSightQuery.TryGetComponent(mob, out eyeSight);
worldAABB = args.WorldAABB;
worldAABB = worldAABB.Translated(eyeCoords.Position - worldAABB.Center);
break;
case ClientObjectReference.RefType.Entity:
var eyeUid = _entityManager.GetEntity(new(eyeRef.Entity.Id));
if (!_xformQuery.TryGetComponent(eyeUid, out var eyeTransform))
return;
eyeCoords = _transformSystem.GetMapCoordinates(eyeUid, eyeTransform);

_mobSightQuery.TryGetComponent(eyeUid, out eyeSight);
worldAABB = args.WorldAABB;
break;
}

var eyeCoords = _transformSystem.GetMapCoordinates(eye, eyeTransform);
if (!_mapManager.TryFindGridAt(eyeCoords, out var gridUid, out var grid))
return;

_mobSightQuery.TryGetComponent(eye, out var mobSight);
_mobSightQuery.TryGetComponent(mob, out var mobSight);
var seeVis = mobSight?.SeeInvisibility ?? 127;
var sight = mobSight?.Sight ?? 0;
var sight = eyeSight?.Sight ?? 0;

var worldHandle = args.WorldHandle;
var worldAABB = args.WorldAABB;

using (_prof.Group("lookup")) {
//TODO use a sprite tree.
Expand Down
Loading
Loading