Fix decal error (#13471)
Fixes https://github.com/space-wizards/space-station-14/issues/13466
This commit is contained in:
@@ -13,6 +13,8 @@ namespace Content.Client.Decals
|
|||||||
[Dependency] private readonly SpriteSystem _sprites = default!;
|
[Dependency] private readonly SpriteSystem _sprites = default!;
|
||||||
|
|
||||||
private DecalOverlay _overlay = default!;
|
private DecalOverlay _overlay = default!;
|
||||||
|
|
||||||
|
// TODO move this data to the component
|
||||||
public readonly Dictionary<EntityUid, SortedDictionary<int, SortedDictionary<uint, Decal>>> DecalRenderIndex = new();
|
public readonly Dictionary<EntityUid, SortedDictionary<int, SortedDictionary<uint, Decal>>> DecalRenderIndex = new();
|
||||||
private readonly Dictionary<EntityUid, Dictionary<uint, int>> _decalZIndexIndex = new();
|
private readonly Dictionary<EntityUid, Dictionary<uint, int>> _decalZIndexIndex = new();
|
||||||
|
|
||||||
@@ -25,8 +27,6 @@ namespace Content.Client.Decals
|
|||||||
|
|
||||||
SubscribeLocalEvent<DecalGridComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<DecalGridComponent, ComponentHandleState>(OnHandleState);
|
||||||
SubscribeNetworkEvent<DecalChunkUpdateEvent>(OnChunkUpdate);
|
SubscribeNetworkEvent<DecalChunkUpdateEvent>(OnChunkUpdate);
|
||||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridInitialize);
|
|
||||||
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleOverlay()
|
public void ToggleOverlay()
|
||||||
@@ -41,16 +41,18 @@ namespace Content.Client.Decals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridRemoval(GridRemovalEvent ev)
|
protected override void OnCompRemove(EntityUid uid, DecalGridComponent component, ComponentRemove args)
|
||||||
{
|
{
|
||||||
DecalRenderIndex.Remove(ev.EntityUid);
|
DecalRenderIndex.Remove(uid);
|
||||||
_decalZIndexIndex.Remove(ev.EntityUid);
|
_decalZIndexIndex.Remove(uid);
|
||||||
|
base.OnCompRemove(uid, component, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridInitialize(GridInitializeEvent ev)
|
protected override void OnCompAdd(EntityUid uid, DecalGridComponent component, ComponentAdd args)
|
||||||
{
|
{
|
||||||
DecalRenderIndex[ev.EntityUid] = new();
|
DecalRenderIndex[uid] = new();
|
||||||
_decalZIndexIndex[ev.EntityUid] = new();
|
_decalZIndexIndex[uid] = new();
|
||||||
|
base.OnCompAdd(uid, component, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace Content.Server.Decals
|
|||||||
[Dependency] private readonly ChunkingSystem _chunking = default!;
|
[Dependency] private readonly ChunkingSystem _chunking = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _conf = default!;
|
[Dependency] private readonly IConfigurationManager _conf = default!;
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IDependencyCollection _dependencies = default!;
|
|
||||||
|
|
||||||
private readonly Dictionary<EntityUid, HashSet<Vector2i>> _dirtyChunks = new();
|
private readonly Dictionary<EntityUid, HashSet<Vector2i>> _dirtyChunks = new();
|
||||||
private readonly Dictionary<IPlayerSession, Dictionary<EntityUid, HashSet<Vector2i>>> _previousSentChunks = new();
|
private readonly Dictionary<IPlayerSession, Dictionary<EntityUid, HashSet<Vector2i>>> _previousSentChunks = new();
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Robust.Shared;
|
|
||||||
using Robust.Shared.Configuration;
|
|
||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -13,6 +11,7 @@ namespace Content.Shared.Decals
|
|||||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||||
|
|
||||||
|
// TODO move this data to the component
|
||||||
protected readonly Dictionary<EntityUid, Dictionary<uint, Vector2i>> ChunkIndex = new();
|
protected readonly Dictionary<EntityUid, Dictionary<uint, Vector2i>> ChunkIndex = new();
|
||||||
|
|
||||||
// Note that this constant is effectively baked into all map files, because of how they save the grid decal component.
|
// Note that this constant is effectively baked into all map files, because of how they save the grid decal component.
|
||||||
@@ -25,22 +24,33 @@ namespace Content.Shared.Decals
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<GridInitializeEvent>(OnGridInitialize);
|
SubscribeLocalEvent<GridInitializeEvent>(OnGridInitialize);
|
||||||
|
SubscribeLocalEvent<DecalGridComponent, ComponentAdd>(OnCompAdd);
|
||||||
|
SubscribeLocalEvent<DecalGridComponent, ComponentRemove>(OnCompRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGridInitialize(GridInitializeEvent msg)
|
private void OnGridInitialize(GridInitializeEvent msg)
|
||||||
{
|
{
|
||||||
var comp = EntityManager.EnsureComponent<DecalGridComponent>(msg.EntityUid);
|
EnsureComp<DecalGridComponent>(msg.EntityUid);
|
||||||
ChunkIndex[msg.EntityUid] = new();
|
}
|
||||||
foreach (var (indices, decals) in comp.ChunkCollection.ChunkCollection)
|
|
||||||
|
protected virtual void OnCompRemove(EntityUid uid, DecalGridComponent component, ComponentRemove args)
|
||||||
|
{
|
||||||
|
ChunkIndex.Remove(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnCompAdd(EntityUid uid, DecalGridComponent component, ComponentAdd args)
|
||||||
|
{
|
||||||
|
var index = ChunkIndex[uid] = new();
|
||||||
|
foreach (var (indices, decals) in component.ChunkCollection.ChunkCollection)
|
||||||
{
|
{
|
||||||
foreach (var uid in decals.Decals.Keys)
|
foreach (var decalUid in decals.Decals.Keys)
|
||||||
{
|
{
|
||||||
ChunkIndex[msg.EntityUid][uid] = indices;
|
index[decalUid] = indices;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DecalGridComponent.DecalGridChunkCollection? DecalGridChunkCollection(EntityUid gridEuid, DecalGridComponent? comp = null)
|
protected DecalGridChunkCollection? DecalGridChunkCollection(EntityUid gridEuid, DecalGridComponent? comp = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(gridEuid, ref comp))
|
if (!Resolve(gridEuid, ref comp))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user