Skip expired CultMesh entity generations
This commit is contained in:
parent
d9c1de9130
commit
eae2e896c7
3 changed files with 30 additions and 2 deletions
|
|
@ -313,6 +313,9 @@ namespace GameCult.Eve.UnityScene
|
|||
?? throw new InvalidOperationException(
|
||||
$"Provider did not publish CultMesh body generation '{handle.RecordKey.Value}'.");
|
||||
handle.Validate(publication);
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
if (!IsPublicationLive(publication, now))
|
||||
return;
|
||||
var lease = _bodyResolver.ResolveReadOnly(publication, new CultMeshBodyValidationRequest
|
||||
{
|
||||
BodyId = handle.BodyId,
|
||||
|
|
@ -322,7 +325,7 @@ namespace GameCult.Eve.UnityScene
|
|||
Sequence = document.Sequence,
|
||||
Capacity = document.Capacity,
|
||||
AccessMode = CultMeshBodyAccessMode.ReadOnly,
|
||||
NowUtc = DateTimeOffset.UtcNow
|
||||
NowUtc = now
|
||||
});
|
||||
var handler = EntityViewAvailable;
|
||||
if (handler == null)
|
||||
|
|
@ -341,6 +344,11 @@ namespace GameCult.Eve.UnityScene
|
|||
}
|
||||
}
|
||||
|
||||
private static bool IsPublicationLive(
|
||||
CultMeshBodyPublicationDocument publication,
|
||||
DateTimeOffset now) =>
|
||||
publication.LivenessExpiresAtUnixMs > now.ToUnixTimeMilliseconds();
|
||||
|
||||
private void RefreshSurface()
|
||||
{
|
||||
var surface = _snapshot!
|
||||
|
|
|
|||
|
|
@ -37,6 +37,26 @@ namespace GameCult.Eve.UnityScene.Tests
|
|||
Assert.That(handle.RecordKey, Is.Not.EqualTo(generationNPlusOne.RecordKey));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LiveTransportDropsExpiredHistoricalGenerationWithoutReinterpretingLatest()
|
||||
{
|
||||
var view = EntityLeaseDocument();
|
||||
var publication = BodyPublication(view, view.Sequence);
|
||||
publication.LivenessExpiresAtUnixMs = 999;
|
||||
var method = typeof(EveUnityCultMeshLiveProviderTransport)
|
||||
.GetMethod("IsPublicationLive", BindingFlags.NonPublic | BindingFlags.Static)!;
|
||||
|
||||
var live = (bool)method.Invoke(null, new object[]
|
||||
{
|
||||
publication,
|
||||
DateTimeOffset.FromUnixTimeMilliseconds(1000)
|
||||
})!;
|
||||
|
||||
Assert.That(live, Is.False);
|
||||
Assert.That(publication.RecordKey, Is.EqualTo(
|
||||
new CultMeshBodyPublicationHandle(view.Buffers[0].BufferId, view.ProducerEpoch, view.Sequence).RecordKey));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntitySoaViewReadsGenericSemanticColumnsFromInjectedLease()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "org.gamecult.eve.unity-scene",
|
||||
"displayName": "Eve Unity Scene Lowering",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"unity": "2021.3",
|
||||
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Reference in a new issue