Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 00de5f1

Browse files
authored
Entity queries - now with snapshots (#551)
Fixed snapshots by adding a component snapshot type
1 parent e6b54b8 commit 00de5f1

File tree

30 files changed

+1901
-115
lines changed

30 files changed

+1901
-115
lines changed

test-project/Assets/Generated/Source/improbable/gdk/tests/ExhaustiveBlittableSingular.cs

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public long Field15
291291
long field15,
292292
global::Improbable.Worker.EntityId field16,
293293
global::Improbable.Gdk.Tests.SomeType field17
294-
)
294+
)
295295
{
296296
var schemaComponentData = new global::Improbable.Worker.Core.SchemaComponentData(197720);
297297
var obj = schemaComponentData.GetFields();
@@ -344,6 +344,27 @@ public long Field15
344344
}
345345
}
346346

347+
public struct Snapshot : ISpatialComponentSnapshot
348+
{
349+
public uint ComponentId => 197720;
350+
351+
public BlittableBool Field1;
352+
public float Field2;
353+
public int Field4;
354+
public long Field5;
355+
public double Field6;
356+
public uint Field8;
357+
public ulong Field9;
358+
public int Field10;
359+
public long Field11;
360+
public uint Field12;
361+
public ulong Field13;
362+
public int Field14;
363+
public long Field15;
364+
public global::Improbable.Worker.EntityId Field16;
365+
public global::Improbable.Gdk.Tests.SomeType Field17;
366+
}
367+
347368
public static class Serialization
348369
{
349370
public static void SerializeUpdate(Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Component component, global::Improbable.Worker.Core.SchemaComponentUpdate updateObj)
@@ -636,6 +657,73 @@ public static Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Update Deserializ
636657
return update;
637658
}
638659

660+
public static Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Snapshot DeserializeSnapshot(global::Improbable.Worker.Core.SchemaObject obj, global::Unity.Entities.World world)
661+
{
662+
var component = new Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Snapshot();
663+
664+
{
665+
component.Field1 = obj.GetBool(1);
666+
}
667+
668+
{
669+
component.Field2 = obj.GetFloat(2);
670+
}
671+
672+
{
673+
component.Field4 = obj.GetInt32(4);
674+
}
675+
676+
{
677+
component.Field5 = obj.GetInt64(5);
678+
}
679+
680+
{
681+
component.Field6 = obj.GetDouble(6);
682+
}
683+
684+
{
685+
component.Field8 = obj.GetUint32(8);
686+
}
687+
688+
{
689+
component.Field9 = obj.GetUint64(9);
690+
}
691+
692+
{
693+
component.Field10 = obj.GetSint32(10);
694+
}
695+
696+
{
697+
component.Field11 = obj.GetSint64(11);
698+
}
699+
700+
{
701+
component.Field12 = obj.GetFixed32(12);
702+
}
703+
704+
{
705+
component.Field13 = obj.GetFixed64(13);
706+
}
707+
708+
{
709+
component.Field14 = obj.GetSfixed32(14);
710+
}
711+
712+
{
713+
component.Field15 = obj.GetSfixed64(15);
714+
}
715+
716+
{
717+
component.Field16 = obj.GetEntityId(16);
718+
}
719+
720+
{
721+
component.Field17 = global::Improbable.Gdk.Tests.SomeType.Serialization.Deserialize(obj.GetObject(17));
722+
}
723+
724+
return component;
725+
}
726+
639727
public static void ApplyUpdate(global::Improbable.Worker.Core.SchemaComponentUpdate updateObj, ref Improbable.Gdk.Tests.ExhaustiveBlittableSingular.Component component)
640728
{
641729
var obj = updateObj.GetFields();
@@ -819,10 +907,26 @@ private static Update DeserializeUpdate(ComponentUpdate update, World world)
819907
return Serialization.DeserializeUpdate(schemaDataOpt.Value);
820908
}
821909

910+
private static Snapshot DeserializeSnapshot(ComponentData snapshot, World world)
911+
{
912+
var schemaDataOpt = snapshot.SchemaData;
913+
if (!schemaDataOpt.HasValue)
914+
{
915+
throw new ArgumentException($"Can not deserialize an empty {nameof(ComponentData)}");
916+
}
917+
918+
return Serialization.DeserializeSnapshot(schemaDataOpt.Value.GetFields(), world);
919+
}
920+
822921
public void InvokeHandler(Dynamic.IHandler handler)
823922
{
824923
handler.Accept<Component, Update>(ExhaustiveBlittableSingular.ComponentId, DeserializeData, DeserializeUpdate);
825924
}
925+
926+
public void InvokeSnapshotHandler(DynamicSnapshot.ISnapshotHandler handler)
927+
{
928+
handler.Accept<Snapshot>(ExhaustiveBlittableSingular.ComponentId, DeserializeSnapshot);
929+
}
826930
}
827931
}
828932
}

0 commit comments

Comments
 (0)