public void Serialize(int networkId, ref ACivilianSnapshotData baseline, ref DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     changeMask0  = (HealthValue != baseline.HealthValue) ? 1u : 0;
     changeMask0 |= (PlayerUnitPlayerId != baseline.PlayerUnitPlayerId) ? (1u << 1) : 0;
     changeMask0 |= (PlayerUnitUnitId != baseline.PlayerUnitUnitId) ? (1u << 2) : 0;
     changeMask0 |= (UnitSelectionStateIsSelected != baseline.UnitSelectionStateIsSelected) ? (1u << 3) : 0;
     changeMask0 |= (RotationValueX != baseline.RotationValueX ||
                     RotationValueY != baseline.RotationValueY ||
                     RotationValueZ != baseline.RotationValueZ ||
                     RotationValueW != baseline.RotationValueW) ? (1u << 4) : 0;
     changeMask0 |= (TranslationValueX != baseline.TranslationValueX ||
                     TranslationValueY != baseline.TranslationValueY ||
                     TranslationValueZ != baseline.TranslationValueZ) ? (1u << 5) : 0;
     changeMask0 |= (Child0RotationValueX != baseline.Child0RotationValueX ||
                     Child0RotationValueY != baseline.Child0RotationValueY ||
                     Child0RotationValueZ != baseline.Child0RotationValueZ ||
                     Child0RotationValueW != baseline.Child0RotationValueW) ? (1u << 6) : 0;
     changeMask0 |= (Child0TranslationValueX != baseline.Child0TranslationValueX ||
                     Child0TranslationValueY != baseline.Child0TranslationValueY ||
                     Child0TranslationValueZ != baseline.Child0TranslationValueZ) ? (1u << 7) : 0;
     changeMask0 |= (Child1RotationValueX != baseline.Child1RotationValueX ||
                     Child1RotationValueY != baseline.Child1RotationValueY ||
                     Child1RotationValueZ != baseline.Child1RotationValueZ ||
                     Child1RotationValueW != baseline.Child1RotationValueW) ? (1u << 8) : 0;
     changeMask0 |= (Child1TranslationValueX != baseline.Child1TranslationValueX ||
                     Child1TranslationValueY != baseline.Child1TranslationValueY ||
                     Child1TranslationValueZ != baseline.Child1TranslationValueZ) ? (1u << 9) : 0;
     writer.WritePackedUIntDelta(changeMask0, baseline.changeMask0, compressionModel);
     if ((changeMask0 & (1 << 0)) != 0)
     {
         writer.WritePackedIntDelta(HealthValue, baseline.HealthValue, compressionModel);
     }
     if ((changeMask0 & (1 << 1)) != 0)
     {
         writer.WritePackedIntDelta(PlayerUnitPlayerId, baseline.PlayerUnitPlayerId, compressionModel);
     }
     if ((changeMask0 & (1 << 2)) != 0)
     {
         writer.WritePackedIntDelta(PlayerUnitUnitId, baseline.PlayerUnitUnitId, compressionModel);
     }
     if ((changeMask0 & (1 << 3)) != 0)
     {
         writer.WritePackedUIntDelta(UnitSelectionStateIsSelected, baseline.UnitSelectionStateIsSelected, compressionModel);
     }
     if ((changeMask0 & (1 << 4)) != 0)
     {
         writer.WritePackedIntDelta(RotationValueX, baseline.RotationValueX, compressionModel);
         writer.WritePackedIntDelta(RotationValueY, baseline.RotationValueY, compressionModel);
         writer.WritePackedIntDelta(RotationValueZ, baseline.RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(RotationValueW, baseline.RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 5)) != 0)
     {
         writer.WritePackedIntDelta(TranslationValueX, baseline.TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(TranslationValueY, baseline.TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(TranslationValueZ, baseline.TranslationValueZ, compressionModel);
     }
     if ((changeMask0 & (1 << 6)) != 0)
     {
         writer.WritePackedIntDelta(Child0RotationValueX, baseline.Child0RotationValueX, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueY, baseline.Child0RotationValueY, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueZ, baseline.Child0RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueW, baseline.Child0RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 7)) != 0)
     {
         writer.WritePackedIntDelta(Child0TranslationValueX, baseline.Child0TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(Child0TranslationValueY, baseline.Child0TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(Child0TranslationValueZ, baseline.Child0TranslationValueZ, compressionModel);
     }
     if ((changeMask0 & (1 << 8)) != 0)
     {
         writer.WritePackedIntDelta(Child1RotationValueX, baseline.Child1RotationValueX, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueY, baseline.Child1RotationValueY, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueZ, baseline.Child1RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueW, baseline.Child1RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 9)) != 0)
     {
         writer.WritePackedIntDelta(Child1TranslationValueX, baseline.Child1TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(Child1TranslationValueY, baseline.Child1TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(Child1TranslationValueZ, baseline.Child1TranslationValueZ, compressionModel);
     }
 }
 public void Deserialize(uint tick, ref ACivilianSnapshotData baseline, ref DataStreamReader reader,
                         NetworkCompressionModel compressionModel)
 {
     this.tick   = tick;
     changeMask0 = reader.ReadPackedUIntDelta(baseline.changeMask0, compressionModel);
     if ((changeMask0 & (1 << 0)) != 0)
     {
         HealthValue = reader.ReadPackedIntDelta(baseline.HealthValue, compressionModel);
     }
     else
     {
         HealthValue = baseline.HealthValue;
     }
     if ((changeMask0 & (1 << 1)) != 0)
     {
         PlayerUnitPlayerId = reader.ReadPackedIntDelta(baseline.PlayerUnitPlayerId, compressionModel);
     }
     else
     {
         PlayerUnitPlayerId = baseline.PlayerUnitPlayerId;
     }
     if ((changeMask0 & (1 << 2)) != 0)
     {
         PlayerUnitUnitId = reader.ReadPackedIntDelta(baseline.PlayerUnitUnitId, compressionModel);
     }
     else
     {
         PlayerUnitUnitId = baseline.PlayerUnitUnitId;
     }
     if ((changeMask0 & (1 << 3)) != 0)
     {
         UnitSelectionStateIsSelected = reader.ReadPackedUIntDelta(baseline.UnitSelectionStateIsSelected, compressionModel);
     }
     else
     {
         UnitSelectionStateIsSelected = baseline.UnitSelectionStateIsSelected;
     }
     if ((changeMask0 & (1 << 4)) != 0)
     {
         RotationValueX = reader.ReadPackedIntDelta(baseline.RotationValueX, compressionModel);
         RotationValueY = reader.ReadPackedIntDelta(baseline.RotationValueY, compressionModel);
         RotationValueZ = reader.ReadPackedIntDelta(baseline.RotationValueZ, compressionModel);
         RotationValueW = reader.ReadPackedIntDelta(baseline.RotationValueW, compressionModel);
     }
     else
     {
         RotationValueX = baseline.RotationValueX;
         RotationValueY = baseline.RotationValueY;
         RotationValueZ = baseline.RotationValueZ;
         RotationValueW = baseline.RotationValueW;
     }
     if ((changeMask0 & (1 << 5)) != 0)
     {
         TranslationValueX = reader.ReadPackedIntDelta(baseline.TranslationValueX, compressionModel);
         TranslationValueY = reader.ReadPackedIntDelta(baseline.TranslationValueY, compressionModel);
         TranslationValueZ = reader.ReadPackedIntDelta(baseline.TranslationValueZ, compressionModel);
     }
     else
     {
         TranslationValueX = baseline.TranslationValueX;
         TranslationValueY = baseline.TranslationValueY;
         TranslationValueZ = baseline.TranslationValueZ;
     }
     if ((changeMask0 & (1 << 6)) != 0)
     {
         Child0RotationValueX = reader.ReadPackedIntDelta(baseline.Child0RotationValueX, compressionModel);
         Child0RotationValueY = reader.ReadPackedIntDelta(baseline.Child0RotationValueY, compressionModel);
         Child0RotationValueZ = reader.ReadPackedIntDelta(baseline.Child0RotationValueZ, compressionModel);
         Child0RotationValueW = reader.ReadPackedIntDelta(baseline.Child0RotationValueW, compressionModel);
     }
     else
     {
         Child0RotationValueX = baseline.Child0RotationValueX;
         Child0RotationValueY = baseline.Child0RotationValueY;
         Child0RotationValueZ = baseline.Child0RotationValueZ;
         Child0RotationValueW = baseline.Child0RotationValueW;
     }
     if ((changeMask0 & (1 << 7)) != 0)
     {
         Child0TranslationValueX = reader.ReadPackedIntDelta(baseline.Child0TranslationValueX, compressionModel);
         Child0TranslationValueY = reader.ReadPackedIntDelta(baseline.Child0TranslationValueY, compressionModel);
         Child0TranslationValueZ = reader.ReadPackedIntDelta(baseline.Child0TranslationValueZ, compressionModel);
     }
     else
     {
         Child0TranslationValueX = baseline.Child0TranslationValueX;
         Child0TranslationValueY = baseline.Child0TranslationValueY;
         Child0TranslationValueZ = baseline.Child0TranslationValueZ;
     }
     if ((changeMask0 & (1 << 8)) != 0)
     {
         Child1RotationValueX = reader.ReadPackedIntDelta(baseline.Child1RotationValueX, compressionModel);
         Child1RotationValueY = reader.ReadPackedIntDelta(baseline.Child1RotationValueY, compressionModel);
         Child1RotationValueZ = reader.ReadPackedIntDelta(baseline.Child1RotationValueZ, compressionModel);
         Child1RotationValueW = reader.ReadPackedIntDelta(baseline.Child1RotationValueW, compressionModel);
     }
     else
     {
         Child1RotationValueX = baseline.Child1RotationValueX;
         Child1RotationValueY = baseline.Child1RotationValueY;
         Child1RotationValueZ = baseline.Child1RotationValueZ;
         Child1RotationValueW = baseline.Child1RotationValueW;
     }
     if ((changeMask0 & (1 << 9)) != 0)
     {
         Child1TranslationValueX = reader.ReadPackedIntDelta(baseline.Child1TranslationValueX, compressionModel);
         Child1TranslationValueY = reader.ReadPackedIntDelta(baseline.Child1TranslationValueY, compressionModel);
         Child1TranslationValueZ = reader.ReadPackedIntDelta(baseline.Child1TranslationValueZ, compressionModel);
     }
     else
     {
         Child1TranslationValueX = baseline.Child1TranslationValueX;
         Child1TranslationValueY = baseline.Child1TranslationValueY;
         Child1TranslationValueZ = baseline.Child1TranslationValueZ;
     }
 }
예제 #3
0
 public void Deserialize(uint tick, ref DataStreamReader reader, CubeInput baseline, NetworkCompressionModel compressionModel)
 {
     Deserialize(tick, ref reader);
 }
예제 #4
0
 public void Serialize(int networkId, ref NetCubeSnapshotData baseline, ref DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     changeMask0  = (MovableCubeComponentPlayerId != baseline.MovableCubeComponentPlayerId) ? 1u : 0;
     changeMask0 |= (RotationValueX != baseline.RotationValueX ||
                     RotationValueY != baseline.RotationValueY ||
                     RotationValueZ != baseline.RotationValueZ ||
                     RotationValueW != baseline.RotationValueW) ? (1u << 1) : 0;
     changeMask0 |= (TranslationValueX != baseline.TranslationValueX ||
                     TranslationValueY != baseline.TranslationValueY ||
                     TranslationValueZ != baseline.TranslationValueZ) ? (1u << 2) : 0;
     writer.WritePackedUIntDelta(changeMask0, baseline.changeMask0, compressionModel);
     if ((changeMask0 & (1 << 0)) != 0)
     {
         writer.WritePackedIntDelta(MovableCubeComponentPlayerId, baseline.MovableCubeComponentPlayerId, compressionModel);
     }
     if ((changeMask0 & (1 << 1)) != 0)
     {
         writer.WritePackedIntDelta(RotationValueX, baseline.RotationValueX, compressionModel);
         writer.WritePackedIntDelta(RotationValueY, baseline.RotationValueY, compressionModel);
         writer.WritePackedIntDelta(RotationValueZ, baseline.RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(RotationValueW, baseline.RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 2)) != 0)
     {
         writer.WritePackedIntDelta(TranslationValueX, baseline.TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(TranslationValueY, baseline.TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(TranslationValueZ, baseline.TranslationValueZ, compressionModel);
     }
 }
 public void Serialize(int networkId, ref GhostSnapshotData baseline, DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     #region __GHOST_CALCULATE_CHANGE_MASK_ZERO__
     changeMask__GHOST_MASK_BATCH__ = (__GHOST_FIELD_NAME__X != baseline.__GHOST_FIELD_NAME__X ||
                                       __GHOST_FIELD_NAME__Y != baseline.__GHOST_FIELD_NAME__Y) ? 1u : 0;
     #endregion
     #region __GHOST_CALCULATE_CHANGE_MASK__
     changeMask__GHOST_MASK_BATCH__ |= (__GHOST_FIELD_NAME__X != baseline.__GHOST_FIELD_NAME__X ||
                                        __GHOST_FIELD_NAME__Y != baseline.__GHOST_FIELD_NAME__Y) ? (1u << __GHOST_MASK_INDEX__) : 0;
     #endregion
     #region __GHOST_WRITE__
     if ((changeMask__GHOST_MASK_BATCH__ & (1 << __GHOST_MASK_INDEX__)) != 0)
     {
         writer.WritePackedFloatDelta(__GHOST_FIELD_NAME__X, baseline.__GHOST_FIELD_NAME__X, compressionModel);
         writer.WritePackedFloatDelta(__GHOST_FIELD_NAME__Y, baseline.__GHOST_FIELD_NAME__Y, compressionModel);
     }
     #endregion
 }
예제 #6
0
 public void Serialize(ref DataStreamWriter writer, CubeInput baseline, NetworkCompressionModel compressionModel)
 {
     writer.WriteInt(Horizontal);
     writer.WriteInt(Vertical);
 }
예제 #7
0
 public void Deserialize(uint tick, ref ArrowSnapshotData baseline, ref DataStreamReader reader,
                         NetworkCompressionModel compressionModel)
 {
     this.tick   = tick;
     changeMask0 = reader.ReadPackedUIntDelta(baseline.changeMask0, compressionModel);
     if ((changeMask0 & (1 << 0)) != 0)
     {
         PlayerBulletPlayerId = reader.ReadPackedIntDelta(baseline.PlayerBulletPlayerId, compressionModel);
     }
     else
     {
         PlayerBulletPlayerId = baseline.PlayerBulletPlayerId;
     }
     if ((changeMask0 & (1 << 1)) != 0)
     {
         RotationValueX = reader.ReadPackedIntDelta(baseline.RotationValueX, compressionModel);
         RotationValueY = reader.ReadPackedIntDelta(baseline.RotationValueY, compressionModel);
         RotationValueZ = reader.ReadPackedIntDelta(baseline.RotationValueZ, compressionModel);
         RotationValueW = reader.ReadPackedIntDelta(baseline.RotationValueW, compressionModel);
     }
     else
     {
         RotationValueX = baseline.RotationValueX;
         RotationValueY = baseline.RotationValueY;
         RotationValueZ = baseline.RotationValueZ;
         RotationValueW = baseline.RotationValueW;
     }
     if ((changeMask0 & (1 << 2)) != 0)
     {
         TranslationValueX = reader.ReadPackedIntDelta(baseline.TranslationValueX, compressionModel);
         TranslationValueY = reader.ReadPackedIntDelta(baseline.TranslationValueY, compressionModel);
         TranslationValueZ = reader.ReadPackedIntDelta(baseline.TranslationValueZ, compressionModel);
     }
     else
     {
         TranslationValueX = baseline.TranslationValueX;
         TranslationValueY = baseline.TranslationValueY;
         TranslationValueZ = baseline.TranslationValueZ;
     }
     if ((changeMask0 & (1 << 3)) != 0)
     {
         Child0RotationValueX = reader.ReadPackedIntDelta(baseline.Child0RotationValueX, compressionModel);
         Child0RotationValueY = reader.ReadPackedIntDelta(baseline.Child0RotationValueY, compressionModel);
         Child0RotationValueZ = reader.ReadPackedIntDelta(baseline.Child0RotationValueZ, compressionModel);
         Child0RotationValueW = reader.ReadPackedIntDelta(baseline.Child0RotationValueW, compressionModel);
     }
     else
     {
         Child0RotationValueX = baseline.Child0RotationValueX;
         Child0RotationValueY = baseline.Child0RotationValueY;
         Child0RotationValueZ = baseline.Child0RotationValueZ;
         Child0RotationValueW = baseline.Child0RotationValueW;
     }
     if ((changeMask0 & (1 << 4)) != 0)
     {
         Child0TranslationValueX = reader.ReadPackedIntDelta(baseline.Child0TranslationValueX, compressionModel);
         Child0TranslationValueY = reader.ReadPackedIntDelta(baseline.Child0TranslationValueY, compressionModel);
         Child0TranslationValueZ = reader.ReadPackedIntDelta(baseline.Child0TranslationValueZ, compressionModel);
     }
     else
     {
         Child0TranslationValueX = baseline.Child0TranslationValueX;
         Child0TranslationValueY = baseline.Child0TranslationValueY;
         Child0TranslationValueZ = baseline.Child0TranslationValueZ;
     }
     if ((changeMask0 & (1 << 5)) != 0)
     {
         Child1RotationValueX = reader.ReadPackedIntDelta(baseline.Child1RotationValueX, compressionModel);
         Child1RotationValueY = reader.ReadPackedIntDelta(baseline.Child1RotationValueY, compressionModel);
         Child1RotationValueZ = reader.ReadPackedIntDelta(baseline.Child1RotationValueZ, compressionModel);
         Child1RotationValueW = reader.ReadPackedIntDelta(baseline.Child1RotationValueW, compressionModel);
     }
     else
     {
         Child1RotationValueX = baseline.Child1RotationValueX;
         Child1RotationValueY = baseline.Child1RotationValueY;
         Child1RotationValueZ = baseline.Child1RotationValueZ;
         Child1RotationValueW = baseline.Child1RotationValueW;
     }
     if ((changeMask0 & (1 << 6)) != 0)
     {
         Child1TranslationValueX = reader.ReadPackedIntDelta(baseline.Child1TranslationValueX, compressionModel);
         Child1TranslationValueY = reader.ReadPackedIntDelta(baseline.Child1TranslationValueY, compressionModel);
         Child1TranslationValueZ = reader.ReadPackedIntDelta(baseline.Child1TranslationValueZ, compressionModel);
     }
     else
     {
         Child1TranslationValueX = baseline.Child1TranslationValueX;
         Child1TranslationValueY = baseline.Child1TranslationValueY;
         Child1TranslationValueZ = baseline.Child1TranslationValueZ;
     }
 }
예제 #8
0
    public static unsafe int InvokeSerialize <TSerializer, TSnapshotData>(TSerializer serializer, int ghostType, ArchetypeChunk chunk, int startIndex, uint currentTick,
                                                                          Entity *currentSnapshotEntity, TSnapshotData *currentSnapshotData,
                                                                          GhostSystemStateComponent *ghosts, NativeArray <Entity> ghostEntities,
                                                                          NativeArray <int> baselinePerEntity, NativeList <SnapshotBaseline> availableBaselines,
                                                                          DataStreamWriter dataStream, NetworkCompressionModel compressionModel)
        where TSnapshotData : unmanaged, ISnapshotData <TSnapshotData>
        where TSerializer : struct, IGhostSerializer <TSnapshotData>
    {
        int ent;
        int sameBaselineCount = 0;

        for (ent = startIndex; ent < chunk.Count && dataStream.Length < TargetPacketSize; ++ent)
        {
            #if ENABLE_UNITY_COLLECTIONS_CHECKS
            if (ghosts[ent].ghostTypeIndex != ghostType)
            {
                // FIXME: what needs to happen to support this case? Should it be treated as a respawn?
                throw new InvalidOperationException("A ghost changed type, ghost must keep the same serializer type throughout their lifetime");
            }
            #endif

            int baseline0 = baselinePerEntity[ent * 3];
            int baseline1 = baselinePerEntity[ent * 3 + 1];
            int baseline2 = baselinePerEntity[ent * 3 + 2];
            if (sameBaselineCount == 0)
            {
                // Count how many entities will use the same baselines as this one, send baselines + count
                uint baselineTick0 = currentTick;
                uint baselineTick1 = currentTick;
                uint baselineTick2 = currentTick;
                if (baseline0 >= 0)
                {
                    baselineTick0 = availableBaselines[baseline0].tick;
                }
                if (baseline1 >= 0)
                {
                    baselineTick1 = availableBaselines[baseline1].tick;
                }
                if (baseline2 >= 0)
                {
                    baselineTick2 = availableBaselines[baseline2].tick;
                }
                for (sameBaselineCount = 1; ent + sameBaselineCount < chunk.Count; ++sameBaselineCount)
                {
                    if (baselinePerEntity[(ent + sameBaselineCount) * 3] != baseline0 ||
                        baselinePerEntity[(ent + sameBaselineCount) * 3 + 1] != baseline1 ||
                        baselinePerEntity[(ent + sameBaselineCount) * 3 + 2] != baseline2)
                    {
                        break;
                    }
                }

                uint baseDiff0 = currentTick - baselineTick0;
                uint baseDiff1 = currentTick - baselineTick1;
                uint baseDiff2 = currentTick - baselineTick2;
                dataStream.WritePackedUInt(baseDiff0, compressionModel);
                dataStream.WritePackedUInt(baseDiff1, compressionModel);
                dataStream.WritePackedUInt(baseDiff2, compressionModel);
                dataStream.WritePackedUInt((uint)sameBaselineCount, compressionModel);
            }

            --sameBaselineCount;
            TSnapshotData *baselineSnapshotData0 = null;
            if (baseline0 >= 0)
            {
                baselineSnapshotData0 = ((TSnapshotData *)availableBaselines[baseline0].snapshot) + ent;
            }
            TSnapshotData *baselineSnapshotData1 = null;
            TSnapshotData *baselineSnapshotData2 = null;
            if (baseline2 >= 0)
            {
                baselineSnapshotData1 = ((TSnapshotData *)availableBaselines[baseline1].snapshot) + ent;
                baselineSnapshotData2 = ((TSnapshotData *)availableBaselines[baseline2].snapshot) + ent;
            }


            dataStream.WritePackedUInt((uint)ghosts[ent].ghostId, compressionModel);

            TSnapshotData *snapshot;
            var            snapshotData = default(TSnapshotData);
            if (currentSnapshotData == null)
            {
                snapshot = &snapshotData;
            }
            else
            {
                snapshot = currentSnapshotData + ent;
            }
            serializer.CopyToSnapshot(chunk, ent, currentTick, ref *snapshot);
            var            baselineData = default(TSnapshotData);
            TSnapshotData *baseline     = &baselineData;
            if (baselineSnapshotData2 != null)
            {
                baselineData = *baselineSnapshotData0;
                baselineData.PredictDelta(currentTick, ref *baselineSnapshotData1, ref *baselineSnapshotData2);
            }
            else if (baselineSnapshotData0 != null)
            {
                baseline = baselineSnapshotData0;
            }

            snapshot->Serialize(ref *baseline, dataStream, compressionModel);

            if (currentSnapshotData != null)
            {
                currentSnapshotEntity[ent] = ghostEntities[ent];
            }
        }

        return(ent);
    }
예제 #9
0
 public void Serialize(int networkId, ref ArrowSnapshotData baseline, ref DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     changeMask0  = (PlayerBulletPlayerId != baseline.PlayerBulletPlayerId) ? 1u : 0;
     changeMask0 |= (RotationValueX != baseline.RotationValueX ||
                     RotationValueY != baseline.RotationValueY ||
                     RotationValueZ != baseline.RotationValueZ ||
                     RotationValueW != baseline.RotationValueW) ? (1u << 1) : 0;
     changeMask0 |= (TranslationValueX != baseline.TranslationValueX ||
                     TranslationValueY != baseline.TranslationValueY ||
                     TranslationValueZ != baseline.TranslationValueZ) ? (1u << 2) : 0;
     changeMask0 |= (Child0RotationValueX != baseline.Child0RotationValueX ||
                     Child0RotationValueY != baseline.Child0RotationValueY ||
                     Child0RotationValueZ != baseline.Child0RotationValueZ ||
                     Child0RotationValueW != baseline.Child0RotationValueW) ? (1u << 3) : 0;
     changeMask0 |= (Child0TranslationValueX != baseline.Child0TranslationValueX ||
                     Child0TranslationValueY != baseline.Child0TranslationValueY ||
                     Child0TranslationValueZ != baseline.Child0TranslationValueZ) ? (1u << 4) : 0;
     changeMask0 |= (Child1RotationValueX != baseline.Child1RotationValueX ||
                     Child1RotationValueY != baseline.Child1RotationValueY ||
                     Child1RotationValueZ != baseline.Child1RotationValueZ ||
                     Child1RotationValueW != baseline.Child1RotationValueW) ? (1u << 5) : 0;
     changeMask0 |= (Child1TranslationValueX != baseline.Child1TranslationValueX ||
                     Child1TranslationValueY != baseline.Child1TranslationValueY ||
                     Child1TranslationValueZ != baseline.Child1TranslationValueZ) ? (1u << 6) : 0;
     writer.WritePackedUIntDelta(changeMask0, baseline.changeMask0, compressionModel);
     if ((changeMask0 & (1 << 0)) != 0)
     {
         writer.WritePackedIntDelta(PlayerBulletPlayerId, baseline.PlayerBulletPlayerId, compressionModel);
     }
     if ((changeMask0 & (1 << 1)) != 0)
     {
         writer.WritePackedIntDelta(RotationValueX, baseline.RotationValueX, compressionModel);
         writer.WritePackedIntDelta(RotationValueY, baseline.RotationValueY, compressionModel);
         writer.WritePackedIntDelta(RotationValueZ, baseline.RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(RotationValueW, baseline.RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 2)) != 0)
     {
         writer.WritePackedIntDelta(TranslationValueX, baseline.TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(TranslationValueY, baseline.TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(TranslationValueZ, baseline.TranslationValueZ, compressionModel);
     }
     if ((changeMask0 & (1 << 3)) != 0)
     {
         writer.WritePackedIntDelta(Child0RotationValueX, baseline.Child0RotationValueX, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueY, baseline.Child0RotationValueY, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueZ, baseline.Child0RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(Child0RotationValueW, baseline.Child0RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 4)) != 0)
     {
         writer.WritePackedIntDelta(Child0TranslationValueX, baseline.Child0TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(Child0TranslationValueY, baseline.Child0TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(Child0TranslationValueZ, baseline.Child0TranslationValueZ, compressionModel);
     }
     if ((changeMask0 & (1 << 5)) != 0)
     {
         writer.WritePackedIntDelta(Child1RotationValueX, baseline.Child1RotationValueX, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueY, baseline.Child1RotationValueY, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueZ, baseline.Child1RotationValueZ, compressionModel);
         writer.WritePackedIntDelta(Child1RotationValueW, baseline.Child1RotationValueW, compressionModel);
     }
     if ((changeMask0 & (1 << 6)) != 0)
     {
         writer.WritePackedIntDelta(Child1TranslationValueX, baseline.Child1TranslationValueX, compressionModel);
         writer.WritePackedIntDelta(Child1TranslationValueY, baseline.Child1TranslationValueY, compressionModel);
         writer.WritePackedIntDelta(Child1TranslationValueZ, baseline.Child1TranslationValueZ, compressionModel);
     }
 }
 public void Serialize(int networkId, ref GhostSnapshotData baseline, ref DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     #region __GHOST_WRITE__
     if ((changeMask__GHOST_MASK_BATCH__ & (1 << __GHOST_MASK_INDEX__)) != 0)
     {
         writer.WritePackedFloatDelta(snapshot.__GHOST_FIELD_NAME__, baseline.__GHOST_FIELD_NAME__, compressionModel);
     }
     #endregion
 }
 public void Serialize(int networkId, ref __GHOST_NAME__SnapshotData baseline, DataStreamWriter writer, NetworkCompressionModel compressionModel)
 {
     #region __GHOST_CALCULATE_CHANGE_MASK__
     #endregion
     #region __GHOST_WRITE_CHANGE_MASK__
     writer.WritePackedUIntDelta(changeMask__GHOST_MASK_BATCH__, baseline.changeMask__GHOST_MASK_BATCH__, compressionModel);
     #endregion
     #region __GHOST_WRITE_IS_PREDICTED__
     bool isPredicted = Get__GHOST_OWNER_FIELD__() == networkId;
     writer.WritePackedUInt(isPredicted?1u:0, compressionModel);
     #endregion
     #region __GHOST_WRITE__
     #endregion
     #region __GHOST_BEGIN_WRITE_PREDICTED__
     if (isPredicted)
     {
         #endregion
         #region __GHOST_WRITE_PREDICTED__
         #endregion
         #region __GHOST_END_WRITE_PREDICTED__
     }
     #endregion
     #region __GHOST_BEGIN_WRITE_INTERPOLATED__
     if (!isPredicted)
     {
         #endregion
         #region __GHOST_WRITE_INTERPOLATED__
         #endregion
         #region __GHOST_END_WRITE_INTERPOLATED__
     }
     #endregion
 }
예제 #12
0
    public void Deserialize(uint tick, ref PilotSnapshotData baseline, ref DataStreamReader reader,
                            NetworkCompressionModel compressionModel)
    {
        this.tick   = tick;
        changeMask0 = reader.ReadPackedUIntDelta(baseline.changeMask0, compressionModel);
        bool isPredicted = reader.ReadPackedUInt(compressionModel) != 0;

        if ((changeMask0 & (1 << 0)) != 0)
        {
            PilotDataPlayerId = reader.ReadPackedIntDelta(baseline.PilotDataPlayerId, compressionModel);
        }
        else
        {
            PilotDataPlayerId = baseline.PilotDataPlayerId;
        }
        if ((changeMask0 & (1 << 5)) != 0)
        {
            RotationValueX = reader.ReadPackedIntDelta(baseline.RotationValueX, compressionModel);
            RotationValueY = reader.ReadPackedIntDelta(baseline.RotationValueY, compressionModel);
            RotationValueZ = reader.ReadPackedIntDelta(baseline.RotationValueZ, compressionModel);
            RotationValueW = reader.ReadPackedIntDelta(baseline.RotationValueW, compressionModel);
        }
        else
        {
            RotationValueX = baseline.RotationValueX;
            RotationValueY = baseline.RotationValueY;
            RotationValueZ = baseline.RotationValueZ;
            RotationValueW = baseline.RotationValueW;
        }
        if ((changeMask0 & (1 << 6)) != 0)
        {
            TranslationValueX = reader.ReadPackedIntDelta(baseline.TranslationValueX, compressionModel);
            TranslationValueY = reader.ReadPackedIntDelta(baseline.TranslationValueY, compressionModel);
            TranslationValueZ = reader.ReadPackedIntDelta(baseline.TranslationValueZ, compressionModel);
        }
        else
        {
            TranslationValueX = baseline.TranslationValueX;
            TranslationValueY = baseline.TranslationValueY;
            TranslationValueZ = baseline.TranslationValueZ;
        }
        if (isPredicted)
        {
            if ((changeMask0 & (1 << 1)) != 0)
            {
                PilotMovementSystemDatavelocityX = reader.ReadPackedIntDelta(baseline.PilotMovementSystemDatavelocityX, compressionModel);
                PilotMovementSystemDatavelocityY = reader.ReadPackedIntDelta(baseline.PilotMovementSystemDatavelocityY, compressionModel);
                PilotMovementSystemDatavelocityZ = reader.ReadPackedIntDelta(baseline.PilotMovementSystemDatavelocityZ, compressionModel);
            }
            else
            {
                PilotMovementSystemDatavelocityX = baseline.PilotMovementSystemDatavelocityX;
                PilotMovementSystemDatavelocityY = baseline.PilotMovementSystemDatavelocityY;
                PilotMovementSystemDatavelocityZ = baseline.PilotMovementSystemDatavelocityZ;
            }
            if ((changeMask0 & (1 << 2)) != 0)
            {
                PilotMovementSystemDataonGround = reader.ReadPackedUIntDelta(baseline.PilotMovementSystemDataonGround, compressionModel);
            }
            else
            {
                PilotMovementSystemDataonGround = baseline.PilotMovementSystemDataonGround;
            }
            if ((changeMask0 & (1 << 3)) != 0)
            {
                PilotMovementSystemDatajumpCooldown = reader.ReadPackedUIntDelta(baseline.PilotMovementSystemDatajumpCooldown, compressionModel);
            }
            else
            {
                PilotMovementSystemDatajumpCooldown = baseline.PilotMovementSystemDatajumpCooldown;
            }
            if ((changeMask0 & (1 << 4)) != 0)
            {
                PilotMovementSystemDatamovementMode = reader.ReadPackedIntDelta(baseline.PilotMovementSystemDatamovementMode, compressionModel);
            }
            else
            {
                PilotMovementSystemDatamovementMode = baseline.PilotMovementSystemDatamovementMode;
            }
        }
    }
예제 #13
0
    public void Serialize(int networkId, ref PilotSnapshotData baseline, ref DataStreamWriter writer, NetworkCompressionModel compressionModel)
    {
        changeMask0  = (PilotDataPlayerId != baseline.PilotDataPlayerId) ? 1u : 0;
        changeMask0 |= (PilotMovementSystemDatavelocityX != baseline.PilotMovementSystemDatavelocityX ||
                        PilotMovementSystemDatavelocityY != baseline.PilotMovementSystemDatavelocityY ||
                        PilotMovementSystemDatavelocityZ != baseline.PilotMovementSystemDatavelocityZ) ? (1u << 1) : 0;
        changeMask0 |= (PilotMovementSystemDataonGround != baseline.PilotMovementSystemDataonGround) ? (1u << 2) : 0;
        changeMask0 |= (PilotMovementSystemDatajumpCooldown != baseline.PilotMovementSystemDatajumpCooldown) ? (1u << 3) : 0;
        changeMask0 |= (PilotMovementSystemDatamovementMode != baseline.PilotMovementSystemDatamovementMode) ? (1u << 4) : 0;
        changeMask0 |= (RotationValueX != baseline.RotationValueX ||
                        RotationValueY != baseline.RotationValueY ||
                        RotationValueZ != baseline.RotationValueZ ||
                        RotationValueW != baseline.RotationValueW) ? (1u << 5) : 0;
        changeMask0 |= (TranslationValueX != baseline.TranslationValueX ||
                        TranslationValueY != baseline.TranslationValueY ||
                        TranslationValueZ != baseline.TranslationValueZ) ? (1u << 6) : 0;
        writer.WritePackedUIntDelta(changeMask0, baseline.changeMask0, compressionModel);
        bool isPredicted = GetPilotDataPlayerId() == networkId;

        writer.WritePackedUInt(isPredicted?1u:0, compressionModel);
        if ((changeMask0 & (1 << 0)) != 0)
        {
            writer.WritePackedIntDelta(PilotDataPlayerId, baseline.PilotDataPlayerId, compressionModel);
        }
        if ((changeMask0 & (1 << 5)) != 0)
        {
            writer.WritePackedIntDelta(RotationValueX, baseline.RotationValueX, compressionModel);
            writer.WritePackedIntDelta(RotationValueY, baseline.RotationValueY, compressionModel);
            writer.WritePackedIntDelta(RotationValueZ, baseline.RotationValueZ, compressionModel);
            writer.WritePackedIntDelta(RotationValueW, baseline.RotationValueW, compressionModel);
        }
        if ((changeMask0 & (1 << 6)) != 0)
        {
            writer.WritePackedIntDelta(TranslationValueX, baseline.TranslationValueX, compressionModel);
            writer.WritePackedIntDelta(TranslationValueY, baseline.TranslationValueY, compressionModel);
            writer.WritePackedIntDelta(TranslationValueZ, baseline.TranslationValueZ, compressionModel);
        }
        if (isPredicted)
        {
            if ((changeMask0 & (1 << 1)) != 0)
            {
                writer.WritePackedIntDelta(PilotMovementSystemDatavelocityX, baseline.PilotMovementSystemDatavelocityX, compressionModel);
                writer.WritePackedIntDelta(PilotMovementSystemDatavelocityY, baseline.PilotMovementSystemDatavelocityY, compressionModel);
                writer.WritePackedIntDelta(PilotMovementSystemDatavelocityZ, baseline.PilotMovementSystemDatavelocityZ, compressionModel);
            }
            if ((changeMask0 & (1 << 2)) != 0)
            {
                writer.WritePackedUIntDelta(PilotMovementSystemDataonGround, baseline.PilotMovementSystemDataonGround, compressionModel);
            }
            if ((changeMask0 & (1 << 3)) != 0)
            {
                writer.WritePackedUIntDelta(PilotMovementSystemDatajumpCooldown, baseline.PilotMovementSystemDatajumpCooldown, compressionModel);
            }
            if ((changeMask0 & (1 << 4)) != 0)
            {
                writer.WritePackedIntDelta(PilotMovementSystemDatamovementMode, baseline.PilotMovementSystemDatamovementMode, compressionModel);
            }
        }
    }