Exemplo n.º 1
0
        static Offset <FConfigurable> Serialise(
            FlatBufferBuilder b,
            IConfigurable configurable,
            string identifier)
        {
            var n = b.CreateString(identifier);

            int          observation_offset;
            FObservation observation_type;

            if (configurable is IHasQuaternionTransform)
            {
                observation_offset = Serialise(b, (IHasQuaternionTransform)configurable).Value;
                observation_type   = FObservation.FQTObs;
            }
            else if (configurable is PositionConfigurable)
            {
                observation_offset = Serialise(b, (PositionConfigurable)configurable).Value;
                observation_type   = FObservation.FTriple;
            }
            else if (configurable is IHasSingle)
            {
                observation_offset = Serialise(b, (IHasSingle)configurable).Value;
                observation_type   = FObservation.FSingle;
                // ReSharper disable once SuspiciousTypeConversion.Global
            }
            else if (configurable is IHasDouble)
            {
                // ReSharper disable once SuspiciousTypeConversion.Global
                observation_offset = Serialise(b, (IHasDouble)configurable).Value;
                observation_type   = FObservation.FDouble;
            }
            else if (configurable is EulerTransformConfigurable)
            {
                observation_offset = Serialise(b, (IHasEulerTransform)configurable).Value;
                observation_type   = FObservation.FETObs;
            }
            else
            {
                FConfigurable.StartFConfigurable(b);
                FConfigurable.AddConfigurableName(b, n);
                return(FConfigurable.EndFConfigurable(b));
            }

            FConfigurable.StartFConfigurable(b);
            FConfigurable.AddConfigurableName(b, n);
            FConfigurable.AddConfigurableValue(b, observation_offset);
            FConfigurable.AddConfigurableValueType(b, observation_type);
            FConfigurable.AddConfigurableRange(b,
                                               FRange.CreateFRange(b,
                                                                   0,
                                                                   0,
                                                                   0,
                                                                   false));
            return(FConfigurable.EndFConfigurable(b));
        }
Exemplo n.º 2
0
        static Offset <FConfigurable> build_configurable(
            FlatBufferBuilder b,
            ConfigurableGameObject configurable,
            string identifier)
        {
            var n = b.CreateString(identifier);

            var observation_offset = 0;
            var observation_type   = FObservation.NONE;

            if (configurable is IHasQuaternionTransform)
            {
                observation_offset = build_quaternion_transform(b, (IHasQuaternionTransform)configurable).Value;
                observation_type   = FObservation.FQT;
            }
            else if (configurable is PositionConfigurable)
            {
                observation_offset = build_position(b, (PositionConfigurable)configurable).Value;
                observation_type   = FObservation.FTriple;
            }
            else if (configurable is IHasSingle)
            {
                observation_offset = build_single(b, (IHasSingle)configurable).Value;
                observation_type   = FObservation.FSingle;
            }
            else if (configurable is EulerTransformConfigurable)
            {
                observation_offset = build_euler_transform(b, (IHasEulerTransform)configurable).Value;
                observation_type   = FObservation.FET;
            }
            else
            {
                FConfigurable.StartFConfigurable(b);
                FConfigurable.AddConfigurableName(b, n);
                return(FConfigurable.EndFConfigurable(b));
            }

            FConfigurable.StartFConfigurable(b);
            FConfigurable.AddConfigurableName(b, n);
            FConfigurable.AddObservation(b, observation_offset);
            FConfigurable.AddObservationType(b, observation_type);
            return(FConfigurable.EndFConfigurable(b));
        }