refactor(runtime): acknowledge exact world host projections
This commit is contained in:
parent
73d0b54e38
commit
18d17d8bb1
17 changed files with 1677 additions and 72 deletions
|
|
@ -63,6 +63,9 @@ internal sealed class WorldGenerationQuiescence
|
|||
private readonly Func<uint, RuntimeEntityKey?> _resolveProjectionKey;
|
||||
private readonly IWorldAudioQuiescence? _audio;
|
||||
private bool _effectsQuiesced;
|
||||
private bool _selectionEdgeCommitted;
|
||||
private bool _audioSuspended;
|
||||
private bool _audioTransitionActive;
|
||||
|
||||
public WorldGenerationQuiescence(
|
||||
SelectionState selection,
|
||||
|
|
@ -99,26 +102,62 @@ internal sealed class WorldGenerationQuiescence
|
|||
|
||||
public void CommitBegin(in WorldGenerationQuiescenceEdge edge)
|
||||
{
|
||||
if (!edge.ShouldApply || _effectsQuiesced)
|
||||
if (!edge.ShouldApply)
|
||||
return;
|
||||
|
||||
_effectsQuiesced = true;
|
||||
if (edge.ClearWorldSelection)
|
||||
if (!_selectionEdgeCommitted)
|
||||
{
|
||||
_selection.Clear(
|
||||
SelectionChangeSource.System,
|
||||
SelectionChangeReason.Cleared);
|
||||
// SelectionState commits its value before notifying observers.
|
||||
// Record the edge first so a re-entrant reveal cannot replay it.
|
||||
_selectionEdgeCommitted = true;
|
||||
if (edge.ClearWorldSelection)
|
||||
{
|
||||
_selection.Clear(
|
||||
SelectionChangeSource.System,
|
||||
SelectionChangeReason.Cleared);
|
||||
}
|
||||
}
|
||||
|
||||
_audio?.SuspendWorldAudio();
|
||||
ReconcileAudio();
|
||||
}
|
||||
|
||||
public void ObserveReleased()
|
||||
{
|
||||
if (!_effectsQuiesced)
|
||||
if (!_effectsQuiesced
|
||||
&& !_selectionEdgeCommitted
|
||||
&& !_audioSuspended)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_effectsQuiesced = false;
|
||||
_audio?.ResumeWorldAudio();
|
||||
ReconcileAudio();
|
||||
if (!_effectsQuiesced && !_audioSuspended)
|
||||
_selectionEdgeCommitted = false;
|
||||
}
|
||||
|
||||
private void ReconcileAudio()
|
||||
{
|
||||
if (_audio is null || _audioTransitionActive)
|
||||
return;
|
||||
|
||||
_audioTransitionActive = true;
|
||||
try
|
||||
{
|
||||
while (_audioSuspended != _effectsQuiesced)
|
||||
{
|
||||
bool suspend = _effectsQuiesced;
|
||||
if (suspend)
|
||||
_audio.SuspendWorldAudio();
|
||||
else
|
||||
_audio.ResumeWorldAudio();
|
||||
_audioSuspended = suspend;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_audioTransitionActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue