feat(runtime): atomically replace collision generations
This commit is contained in:
parent
99bf1751bb
commit
9b0f59bd1b
21 changed files with 2435 additions and 408 deletions
|
|
@ -12,8 +12,8 @@ public enum LandblockRetirementStage : ushort
|
|||
EntityLighting = 1 << 3,
|
||||
EntityTranslucency = 1 << 4,
|
||||
PluginProjection = 1 << 5,
|
||||
Terrain = 1 << 6,
|
||||
Physics = 1 << 7,
|
||||
Physics = 1 << 6,
|
||||
Terrain = 1 << 7,
|
||||
CellVisibility = 1 << 8,
|
||||
BuildingRegistry = 1 << 9,
|
||||
EnvironmentCells = 1 << 10,
|
||||
|
|
@ -24,6 +24,7 @@ internal enum LandblockRetirementOperationResult : byte
|
|||
{
|
||||
NoWork,
|
||||
Progressed,
|
||||
Pending,
|
||||
Failed,
|
||||
}
|
||||
|
||||
|
|
@ -77,6 +78,28 @@ public sealed class LandblockRetirementTicket
|
|||
}
|
||||
}
|
||||
|
||||
public bool RunOnce(LandblockRetirementStage stage, Func<bool> operation)
|
||||
{
|
||||
ValidateSingleStage(stage);
|
||||
ArgumentNullException.ThrowIfNull(operation);
|
||||
if ((CompletedStages & stage) != 0)
|
||||
return true;
|
||||
|
||||
try
|
||||
{
|
||||
if (!operation())
|
||||
return false;
|
||||
CompletedStages |= stage;
|
||||
_failures.Remove(stage);
|
||||
return true;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
_failures[stage] = error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal LandblockRetirementOperationResult RunOnceStep(
|
||||
LandblockRetirementStage stage,
|
||||
Action operation)
|
||||
|
|
@ -100,6 +123,31 @@ public sealed class LandblockRetirementTicket
|
|||
}
|
||||
}
|
||||
|
||||
internal LandblockRetirementOperationResult RunOnceStep(
|
||||
LandblockRetirementStage stage,
|
||||
Func<bool> operation)
|
||||
{
|
||||
ValidateSingleStage(stage);
|
||||
ArgumentNullException.ThrowIfNull(operation);
|
||||
if ((CompletedStages & stage) != 0)
|
||||
return LandblockRetirementOperationResult.NoWork;
|
||||
|
||||
try
|
||||
{
|
||||
if (!operation())
|
||||
return LandblockRetirementOperationResult.Pending;
|
||||
|
||||
CompletedStages |= stage;
|
||||
_failures.Remove(stage);
|
||||
return LandblockRetirementOperationResult.Progressed;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
_failures[stage] = error;
|
||||
return LandblockRetirementOperationResult.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RunForEachEntity(
|
||||
LandblockRetirementStage stage,
|
||||
Func<WorldEntity, bool> predicate,
|
||||
|
|
@ -815,6 +863,8 @@ public sealed class LandblockRetirementCoordinator
|
|||
}
|
||||
|
||||
meter.Complete();
|
||||
if (result == LandblockRetirementOperationResult.Pending)
|
||||
return BudgetedAdvanceResult.Yielded;
|
||||
return BudgetedAdvanceResult.Progressed;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue