Compare commits

...

9 Commits

Author SHA1 Message Date
Redrover1760 0123c844da Merge branch 'main' of https://github.com/Monolith-Station/Monolith into bliplag-fix-real 2026-05-05 12:38:39 -04:00
Redrover1760 e1ab88c51d progress 2026-04-27 23:20:31 -04:00
Redrover1760 bba8e08b99 Merge branch 'main' of https://github.com/Monolith-Station/Monolith into bliplag-fix-real 2026-04-26 15:37:14 -04:00
Redrover1760 12bc451100 Merge branch 'main' of https://github.com/Monolith-Station/Monolith into bliplag-fix-real 2026-04-22 00:01:00 -04:00
Redrover1760 c166d47d53 one line fix 2026-04-22 00:00:53 -04:00
Redrover1760 210dca1f89 Merge branch 'main' of https://github.com/Monolith-Station/Monolith into bliplag-fix-real 2026-04-09 13:23:15 -04:00
Redrover1760 3763a960c3 rea 2026-04-05 14:00:28 -04:00
Redrover1760 ccb9f992ba again 2026-04-05 11:42:55 -04:00
Redrover1760 848f671108 beginning 2026-04-04 22:06:20 -04:00
+76 -2
View File
@@ -1,10 +1,14 @@
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using Content.Server.Alert.Commands;
using Content.Shared._Mono.Radar;
using Content.Shared.Projectiles;
using Content.Shared.Shuttles.Components;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
namespace Content.Server._Mono.Radar;
@@ -19,6 +23,14 @@ public sealed partial class RadarBlipSystem : EntitySystem
private readonly List<EntityUid> _tempSourcesCache = new();
private readonly List<BlipConfig> _tempPaletteCache = new();
private readonly Dictionary<BlipConfig, ushort> _paletteIndex = new();
private readonly Dictionary<ICommonSession, List<BlipNetData>> _cachedBliplist = new();
private readonly Dictionary<ICommonSession, List<BlipNetData>> _sentBliplist = new();
private readonly Dictionary<ICommonSession, List<BlipNetData>> _unionedBliplist = new();
private readonly Dictionary<ICommonSession, List<EntityUid>> _sessionUpdateList = new();
private static readonly float UpdateInterval = 0.5f;
private float _lastUpdated = 0;
public override void Initialize()
{
@@ -27,6 +39,60 @@ public sealed partial class RadarBlipSystem : EntitySystem
SubscribeLocalEvent<RadarBlipComponent, ComponentShutdown>(OnBlipShutdown);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
_lastUpdated += frameTime;
if (UpdateInterval <= _lastUpdated)
return;
_lastUpdated -= UpdateInterval;
// MAIN Update Method
// Run once per interval.
// Get all Sessions requesting blips (Method)
// For each session, get all entities within RANGE of the target with EQE blip component (Method)
// Return as Dictionary
// COMPARE TO OLD CACHE (Method)
// For static blips, a simple Union of both lists will do.
// But for moving blips, we must calculate the expected updated position of blips by the velocity.
// For new blips, send them to the client for client to cache.
// For old blips, remove them from the Cache and send a removal event.
// Use dictionary, for each Session, return list. Send indivdiual list per client.
_sentBliplist.Clear();
// Calculate new positions for all blips with velocity > 0 with frametime and velocity vector. Replace old positions with new.
// Compare cached blip list with created bliplist
// Output those that do not match.
// For those that have a moving velocity, apply specialcase matching.
//but then if a blip moves it might not update
//need to check if new position is consistent with velocity
//If it is, remove from _unionedBliplist.
//Send the Union of _sentBlipList and _cachedBlipList to client. "_unionedBliplist"
// Client should no longer remove blips on their own.
// Send removal requests to blips that have left the client's range, as determined by blipcomponent.
}
private void OnBlipsRequested(RequestBlipsEvent ev, EntitySessionEventArgs args)
{
if (!TryGetEntity(ev.Radar, out var radarUid)
@@ -37,16 +103,24 @@ public sealed partial class RadarBlipSystem : EntitySystem
var sourcesEv = new GetRadarSourcesEvent();
RaiseLocalEvent(radarUid.Value, ref sourcesEv);
// Reuse pooled sources list
_tempSourcesCache.Clear();
if (sourcesEv.Sources != null)
_tempSourcesCache.AddRange(sourcesEv.Sources);
else
_tempSourcesCache.Add(radarUid.Value);
// Ensure that we do not duplicate our values or keys, since we only clear after update() is called.
if (_sessionUpdateList.ContainsKey(args.SenderSession))
_sessionUpdateList[args.SenderSession] = _tempSourcesCache;
else
_sessionUpdateList.Add(args.SenderSession, _tempSourcesCache);
AssembleBlipsReport((EntityUid)radarUid, _tempSourcesCache, radar);
AssembleHitscanReport((EntityUid)radarUid, _tempSourcesCache, radar);
_sentBliplist.Add(args.SenderSession, _tempBlipsCache);
// Combine the blips and hitscan lines
var giveEv = new GiveBlipsEvent(_tempPaletteCache, _tempBlipsCache, _tempHitscansCache);
RaiseNetworkEvent(giveEv, args.SenderSession);
@@ -167,7 +241,7 @@ public sealed partial class RadarBlipSystem : EntitySystem
if (!hitscan.Enabled)
continue;
if (!NearAnySources(hitscan.StartPosition, sources, component.MaxRange) && NearAnySources(hitscan.EndPosition, sources, component.MaxRange))
if (!NearAnySources(hitscan.StartPosition, sources, component.MaxRange) && !NearAnySources(hitscan.EndPosition, sources, component.MaxRange))
continue;
_tempHitscansCache.Add(new(hitscan.StartPosition, hitscan.EndPosition, hitscan.LineThickness, hitscan.RadarColor));