feat(runtime): own deferred set-position residence

This commit is contained in:
Erik 2026-07-31 22:32:49 +02:00
parent e84a388e6f
commit 4c02ac4259
18 changed files with 5557 additions and 34 deletions

View file

@ -264,6 +264,87 @@ public sealed class ParentAttachmentStateTests
Assert.Equal((ushort)6, projection.ChildPositionSequence);
}
[Fact]
public void CommittedChildrenAppendInCommitOrder()
{
const uint parentGuid = 0x70000200u;
var relations = new ParentAttachmentState();
Commit(relations, Relation(parentGuid, 0x70000201u, parentInstance: 9));
Commit(relations, Relation(parentGuid, 0x70000202u, parentInstance: 9));
IReadOnlyList<uint> committed = relations.ChildrenAttachedToParent(
parentGuid,
9);
Commit(relations, Relation(parentGuid, 0x70000203u, parentInstance: 9));
Assert.Same(
committed,
relations.ChildrenAttachedToParent(parentGuid, 9));
Assert.Equal(
[0x70000201u, 0x70000202u, 0x70000203u],
committed);
}
[Fact]
public void EndingChildProjectionSwapRemovesCommittedChild()
{
const uint parentGuid = 0x70000210u;
var relations = new ParentAttachmentState();
Commit(relations, Relation(parentGuid, 0x70000211u, parentInstance: 9));
Commit(relations, Relation(parentGuid, 0x70000212u, parentInstance: 9));
Commit(relations, Relation(parentGuid, 0x70000213u, parentInstance: 9));
relations.EndChildProjection(0x70000211u);
Assert.Equal(
[0x70000213u, 0x70000212u],
relations.ChildrenAttachedToParent(parentGuid, 9));
}
[Fact]
public void ReparentSwapRemovesOldEntryAndAppendsNewEntry()
{
const uint oldParentGuid = 0x70000220u;
const uint newParentGuid = 0x70000221u;
const uint childGuid = 0x70000222u;
var relations = new ParentAttachmentState();
Commit(relations, Relation(oldParentGuid, childGuid, parentInstance: 9));
Commit(relations, Relation(oldParentGuid, 0x70000223u, parentInstance: 9));
Commit(relations, Relation(oldParentGuid, 0x70000224u, parentInstance: 9));
Commit(relations, Relation(newParentGuid, 0x70000225u, parentInstance: 4));
Commit(relations, Relation(newParentGuid, childGuid, parentInstance: 4));
Assert.Equal(
[0x70000224u, 0x70000223u],
relations.ChildrenAttachedToParent(oldParentGuid, 9));
Assert.Equal(
[0x70000225u, childGuid],
relations.ChildrenAttachedToParent(newParentGuid, 4));
}
[Fact]
public void CommittedChildrenAreIsolatedByParentGuidAndIncarnation()
{
const uint parentGuid = 0x70000230u;
const uint otherParentGuid = 0x70000231u;
var relations = new ParentAttachmentState();
Commit(relations, Relation(parentGuid, 0x70000232u, parentInstance: 9));
Commit(relations, Relation(parentGuid, 0x70000233u, parentInstance: 10));
Commit(relations, Relation(otherParentGuid, 0x70000234u, parentInstance: 9));
Assert.Equal(
[0x70000232u],
relations.ChildrenAttachedToParent(parentGuid, 9));
Assert.Equal(
[0x70000233u],
relations.ChildrenAttachedToParent(parentGuid, 10));
Assert.Equal(
[0x70000234u],
relations.ChildrenAttachedToParent(otherParentGuid, 9));
Assert.Empty(relations.ChildrenAttachedToParent(otherParentGuid, 10));
}
private static void Resolve(
ParentAttachmentState relations,
InboundPhysicsStateController inbound,
@ -290,6 +371,20 @@ public sealed class ParentAttachmentStateTests
out accepted)
&& relations.CommitProjection(relation);
private static void Commit(
ParentAttachmentState relations,
ParentAttachmentRelation relation)
{
relations.AcceptCreateObjectRelation(relation);
Assert.True(relations.CommitProjection(relation));
}
private static ParentAttachmentRelation Relation(
uint parentGuid,
uint childGuid,
ushort parentInstance) =>
new(parentGuid, childGuid, 1, 2, parentInstance, 1);
private static WorldSession.EntitySpawn Spawn(
uint guid,
ushort instance,