Ejemplo n.º 1
0
        private static GenericCommandRequest GenericCommandRequestFromObjects(string commandName, object[] args)
        {
            var(paramInt, paramFloat, paramBool, paramString, paramEntity) = TypeArrays.ExtractTypedArraysFromObjects(args);

            var genericCommandRequest = new GenericCommandRequest
            {
                name = String.IsNullOrEmpty(commandName) ? "" : commandName,

                paramInt1 = paramInt[0],
                paramInt2 = paramInt[1],
                paramInt3 = paramInt[2],
                paramInt4 = paramInt[3],

                paramFloat1 = paramFloat[0],
                paramFloat2 = paramFloat[1],
                paramFloat3 = paramFloat[2],
                paramFloat4 = paramFloat[3],

                paramBool1 = paramBool[0],
                paramBool2 = paramBool[1],
                paramBool3 = paramBool[2],
                paramBool4 = paramBool[3],

                paramEntity1 = paramEntity[0],
                paramEntity2 = paramEntity[1],
                paramEntity3 = paramEntity[2],
                paramEntity4 = paramEntity[3],

                paramString = String.IsNullOrEmpty(paramString[0]) ? "" : paramString[0],
            };

            return(genericCommandRequest);
        }
        public void GenericCommandRequest(IOutBitStream bitstream, GenericCommandRequest data)
        {
            var converted_name = coherenceToUnityConverters.FromUnityFixedString64(data.name);

            bitstream.WriteShortString(converted_name);
            bitstream.WriteIntegerRange(data.paramInt1, 15, -9999);
            bitstream.WriteIntegerRange(data.paramInt2, 15, -9999);
            bitstream.WriteIntegerRange(data.paramInt3, 15, -9999);
            bitstream.WriteIntegerRange(data.paramInt4, 15, -9999);
            var converted_paramFloat1 = coherenceToUnityConverters.FromUnityfloat(data.paramFloat1);

            bitstream.WriteFixedPoint(converted_paramFloat1, 24, 2400);
            var converted_paramFloat2 = coherenceToUnityConverters.FromUnityfloat(data.paramFloat2);

            bitstream.WriteFixedPoint(converted_paramFloat2, 24, 2400);
            var converted_paramFloat3 = coherenceToUnityConverters.FromUnityfloat(data.paramFloat3);

            bitstream.WriteFixedPoint(converted_paramFloat3, 24, 2400);
            var converted_paramFloat4 = coherenceToUnityConverters.FromUnityfloat(data.paramFloat4);

            bitstream.WriteFixedPoint(converted_paramFloat4, 24, 2400);
            bitstream.WriteBool(data.paramBool1);
            bitstream.WriteBool(data.paramBool2);
            bitstream.WriteBool(data.paramBool3);
            bitstream.WriteBool(data.paramBool4);
            bitstream.WriteEntity(data.paramEntity1);
            bitstream.WriteEntity(data.paramEntity2);
            bitstream.WriteEntity(data.paramEntity3);
            bitstream.WriteEntity(data.paramEntity4);
            var converted_paramString = coherenceToUnityConverters.FromUnityFixedString64(data.paramString);

            bitstream.WriteShortString(converted_paramString);
        }