Ejemplo n.º 1
0
        protected Link(byte[] data, int offset, bool isTimed)
        {
            IsTimed = isTimed;

            TargetAssetID = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 4));

            if (isTimed)
            {
                Time         = ConverterFunctions.Switch(BitConverter.ToSingle(data, offset));
                _eventSendID = (ushort)ConverterFunctions.Switch(BitConverter.ToInt32(data, offset + 8));

                arguments = new byte[16];
                for (int i = 0; i < 16; i++)
                {
                    arguments[i] = data[offset + 12 + i];
                }

                ArgumentAssetID    = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 0x1C));
                SourceCheckAssetID = 0;
            }
            else
            {
                _eventReceiveID = Switch(BitConverter.ToUInt16(data, offset));
                _eventSendID    = Switch(BitConverter.ToUInt16(data, offset + 2));

                arguments = new byte[16];
                for (int i = 0; i < 16; i++)
                {
                    arguments[i] = data[offset + 8 + i];
                }

                ArgumentAssetID    = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 0x18));
                SourceCheckAssetID = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 0x1C));
            }
        }
Ejemplo n.º 2
0
        public byte[] ToByteArray()
        {
            List <byte> data = new List <byte>();

            if (IsTimed)
            {
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(Time)));
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(TargetAssetID)));
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch((int)_eventSendID)));
                data.AddRange(arguments);
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(ArgumentAssetID)));
            }
            else
            {
                data.AddRange(BitConverter.GetBytes(Switch(_eventReceiveID)));
                data.AddRange(BitConverter.GetBytes(Switch(_eventSendID)));
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(TargetAssetID)));
                data.AddRange(arguments);
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(ArgumentAssetID)));
                data.AddRange(BitConverter.GetBytes(ConverterFunctions.Switch(SourceCheckAssetID)));
            }

            return(data.ToArray());
        }