Ejemplo n.º 1
0
        public static void Serialize(Quaternion data, float max, float min, float ratio, int sendTimes, bool DoCompress,
                                     Core.Utils.MyBinaryWriter writer, Quaternion last = default(Quaternion), bool weiteAll = false)
        {
            if (!DoCompress)
            {
                Serialize(data, writer, last, weiteAll);
                return;
            }

            float[] list     = { data.x, data.y, data.z, data.w };
            float[] lastlist = { last.x, last.y, last.z, last.w };
            float   biggest  = data.x;
            int     Site     = 0;

            for (int i = 1; i < list.Length; i++)
            {
                if (Mathf.Abs(list[i]) > Mathf.Abs(biggest))
                {
                    biggest = list[i];
                    Site    = i;
                }
            }

            float sign = list[Site] > 0 ? 1 : -1;

            _byteSerializer.Write((Byte)Site, writer);
            for (int i = 0; i < list.Length; i++)
            {
                if (i != Site)
                {
                    Serialize(list[i] * sign, max, min, ratio, sendTimes, DoCompress, writer, lastlist[i] * sign,
                              weiteAll);
                }
            }
        }
Ejemplo n.º 2
0
 private static void SendCompressedData(int sendTime, uint toSend, Core.Utils.MyBinaryWriter writer)
 {
     while (sendTime > 0)
     {
         _byteSerializer.Write((Byte)(toSend >> ((sendTime - 1) * 8)), writer);
         sendTime--;
     }
 }
Ejemplo n.º 3
0
 public void Write(string data, Core.Utils.MyBinaryWriter writer)
 {
     if (data == null)
     {
         Logger.InfoFormat("StringSerializer String is Null");
         data = string.Empty;
     }
     writer.Write(data);
 }
Ejemplo n.º 4
0
        public static void Serialize(Vector3 data, float max, float min, float ratio, int sendTimes, bool DoCompress,
                                     Core.Utils.MyBinaryWriter writer, Vector3 last = default(Vector3), bool weiteAll = false)
        {
            if (!DoCompress)
            {
                Serialize(data, writer, last, weiteAll);
                return;
            }

            Serialize(data.x, max, min, ratio, sendTimes, DoCompress, writer, last.x, weiteAll);
            Serialize(data.y, max, min, ratio, sendTimes, DoCompress, writer, last.y, weiteAll);
            Serialize(data.z, max, min, ratio, sendTimes, DoCompress, writer, last.z, weiteAll);
        }
Ejemplo n.º 5
0
 public static void Serialize(List <int> list, Core.Utils.MyBinaryWriter writer, List <int> lastList = null,
                              bool writeAll = false)
 {
     if (list == null || list.Count == 0)
     {
         writer.Write((short)0);
     }
     else
     {
         writer.Write((short)list.Count);
         foreach (var i in list)
         {
             writer.Write(i);
         }
     }
 }
Ejemplo n.º 6
0
        public static void Serialize(int data, float max, float min, float ratio, int sendTimes, bool DoCompress,
                                     Core.Utils.MyBinaryWriter writer, int last = default(int), bool weiteAll = false)
        {
            if (!DoCompress)
            {
                Serialize(data, writer, last, weiteAll);
                return;
            }

            if (data > max || data < min)
            {
                _serializeLogger.DebugFormat("Serialize fault : out of range!  data {0},max {1},min {2}", data, max,
                                             min);
            }

            uint toSend = (uint)(data - min);

            SendCompressedData(sendTimes, toSend, writer);
        }
Ejemplo n.º 7
0
        public static void Serialize <T>(T[] currArr, Core.Utils.MyBinaryWriter writer, T[] lastArr = null,
                                         bool writeAll = false) where T : class, IPatchClass <T>, new()
        {
            BitArrayWrapper bitArray  = GetDiffBitArray(lastArr, currArr, writeAll);
            var             count     = currArr == null ? 0 : currArr.Length;
            var             lastCount = lastArr == null ? 0 : lastArr.Length;

            writer.Write(bitArray);

            for (int i = 0; i < count; i++)
            {
                if (bitArray[i] == false)
                {
                    continue;
                }
                var last = i >= lastCount || writeAll ? default(T) : lastArr[i];
                Serialize(currArr[i], last, writer);
            }
            bitArray.ReleaseReference();
        }
Ejemplo n.º 8
0
        public static void Serialize <T>(List <T> list, Core.Utils.MyBinaryWriter writer, List <T> lastList = null,
                                         bool writeAll = false) where T : IPatchClass <T>, new()
        {
            BitArrayWrapper bitArray  = GetDiffBitArray(lastList, list, writeAll);
            var             count     = list == null ? 0 : list.Count;
            var             lastCount = lastList == null ? 0 : lastList.Count;

            writer.Write(bitArray);

            for (int i = 0; i < count; i++)
            {
                if (bitArray[i] == false)
                {
                    continue;
                }
                var last = i >= lastCount || writeAll ? default(T) : lastList[i];
                PatchPropertySerializer.Write(list[i], last, writer);
            }

            bitArray.ReleaseReference();
        }
Ejemplo n.º 9
0
 public static void Serialize(WeaponBagContainer data, Core.Utils.MyBinaryWriter writer, WeaponBagContainer last = null,
                              bool weiteAll = false)
 {
     _weaponBagSerializer.Write(data, writer);
 }
Ejemplo n.º 10
0
 public static void Serialize(PlayerEvents data, Core.Utils.MyBinaryWriter writer, PlayerEvents last = null,
                              bool weiteAll = false)
 {
     _eventsSerializer.Write(data, writer);
 }
Ejemplo n.º 11
0
 public static void Serialize(EntityKey data, Core.Utils.MyBinaryWriter writer,
                              EntityKey last = default(EntityKey), bool weiteAll = false)
 {
     _entityKeySerializer.Write(data, writer);
 }
Ejemplo n.º 12
0
 public static void Serialize(UInt16 data, Core.Utils.MyBinaryWriter writer, ushort last = default(ushort),
                              bool weiteAll = false)
 {
     _uint16Serializer.Write(data, writer);
 }
Ejemplo n.º 13
0
 public static void Serialize(uint data, Core.Utils.MyBinaryWriter writer, uint last = default(uint),
                              bool weiteAll = false)
 {
     _uintSerializer.Write(data, writer);
 }
Ejemplo n.º 14
0
 public static void Serialize(Quaternion data, Core.Utils.MyBinaryWriter writer,
                              Quaternion last = default(Quaternion), bool weiteAll = false)
 {
     _quaternionSerializer.Write(data, writer);
 }
Ejemplo n.º 15
0
 public static void Serialize(Vector3 data, Core.Utils.MyBinaryWriter writer, Vector3 last = default(Vector3),
                              bool weiteAll = false)
 {
     _vector3Serializer.Write(data, writer);
 }
Ejemplo n.º 16
0
 public static void Serialize(bool data, Core.Utils.MyBinaryWriter writer, bool last = default(bool),
                              bool weiteAll = false)
 {
     _boolSerializer.Write(data, writer);
 }
Ejemplo n.º 17
0
 public static void Serialize(double data, Core.Utils.MyBinaryWriter writer, double last = default(double),
                              bool weiteAll = false)
 {
     _doubleSerializer.Write(data, writer);
 }
Ejemplo n.º 18
0
 public static void Serialize(string data, Core.Utils.MyBinaryWriter writer, string last = default(string),
                              bool weiteAll = false)
 {
     _stringSerializer.Write(data, writer);
 }
Ejemplo n.º 19
0
 public static void Serialize(float data, Core.Utils.MyBinaryWriter writer, float last = default(float),
                              bool weiteAll = false)
 {
     _floatSerializer.Write(data, writer);
 }
Ejemplo n.º 20
0
 public void Write(Vector3 data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data.x);
     writer.Write(data.y);
     writer.Write(data.z);
 }
Ejemplo n.º 21
0
 public void Write(InterruptData data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data.cmdType);
     writer.Write(data.hasValue);
     writer.Write(data.state);
 }
Ejemplo n.º 22
0
 public static void Serialize(StateInterCommands data, Core.Utils.MyBinaryWriter writer,
                              StateInterCommands last = default(StateInterCommands), bool weiteAll = false)
 {
     data.Write(writer);
 }
Ejemplo n.º 23
0
 public static void Serialize(UnityAnimationEventCommands data, Core.Utils.MyBinaryWriter writer,
                              UnityAnimationEventCommands last = default(UnityAnimationEventCommands), bool weiteAll = false)
 {
     data.Write(writer);
 }
Ejemplo n.º 24
0
 public void Write(uint data, Core.Utils.MyBinaryWriter writer)
 {
     writer.Write(data);
 }
Ejemplo n.º 25
0
 public static void Serialize(short data, Core.Utils.MyBinaryWriter writer, short last = default(short),
                              bool weiteAll = false)
 {
     _shortSerializer.Write(data, writer);
 }