Merge remote-tracking branch 'space-station-14/master' into ed-25-05-2024-upstream
# Conflicts: # Content.Server/Atmos/Components/FlammableComponent.cs # Content.Shared/Lock/LockSystem.cs # Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
This commit is contained in:
@@ -62,46 +62,37 @@ namespace Content.Shared.Decals
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DecalGridState : ComponentState, IComponentDeltaState
|
||||
public sealed class DecalGridState(Dictionary<Vector2i, DecalChunk> chunks) : ComponentState
|
||||
{
|
||||
public Dictionary<Vector2i, DecalChunk> Chunks;
|
||||
public bool FullState => AllChunks == null;
|
||||
public Dictionary<Vector2i, DecalChunk> Chunks = chunks;
|
||||
}
|
||||
|
||||
// required to infer deleted/missing chunks for delta states
|
||||
public HashSet<Vector2i>? AllChunks;
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DecalGridDeltaState(Dictionary<Vector2i, DecalChunk> modifiedChunks, HashSet<Vector2i> allChunks)
|
||||
: ComponentState, IComponentDeltaState<DecalGridState>
|
||||
{
|
||||
public Dictionary<Vector2i, DecalChunk> ModifiedChunks = modifiedChunks;
|
||||
public HashSet<Vector2i> AllChunks = allChunks;
|
||||
|
||||
public DecalGridState(Dictionary<Vector2i, DecalChunk> chunks)
|
||||
public void ApplyToFullState(DecalGridState state)
|
||||
{
|
||||
Chunks = chunks;
|
||||
}
|
||||
|
||||
public void ApplyToFullState(IComponentState fullState)
|
||||
{
|
||||
DebugTools.Assert(!FullState);
|
||||
var state = (DecalGridState) fullState;
|
||||
DebugTools.Assert(state.FullState);
|
||||
|
||||
foreach (var key in state.Chunks.Keys)
|
||||
{
|
||||
if (!AllChunks!.Contains(key))
|
||||
state.Chunks.Remove(key);
|
||||
}
|
||||
|
||||
foreach (var (chunk, data) in Chunks)
|
||||
foreach (var (chunk, data) in ModifiedChunks)
|
||||
{
|
||||
state.Chunks[chunk] = new(data);
|
||||
}
|
||||
}
|
||||
|
||||
public IComponentState CreateNewFullState(IComponentState fullState)
|
||||
public DecalGridState CreateNewFullState(DecalGridState state)
|
||||
{
|
||||
DebugTools.Assert(!FullState);
|
||||
var state = (DecalGridState) fullState;
|
||||
DebugTools.Assert(state.FullState);
|
||||
|
||||
var chunks = new Dictionary<Vector2i, DecalChunk>(state.Chunks.Count);
|
||||
|
||||
foreach (var (chunk, data) in Chunks)
|
||||
foreach (var (chunk, data) in ModifiedChunks)
|
||||
{
|
||||
chunks[chunk] = new(data);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Content.Shared.Decals
|
||||
data[index] = chunk;
|
||||
}
|
||||
|
||||
args.State = new DecalGridState(data) { AllChunks = new(component.ChunkCollection.ChunkCollection.Keys) };
|
||||
args.State = new DecalGridDeltaState(data, new(component.ChunkCollection.ChunkCollection.Keys));
|
||||
}
|
||||
|
||||
private void OnGridInitialize(GridInitializeEvent msg)
|
||||
|
||||
Reference in New Issue
Block a user