private void Awake()
        {
            PropertyInfo pipelineProperty = typeof(KSPUpgradePipeline).GetProperty("Pipeline",
                                                                                   BindingFlags.Static |
                                                                                   BindingFlags.NonPublic |
                                                                                   BindingFlags.Public |
                                                                                   BindingFlags.IgnoreCase);

            if (!(pipelineProperty?.GetValue(null) is SaveUpgradePipeline.SaveUpgradePipeline pipeline))
            {
                FARLogger.Error("Could not find SaveUpgradePipeline");
                return;
            }

            FARLogger.Info("Removing ModuleControlSurface upgrade script from SaveUpgradePipeline");
            pipeline.upgradeScripts.RemoveAll(script => script.Name.Contains("ModuleControlSurface"));
        }
        private void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            Instance = this;

            FARLogger.Info("Vehicle Voxel Setup started");
            FARAeroSection.GenerateCrossFlowDragCurve();
            VehicleVoxel.VoxelSetup();
            PhysicsGlobals.DragCubeMultiplier = 0;
            FARLogger.Info("Vehicle Voxel Setup complete");

            newGame = false;
        }
        void LoadAssets(AssetLoader.Loader loader)
        {
            for (int i = 0; i < loader.definitions.Length; i++)
            {
                UnityEngine.Object o = loader.objects[i];
                if (o == null)
                {
                    continue;
                }

                Type oType = o.GetType();

                // FARLogger.Info("Object " + i + " in bundle: " + o);
                if (oType == typeof(Material))
                {
                    FARLogger.Info("Adding material " + loader.definitions[i].name + " to dictionary");
                }
                materialDict.Add(loader.definitions[i].name, o as Material);
            }
        }
        void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }
            instance = this;

            //if (newGame)
            //    PopupDialog.SpawnPopupDialog("Ferram Aerospace Research", "Welcome to KSP with FAR!\n\r\n\rThings will be much harder from here on out; the FAR button in the top-right corner will bring you to difficulty settings if you ever decide to change them.  Have fun!", "OK", false, HighLogic.Skin);

            FARLogger.Info("Vehicle Voxel Setup started");
            FerramAerospaceResearch.FARAeroComponents.FARAeroSection.GenerateCrossFlowDragCurve();
            VehicleVoxel.VoxelSetup();
            PhysicsGlobals.DragCubeMultiplier = 0;
            FARLogger.Info("Vehicle Voxel Setup complete");

            //GameEvents.onGameStateSave.Add(OnSave);
            newGame = false;
        }
 // ReSharper disable once MemberCanBeMadeStatic.Local -> static does not work with GameEvents
 private void OnSceneChange(GameEvents.FromToAction <GameScenes, GameScenes> fromToScenes)
 {
     FARLogger.Info("check scene");
     if (fromToScenes.to == GameScenes.SPACECENTER)
     {
         if (!FARDebugValues.useBlizzyToolbar)
         {
             return;
         }
         if (FARDebugButtonBlizzy != null)
         {
             return;
         }
         FARDebugButtonBlizzy             = ToolbarManager.Instance.add("FerramAerospaceResearch", "FARDebugButtonBlizzy");
         FARDebugButtonBlizzy.TexturePath = "FerramAerospaceResearch/Textures/icon_button_blizzy";
         FARDebugButtonBlizzy.ToolTip     = "FAR Debug Options";
         FARDebugButtonBlizzy.OnClick    += e => debugMenu = !debugMenu;
     }
     else
     {
         FARDebugButtonBlizzy?.Destroy();
     }
 }
        void Start()
        {
            materialDict = new Dictionary <string, Material>();
            shaderDict   = new Dictionary <string, Shader>();

            /* FARLogger.Info("Asset bundles");
             * FARLogger.Info("" + AssetLoader.BundleDefinitions.Count);
             * foreach (BundleDefinition b in AssetLoader.BundleDefinitions)
             * {
             *  FARLogger.Info("" + b.name + " " + b.createdTime + " " + b.path + " " + b.info + " " + b.urlName);
             * }
             * FARLogger.Info("" + AssetLoader.AssetDefinitions.Count);
             * foreach (AssetDefinition a in AssetLoader.AssetDefinitions)
             * {
             *  FARLogger.Info("" + a.name + " " + a.type + " " + a.path);
             * }*/

            // AssetLoader.LoadAssets(LoadAssets,
            // AssetLoader.GetAssetDefinitionWithName("FerramAerospaceResearch/Shaders/farshaders",
            // "FARCrossSectionGraph"));
            AssetLoader.LoadAssets(LoadAssets, AssetLoader.GetAssetDefinitionsWithType("FerramAerospaceResearch/Assets/farassets", typeof(Material)));
            AssetLoader.LoadAssets(LoadAssets, AssetLoader.GetAssetDefinitionsWithType("FerramAerospaceResearch/Assets/farassets", typeof(Shader)));
            FARLogger.Info("Finished loading FAR Assets.");
        }
            protected override void SetBundlePath(string name)
            {
                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (Application.platform)
                {
                case RuntimePlatform.LinuxPlayer:
                    FARLogger.Info("Loading shaders from Linux bundle");
                    name += "_linux";
                    break;

                case RuntimePlatform.WindowsPlayer:
                    if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL", StringComparison.Ordinal))
                    {
                        FARLogger.Info("Loading shaders from Linux/OpenGL bundle");
                        name += "_linux";     //For OpenGL users on Windows we load the Linux shaders to fix OpenGL issues
                    }
                    else
                    {
                        FARLogger.Info("Loading shaders from Windows bundle");
                        name += "_windows";
                    }
                    break;

                case RuntimePlatform.OSXPlayer:
                    FARLogger.Info("Loading shaders from MacOSX bundle");
                    name += "_macosx";
                    break;

                default:
                    // Should never reach this
                    FARLogger.Error(string.Format("Invalid runtime platform {0}", Application.platform));
                    break;
                }

                base.SetBundlePath(name);
            }
Example #8
0
        public override void OnLoad(ConfigNode node)
        {
            Instance = this;
            GeneratePresets();
            int index = 4;

            if (node.HasValue("newGame"))
            {
                newGame = bool.Parse(node.GetValue("newGame"));
            }

            if (node.HasValue("index"))
            {
                index = int.Parse(node.GetValue("index"));
            }

            dropdown = new GUIDropDown <FARDifficultyAndExactnessSettings>(presetNames.ToArray(),
                                                                           presets.ToArray(),
                                                                           index < 0 ? 2 : index);
            voxelSettings = new FARVoxelSettings();

            if (node.HasValue("numVoxelsControllableVessel"))
            {
                voxelSettings.numVoxelsControllableVessel = int.Parse(node.GetValue("numVoxelsControllableVessel"));
            }
            if (node.HasValue("numVoxelsDebrisVessel"))
            {
                voxelSettings.numVoxelsDebrisVessel = int.Parse(node.GetValue("numVoxelsDebrisVessel"));
            }
            if (node.HasValue("minPhysTicksPerUpdate"))
            {
                voxelSettings.minPhysTicksPerUpdate = int.Parse(node.GetValue("minPhysTicksPerUpdate"));
            }
            if (node.HasValue("useHigherResVoxelPoints"))
            {
                voxelSettings.useHigherResVoxelPoints = bool.Parse(node.GetValue("useHigherResVoxelPoints"));
            }
            if (node.HasValue("use32BitIndices"))
            {
                DebugVoxelMesh.Use32BitIndices = bool.Parse(node.GetValue("use32BitIndices"));
            }

            if (index == -1)
            {
                settings = new FARDifficultyAndExactnessSettings(index);

                if (node.HasValue("fractionTransonicDrag"))
                {
                    settings.fractionTransonicDrag = double.Parse(node.GetValue("fractionTransonicDrag"));
                }
                if (node.HasValue("gaussianVehicleLengthFractionForSmoothing"))
                {
                    settings.gaussianVehicleLengthFractionForSmoothing =
                        double.Parse(node.GetValue("gaussianVehicleLengthFractionForSmoothing"));
                }

                if (node.HasValue("numAreaSmoothingPasses"))
                {
                    settings.numAreaSmoothingPasses = int.Parse(node.GetValue("numAreaSmoothingPasses"));
                }
                if (node.HasValue("numDerivSmoothingPasses"))
                {
                    settings.numDerivSmoothingPasses = int.Parse(node.GetValue("numDerivSmoothingPasses"));
                }


                customSettings = settings;
            }
            else
            {
                settings       = presets[index];
                customSettings = new FARDifficultyAndExactnessSettings(-1);
            }

            currentIndex = index;


            FARLogger.Info("Loading FAR Data");
            flightGUISettings = new List <ConfigNode>();
            if (node.HasNode("FlightGUISettings"))
            {
                foreach (ConfigNode flightGUINode in node.GetNode("FlightGUISettings").nodes)
                {
                    flightGUISettings.Add(flightGUINode);
                }
            }

            FARDebugAndSettings.LoadConfigs(node);
        }
 public double BrentSolve(string dbgmsg)
 {
     FARLogger.Info("MirroredFunction (mirrored= " + mirror + ") reverting to BrentsMethod: " + dbgmsg);
     return(FARMathUtil.BrentsMethod(this.F, leftedge, rightedge, tol_brent, iterlim));
 }