Ejemplo n.º 1
0
 static RotationSerializer()
 {
     Serializer = new GhostComponentSerializer
     {
         IsUpdateValue  = false,
         SendType       = GhostSendType.Predicted,
         ComponentType  = ComponentType.ReadWrite <Rotation>(),
         ComponentSize  = UnsafeUtility.SizeOf <Rotation>(),
         DataSize       = UnsafeUtility.SizeOf <Snapshot>(),
         CopyToSnapshot =
             new PortableFunctionPointer <GhostComponentSerializer.CopyToSnapshotDelegate>(CopyToSnapshot),
         CopyFromSnapshot =
             new PortableFunctionPointer <GhostComponentSerializer.CopyFromSnapshotDelegate>(CopyFromSnapshot),
         Serialize         = new PortableFunctionPointer <GhostComponentSerializer.SerializeDelegate>(Serialize),
         Deserialize       = new PortableFunctionPointer <GhostComponentSerializer.DeserializeDelegate>(Deserialize),
         RestoreFromBackup =
             new PortableFunctionPointer <GhostComponentSerializer.RestoreFromBackupDelegate>(RestoreFromBackup)
     };
 }
 private static void CopyToSnapshot(IntPtr stateData, IntPtr snapshotData, int snapshotOffset, int snapshotStride, IntPtr componentData, int componentStride, int count)
 {
     for (int i = 0; i < count; ++i)
     {
         ref var snapshot        = ref GhostComponentSerializer.TypeCast <Snapshot>(snapshotData, snapshotOffset + snapshotStride * i);
         ref var component       = ref GhostComponentSerializer.TypeCast <AgentComponent>(componentData, componentStride * i);