예제 #1
0
        public static bool[] GetBoolValues(this ConfigNode node, String name)
        {
            String[] values = node.GetValues(name);
            int      len    = values.Length;

            bool[] vals = new bool[len];
            for (int i = 0; i < len; i++)
            {
                vals[i] = ROEUtil.safeParseBool(values[i]);
            }
            return(vals);
        }
예제 #2
0
        private void initialize()
        {
            if (initialized)
            {
                return;
            }
            initialized = true;
            ConfigNode    node     = ROEUtil.parseConfigNode(configNodeData);
            AnimationData animData = new AnimationData(node.GetNode("ANIMATIONDATA"));

            animationModule = new AnimationModule(part, this, nameof(persistentState), null, nameof(deployEngineEvent), nameof(retractEngineEvent));
            animationModule.getSymmetryModule = m => ((ROEDeployableEngine)m).animationModule;
            animationModule.setupAnimations(animData, part.transform.FindRecursive("model"), 0);
            animationModule.onAnimStateChangeCallback = onAnimationStateChange;
        }
예제 #3
0
        public static Vector3 GetVector3(this ConfigNode node, String name, Vector3 defaultValue)
        {
            String value = node.GetValue(name);

            if (value == null)
            {
                return(defaultValue);
            }
            String[] vals = value.Split(',');
            if (vals.Length < 3)
            {
                MonoBehaviour.print("ERROR parsing values for Vector3 from input: " + value + ". found less than 3 values, cannot create Vector3");
                return(defaultValue);
            }
            return(new Vector3((float)ROEUtil.safeParseDouble(vals[0]), (float)ROEUtil.safeParseDouble(vals[1]), (float)ROEUtil.safeParseDouble(vals[2])));
        }
예제 #4
0
        public static float[] GetFloatValues(this ConfigNode node, String name, float[] defaults)
        {
            String baseVal = node.GetStringValue(name);

            if (!String.IsNullOrEmpty(baseVal))
            {
                String[] split = baseVal.Split(new char[] { ',' });
                float[]  vals  = new float[split.Length];
                for (int i = 0; i < split.Length; i++)
                {
                    vals[i] = ROEUtil.safeParseFloat(split[i]);
                }
                return(vals);
            }
            return(defaults);
        }
예제 #5
0
        //private static Rect presetWindowRect = new Rect(Screen.width - 900 - presetWidth - margin, 40, presetWidth + margin, presetHeight + margin);
        //private static bool presetWindowOpen = false;

        public static void openGUI(ROEEngineThrustCurveGUI srbModule, string preset, FloatCurve inputCurve)
        {
            module = srbModule;
            id     = module.GetInstanceID();
            ROELog.debug("ThrustCurveEditor-input curve: " + curve + "\n" + ROEUtil.printFloatCurve(curve));
            presetName = preset;
            setupCurveData(inputCurve);
            texture = new Texture2D(graphWidth, graphHeight);
            updateGraphTexture();
            loadPresets();
            if (activeGUI == null)
            {
                activeGUI = srbModule.gameObject.AddComponent <ThrustCurveEditorGUI>();
                ROELog.debug("ROEngines - Created new gui object: " + activeGUI);
            }
        }
예제 #6
0
        private void initialize()
        {
            constraints.Clear();
            ConfigNode node = ROEUtil.parseConfigNode(configNodeData);

            ConfigNode[] lookConstraintNodes = node.GetNodes("LOOK_CONST");
            foreach (ConfigNode lcn in lookConstraintNodes)
            {
                loadLookConstraint(lcn);
            }

            ConfigNode[] lockedConstraintNodes = node.GetNodes("LOCKED_CONST");
            foreach (ConfigNode lcn in lockedConstraintNodes)
            {
                loadLockedConstraint(lcn);
            }
            updateConstraints();
        }
예제 #7
0
        public static FloatCurve GetFloatCurve(this ConfigNode node, String name, FloatCurve defaultValue = null)
        {
            FloatCurve curve = new FloatCurve();

            if (node.HasNode(name))
            {
                ConfigNode curveNode = node.GetNode(name);
                String[]   values    = curveNode.GetValues("key");
                int        len       = values.Length;
                String[]   splitValue;
                float      a, b, c, d;
                for (int i = 0; i < len; i++)
                {
                    splitValue = Regex.Replace(values[i], @"\s+", " ").Split(' ');
                    if (splitValue.Length > 2)
                    {
                        a = ROEUtil.safeParseFloat(splitValue[0]);
                        b = ROEUtil.safeParseFloat(splitValue[1]);
                        c = ROEUtil.safeParseFloat(splitValue[2]);
                        d = ROEUtil.safeParseFloat(splitValue[3]);
                        curve.Add(a, b, c, d);
                    }
                    else
                    {
                        a = ROEUtil.safeParseFloat(splitValue[0]);
                        b = ROEUtil.safeParseFloat(splitValue[1]);
                        curve.Add(a, b);
                    }
                }
            }
            else if (defaultValue != null)
            {
                foreach (Keyframe f in defaultValue.Curve.keys)
                {
                    curve.Add(f.time, f.value, f.inTangent, f.outTangent);
                }
            }
            else
            {
                curve.Add(0, 0);
                curve.Add(1, 1);
            }
            return(curve);
        }