Exemplo n.º 1
0
        private void Start()
        {
            destroyed = false;

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            //RebuildAllMeshData();
            SetupIGeometryUpdaters();
            SetupICrossSectionAdjusters();
            GetAnimations();
        }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     this.part.mass = this.totalMass;
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
 }
        public void OnActionExecuting(ActionExecutingContext context)
        {
            if (!context.HttpContext.Request.Headers.TryGetValue(VersionHeaderName, out StringValues valueString))
            {
                ProcessInvalidVersion(context, $"Missing header {VersionHeaderName}");
                return;
            }

            if (!ClientVersion.TryParse(valueString, out ClientVersion version))
            {
                ProcessInvalidVersion(context, $"Invalid value of header {VersionHeaderName}");
                return;
            }

            if (!CompatibilityChecker.IsCompatibleWith(CompatibilitySet.Network, context.HttpContext.Connection.RemoteIpAddress.ToString(), version))
            {
                ProcessInvalidVersion(context, $"Server is incompatible with version defined in header {VersionHeaderName}");
                return;
            }

            // validate if this is not request from myself
            if (!context.HttpContext.Request.Headers.TryGetValue(InstanceHeaderName, out valueString))
            {
                ProcessInvalidVersion(context, $"Missing header {InstanceHeaderName}");
                return;
            }

            if (!Hash.TryParse(valueString, out Hash hash))
            {
                ProcessInvalidVersion(context, $"Invalid value of header {InstanceHeaderName}");
                return;
            }

            // validate input type header
            if (!context.HttpContext.Request.Headers.TryGetValue(TypeHeaderName, out StringValues _))
            {
                ProcessInvalidVersion(context, $"Missing header {TypeHeaderName}");
                return;
            }

            var controller = (IHttpApiController)context.Controller;

            controller.RemoteIpAddress = context.HttpContext.Connection.RemoteIpAddress;
            controller.PeerId          = hash;
            controller.IsLoopback      = hash.Equals(InstanceHash.Hash);
        }
Exemplo n.º 4
0
        public override void OnAwake()
        {
            enabled = false;
            if (!CompatibilityChecker.IsAllCompatible())
            {
                compatible = false;
                Events["HideUI"].active = false;
                Events["ShowUI"].active = false;
                return;
            }

            PartMessageService.Register(this);
            this.RegisterOnUpdateEditor(OnUpdateEditor);

            // Initialize utilization from the settings file
            utilization = MFSSettings.partUtilizationDefault;
        }
Exemplo n.º 5
0
        public bool InstallCheckerGetKop()
        {
            string KSPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "readme.txt");                                     //Locate KSP directory readme
            string KOPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "GameData/Kopernicus/Plugins/Kopernicus.version"); //Locate kopernicus readme if it exists

            DoLogThingsForMe("Detected KSP validation path as " + KSPpath);
            DoLogThingsForMe("Detected Kopernicus validation path as " + KOPpath);
            bool x = CompatibilityChecker.IsCompatible();

            if (x is true)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        private void Awake()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                Destroy(this);
                return;
            }

            if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
            {
                return;
            }

            if (FlightGlobals.GetHomeBody()?.atmosphericAmbientColor != null)
            {
                RenderSettings.ambientLight = FlightGlobals.GetHomeBody().atmosphericAmbientColor;
            }
        }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     if (HighLogic.LoadedScene == GameScenes.LOADING || !PartLoader.Instance.IsReady() || part.partInfo == null)
     {
         if (deployAltitude <= 500)
         {
             deployAltitude += 200;
         }
     }
     else
     {
         Part prefab = part.partInfo.partPrefab;
         massDelta = prefab == null ? 0 : TotalMass - prefab.mass;
     }
 }
Exemplo n.º 8
0
        private void Start()
        {
            if (!CompatibilityChecker.IsCompatible())
            {
                Destroy(this);
                return;
            }
            DontDestroyOnLoad(gameObject);

            if (LoadingScreen.Instance == null)
            {
                Debug.Log("[Kopernicus] LoadingScreen instance not found! Aborting Mesh preloading.");
                return;
            }

            List <LoadingSystem> list = LoadingScreen.Instance.loaders;

            list?.Insert(list.FindIndex(m => m is GameDatabase) + 1, gameObject.AddComponent <MeshPreloader>());
        }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
     else
     {
         Part prefab = this.part.partInfo.partPrefab;
         this.massDelta = prefab == null ? 0 : this.totalMass - prefab.mass;
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     if (!CompatibilityChecker.IsAllCompatible())
     {
         return;
     }
     this.part.mass = this.totalMass;
     if (HighLogic.LoadedScene == GameScenes.LOADING)
     {
         PartModule parachute = this.part.Modules["ModuleParachute"];
         if (parachute != null)
         {
             this.part.RemoveModule(parachute);
         }
         if (this.deployAltitude <= 500)
         {
             this.deployAltitude += 200;
         }
     }
 }
Exemplo n.º 11
0
        public void IsCultureInsensitive()
        {
            var archive             = Substitute.For <ISketchArchive>();
            var appVerion           = 3.14;
            var version             = CompatibilityChecker.SketchCompatibilityVersion;
            var compatibiltyVersion = version;

            var json = GenerateMetaJson(appVerion, compatibiltyVersion, version);

            using (var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json)))
            {
                archive.OpenFile("meta.json")
                .Returns(jsonStream);

                var log = new MessageListLogger();

                Thread.CurrentThread.CurrentCulture = new CultureInfo("nb-NO");
                CompatibilityChecker.Check("dummy.sketch", archive, log);
            }
        }
Exemplo n.º 12
0
        public override void OnLoad(ConfigNode node)
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                return;
            }
            this.part.mass = this.totalMass;
            this.massDelta = 0f;

            if ((object)(this.part.partInfo) != null && (object)(this.part.partInfo.partPrefab) != null)
            {
                this.massDelta = this.part.mass - this.part.partInfo.partPrefab.mass;
            }
            if (HighLogic.LoadedScene == GameScenes.LOADING)
            {
                if (this.deployAltitude <= 500)
                {
                    this.deployAltitude += 200;
                }
            }
        }
Exemplo n.º 13
0
        public void SketchFileProducedWithOlderVersionThanSupportedGivesWarning()
        {
            var archive             = Substitute.For <ISketchArchive>();
            var appVerion           = 3.14;
            var version             = CompatibilityChecker.SketchCompatibilityVersion - 3;
            var compatibiltyVersion = version;

            var json = GenerateMetaJson(appVerion, compatibiltyVersion, version);

            using (var jsonStream = new MemoryStream(Encoding.ASCII.GetBytes(json))) {
                archive.OpenFile("meta.json")
                .Returns(jsonStream);

                var log = new MessageListLogger();

                CompatibilityChecker.Check("dummy.sketch", archive, log);

                Assert.AreEqual(1, log.ErrorsAndWarnings().Count);
                Assert.AreEqual(3, log.Messages.Count);
                Assert.That(log.ErrorsAndWarnings().First(),
                            Does.StartWith("WARNING:" + "\t" + "The sketch file was created with an older version"));
            }
        }
Exemplo n.º 14
0
        public void Start()
        {
            if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
            }

            if (dmpSettings.disclaimerAccepted != 1)
            {
                modDisabled = true;
                disclaimerWindow.SpawnDialog();
            }

            Profiler.DMPReferenceTime.Start();
            DontDestroyOnLoad(this);

            // Prevents symlink warning for development.
            SetupDirectoriesIfNeeded();

            // UniverseSyncCache needs to run expiry here
            universeSyncCache.ExpireCache();

            GameEvents.onHideUI.Add(() =>
            {
                showGUI = false;
            });
            GameEvents.onShowUI.Add(() =>
            {
                showGUI = true;
            });

            HandleCommandLineArgs();
            long testTime = Compression.TestSysIOCompression();

            DarkLog.Debug("System.IO compression works: " + Compression.sysIOCompressionWorks + ", test time: " + testTime + " ms.");
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
Exemplo n.º 15
0
        private void FixedUpdate()
        {
            //Flight values
            if (!CompatibilityChecker.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || this.part.Rigidbody == null)
            {
                return;
            }
            this.pos     = this.part.partTransform.position;
            this.ASL     = FlightGlobals.getAltitudeAtPos(this.pos);
            this.trueAlt = this.ASL;
            if (this.vessel.mainBody.pqsController != null)
            {
                double terrainAlt = this.vessel.pqsAltitude;
                if (!this.vessel.mainBody.ocean || terrainAlt > 0)
                {
                    this.trueAlt -= terrainAlt;
                }
            }
            this.atmPressure = FlightGlobals.getStaticPressure(this.ASL, this.vessel.mainBody) * PhysicsGlobals.KpaToAtmospheres;
            this.atmDensity  = part.atmDensity;
            Vector3 velocity = this.part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f();

            this.sqrSpeed   = velocity.sqrMagnitude;
            this.dragVector = -velocity.normalized;

            if (this.atmDensity > 0)
            {
                CalculateChuteFlux();
            }
            else
            {
                this.convFlux = 0;
            }

            CalculateSafeToDeployEstimate();

            if (!this.staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && this.vessel.isActiveVessel && (this.part.inverseStage == Staging.CurrentStage - 1 || Staging.CurrentStage == 0))
            {
                ActivateRC();
            }

            if (this.staged)
            {
                //Checks if the parachute must disarm
                if (this.armed)
                {
                    this.part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                    if (this.canDeploy)
                    {
                        this.armed = false;
                    }
                }
                //Parachute deployments
                else
                {
                    //Parachutes
                    if (this.canDeploy)
                    {
                        if (this.isDeployed)
                        {
                            if (!CalculateChuteTemp())
                            {
                                return;
                            }
                            FollowDragDirection();
                        }

                        switch (this.deploymentState)
                        {
                        case DeploymentStates.STOWED:
                        {
                            this.part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                            if (this.pressureCheck && this.randomDeployment)
                            {
                                PreDeploy();
                            }
                            break;
                        }

                        case DeploymentStates.PREDEPLOYED:
                        {
                            this.part.Rigidbody.AddForceAtPosition(DragForce(0, this.preDeployedDiameter, 1f / this.semiDeploymentSpeed), this.forcePosition, ForceMode.Force);
                            if (this.trueAlt <= this.deployAltitude && this.dragTimer.elapsed.TotalSeconds >= 1f / this.semiDeploymentSpeed)
                            {
                                Deploy();
                            }
                            break;
                        }

                        case DeploymentStates.DEPLOYED:
                        {
                            this.part.rigidbody.AddForceAtPosition(DragForce(this.preDeployedDiameter, this.deployedDiameter, 1f / this.deploymentSpeed), this.forcePosition, ForceMode.Force);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                    //Deactivation
                    else
                    {
                        if (this.isDeployed)
                        {
                            Cut();
                        }
                        else
                        {
                            this.failedTimer.Start();
                            StagingReset();
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void Start()
        {
            if (CompatibilityChecker.IsAllCompatible() && Instance == null)
            {
                Instance = this;
            }
            else
            {
                Destroy(this);
                return;
            }

            showGUI = false;
            if (FARDebugAndSettings.FARDebugButtonStock)
            {
                FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
            }

            _vehicleAero = new VehicleAerodynamics();

            // ReSharper disable PossibleLossOfFraction
            guiRect = new Rect(Screen.width / 4, Screen.height / 6, 10, 10);
            // ReSharper restore PossibleLossOfFraction

            _instantSim = new InstantConditionSim();
            var flapSettingDropDown =
                new GUIDropDown <int>(new[]
            {
                Localizer.Format("FARFlapSetting0"),
                Localizer.Format("FARFlapSetting1"),
                Localizer.Format("FARFlapSetting2"),
                Localizer.Format("FARFlapSetting3")
            },
                                      new[] { 0, 1, 2, 3 });
            GUIDropDown <CelestialBody> celestialBodyDropdown = CreateBodyDropdown();

            modeDropdown = new GUIDropDown <FAREditorMode>(FAReditorMode_str,
                                                           new[]
            {
                FAREditorMode.STATIC,
                FAREditorMode.STABILITY,
                FAREditorMode.SIMULATION,
                FAREditorMode.AREA_RULING
            });

            _simManager = new EditorSimManager(_instantSim);

            _editorGraph     = new StaticAnalysisGraphGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDeriv       = new StabilityDerivGUI(_simManager, flapSettingDropDown, celestialBodyDropdown);
            _stabDerivLinSim = new StabilityDerivSimulationGUI(_simManager);

            Color crossSection = GUIColors.GetColor(3);

            crossSection.a = 0.8f;

            Color crossSectionDeriv = GUIColors.GetColor(2);

            crossSectionDeriv.a = 0.8f;

            _areaRulingOverlay =
                EditorAreaRulingOverlay.CreateNewAreaRulingOverlay(new Color(0.05f, 0.05f, 0.05f, 0.7f),
                                                                   crossSection,
                                                                   crossSectionDeriv,
                                                                   10,
                                                                   5);
            guiRect.height = 500;
            guiRect.width  = 650;


            GameEvents.onEditorVariantApplied.Add(UpdateGeometryEvent);
            GameEvents.onEditorPartEvent.Add(UpdateGeometryEvent);
            GameEvents.onEditorUndo.Add(ResetEditorEvent);
            GameEvents.onEditorRedo.Add(ResetEditorEvent);
            GameEvents.onEditorShipModified.Add(ResetEditorEvent);
            GameEvents.onEditorLoad.Add(ResetEditorEvent);

            GameEvents.onGUIEngineersReportReady.Add(AddDesignConcerns);
            GameEvents.onGUIEngineersReportDestroy.Add(RemoveDesignConcerns);

            RequestUpdateVoxel();
        }
Exemplo n.º 17
0
        public override void OnStart(PartModule.StartState state)
        {
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (!CompatibilityChecker.IsAllCompatible())
            {
                Actions.ForEach(a => a.active = false);
                Events.ForEach(e =>
                {
                    e.active          = false;
                    e.guiActive       = false;
                    e.guiActiveEditor = false;
                });
                Fields["chuteCount"].guiActive = false;
                return;
            }

            //Staging icon
            this.part.stagingIcon = "PARACHUTES";
            InitializeAnimationSystem();

            //First initiation of the part
            if (!this.initiated)
            {
                this.initiated  = true;
                this.armed      = false;
                this.chuteCount = maxSpares;
                this.cap.gameObject.SetActive(true);
            }
            this.part.mass = this.totalMass;
            this.massDelta = 0f;
            if ((object)(this.part.partInfo) != null && (object)(this.part.partInfo.partPrefab) != null)
            {
                this.massDelta = this.part.mass - this.part.partInfo.partPrefab.mass;
            }

            //Flight loading
            if (HighLogic.LoadedSceneIsFlight)
            {
                Random random = new Random();
                this.randomTime = (float)random.NextDouble();
                this.randomX    = (float)(random.NextDouble() * 100);
                this.randomY    = (float)(random.NextDouble() * 100);

                //Hide/show UI event addition
                GameEvents.onHideUI.Add(HideUI);
                GameEvents.onShowUI.Add(ShowUI);

                if (this.canRepack)
                {
                    SetRepack();
                }

                if (this.time != 0)
                {
                    this.dragTimer = new PhysicsWatch(this.time);
                }
                if (this.deploymentState != DeploymentStates.STOWED)
                {
                    this.part.stackIcon.SetIconColor(XKCDColors.Red);
                    this.cap.gameObject.SetActive(false);
                }

                if (this.staged && this.isDeployed)
                {
                    this.parachute.gameObject.SetActive(true);
                    switch (this.deploymentState)
                    {
                    case DeploymentStates.PREDEPLOYED:
                        this.part.SkipToAnimationTime(this.semiDeployedAnimation, this.semiDeploymentSpeed, Mathf.Clamp01(this.time)); break;

                    case DeploymentStates.DEPLOYED:
                        this.part.SkipToAnimationTime(this.fullyDeployedAnimation, this.deploymentSpeed, Mathf.Clamp01(this.time)); break;

                    default:
                        break;
                    }
                }

                DragCubeList cubes = this.part.DragCubes;
                //Set stock cubes to 0
                cubes.SetCubeWeight("PACKED", 0);
                cubes.SetCubeWeight("SEMIDEPLOYED", 0);
                cubes.SetCubeWeight("DEPLOYED", 0);

                //Sets RC cubes
                if (this.deploymentState == DeploymentStates.STOWED)
                {
                    cubes.SetCubeWeight("PACKED", 1);
                    cubes.SetCubeWeight("RCDEPLOYED", 0);
                }
                else
                {
                    cubes.SetCubeWeight("PACKED", 0);
                    cubes.SetCubeWeight("RCDEPLOYED", 1);
                }
            }

            //GUI
            this.window = new Rect(200, 100, 350, 400);
            this.drag   = new Rect(0, 0, 350, 30);
        }
Exemplo n.º 18
0
        public void Awake()
        {
            DarkLog.SetMainThread();

            if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
            }
            if (Settings.fetch.disclaimerAccepted != 1)
            {
                modDisabled = true;
                DisclaimerWindow.SpawnDialog();
            }

            Profiler.DMPReferenceTime.Start();
            DontDestroyOnLoad(this);

            // Prevents symlink warning for development.
            SetupDirectoriesIfNeeded();

            // UniverseSyncCache needs to run expiry here
            UniverseSyncCache.fetch.ExpireCache();

            // Register events needed to bootstrap the workers.
            lock (eventLock)
            {
                resetEvent.Add(LockSystem.Reset);
                resetEvent.Add(AdminSystem.Reset);
                resetEvent.Add(AsteroidWorker.Reset);
                resetEvent.Add(ChatWorker.Reset);
                resetEvent.Add(CraftLibraryWorker.Reset);
                resetEvent.Add(DebugWindow.Reset);
                resetEvent.Add(DynamicTickWorker.Reset);
                resetEvent.Add(FlagSyncer.Reset);
                resetEvent.Add(HackyInAtmoLoader.Reset);
                resetEvent.Add(KerbalReassigner.Reset);
                resetEvent.Add(PlayerColorWorker.Reset);
                resetEvent.Add(PlayerStatusWindow.Reset);
                resetEvent.Add(PlayerStatusWorker.Reset);
                resetEvent.Add(PartKiller.Reset);
                resetEvent.Add(ScenarioWorker.Reset);
                resetEvent.Add(ScreenshotWorker.Reset);
                resetEvent.Add(TimeSyncer.Reset);
                resetEvent.Add(ToolbarSupport.Reset);
                resetEvent.Add(VesselWorker.Reset);
                resetEvent.Add(WarpWorker.Reset);
                GameEvents.onHideUI.Add(() =>
                {
                    showGUI = false;
                });
                GameEvents.onShowUI.Add(() =>
                {
                    showGUI = true;
                });
            }
            FireResetEvent();
            HandleCommandLineArgs();
            long testTime = Compression.TestSysIOCompression();

            DarkLog.Debug("System.IO compression works: " + Compression.sysIOCompressionWorks + ", test time: " + testTime + " ms.");
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
Exemplo n.º 19
0
        private void Start()
        {
            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }

            _vessel      = gameObject.GetComponent <Vessel>();
            this.enabled = true;

            if (_vessel.rootPart.Modules.Contains("MissileLauncher") && _vessel.parts.Count == 1)
            {
                _vessel.rootPart.dragModel = Part.DragModel.CUBE;
                this.enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();
            for (int i = 0; i < _vessel.parts.Count; i++)
            {
                Part p = _vessel.parts[i];
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                /*p.dragModel = Part.DragModel.NONE;
                 * p.dragReferenceVector = Vector3.zero;
                 * p.dragScalar = 0;
                 * p.dragVector = Vector3.zero;
                 * p.dragVectorDir = Vector3.zero;
                 * p.dragVectorDirLocal = Vector3.zero;
                 * p.dragVectorMag = 0;
                 * p.dragVectorSqrMag = 0;
                 *
                 * p.bodyLiftMultiplier = 0;
                 * p.bodyLiftScalar = 0;*/

                GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                if ((object)g != null)
                {
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }
                if (p.Modules.Contains <KerbalEVA>() || p.Modules.Contains <FlagSite>())
                {
                    Debug.Log("Handling Stuff for KerbalEVA / Flag");
                    g = (GeometryPartModule)p.AddModule("GeometryPartModule");
                    g.OnStart(StartState());
                    p.AddModule("FARAeroPartModule").OnStart(StartState());
                    _currentGeoModules.Add(g);
                }
            }

            GameEvents.onVesselGoOffRails.Add(VesselUpdateEvent);
            //GameEvents.onVesselChange.Add(VesselUpdateEvent);
            //GameEvents.onVesselLoaded.Add(VesselUpdate);
            //GameEvents.onVesselCreate.Add(VesselUpdateEvent);
            GameEvents.onVesselWasModified.Add(VesselUpdateEvent);
            RequestUpdateVoxel(false);

            if (_vessel == null)
            {
                _vessel = gameObject.GetComponent <Vessel>();
                if (_vessel == null)
                {
                    return;
                }
            }

            if (_vehicleAero == null)
            {
                _vehicleAero         = new VehicleAerodynamics();
                _vesselIntakeRamDrag = new VesselIntakeRamDrag();
            }
            //Debug.Log("Starting " + _vessel.vesselName + " aero properties");
        }
Exemplo n.º 20
0
 public HttpApiClient(IMessageSerializer serializer, CompatibilityChecker compatibility, InstanceHash instanceHash)
 {
     this.serializer    = serializer ?? throw new ArgumentNullException(nameof(serializer));
     this.compatibility = compatibility ?? throw new ArgumentNullException(nameof(compatibility));
     this.instanceHash  = instanceHash ?? throw new ArgumentNullException(nameof(instanceHash));
 }
        public override void OnStart(StartState startState)
        {
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (!CompatibilityChecker.IsAllCompatible())
            {
                Actions.ForEach(a => a.active = false);
                Events.ForEach(e =>
                {
                    e.active          = false;
                    e.guiActive       = false;
                    e.guiActiveEditor = false;
                });
                Fields["chuteCount"].guiActive = false;
                return;
            }

            //Staging icon
            part.stagingIcon = "PARACHUTES";
            InitializeAnimationSystem();

            //First initiation of the part
            if (!initiated)
            {
                initiated  = true;
                armed      = false;
                chuteCount = maxSpares;
                cap.gameObject.SetActive(true);
            }

            float tmpPartMass = TotalMass;

            massDelta = 0;
            if (!(part.partInfo?.partPrefab is null))
            {
                massDelta = tmpPartMass - part.partInfo.partPrefab.mass;
            }

            //Flight loading
            if (HighLogic.LoadedSceneIsFlight)
            {
                var random = new Random();
                randomTime = (float)random.NextDouble();
                randomX    = (float)(random.NextDouble() * 100);
                randomY    = (float)(random.NextDouble() * 100);

                //Hide/show UI event addition
                GameEvents.onHideUI.Add(HideUI);
                GameEvents.onShowUI.Add(ShowUI);
                GameEvents.onStageActivate.Add(OnStageActivate);

                if (CanRepack)
                {
                    SetRepack();
                }

                if (!time.NearlyEqual(0))
                {
                    dragTimer = new PhysicsWatch(time);
                }
                if (DeploymentState != DeploymentStates.STOWED)
                {
                    part.stackIcon.SetIconColor(XKCDColors.Red);
                    cap.gameObject.SetActive(false);
                }

                if (staged && IsDeployed)
                {
                    parachute.gameObject.SetActive(true);
                    switch (DeploymentState)
                    {
                    case DeploymentStates.PREDEPLOYED:
                        part.SkipToAnimationTime(semiDeployedAnimation, semiDeploymentSpeed, Mathf.Clamp01(time));
                        break;

                    case DeploymentStates.DEPLOYED:
                        part.SkipToAnimationTime(fullyDeployedAnimation, deploymentSpeed, Mathf.Clamp01(time));
                        break;
                    }
                }

                DragCubeList cubes = part.DragCubes;
                //Set stock cubes to 0
                cubes.SetCubeWeight("PACKED", 0);
                cubes.SetCubeWeight("SEMIDEPLOYED", 0);
                cubes.SetCubeWeight("DEPLOYED", 0);

                //Sets RC cubes
                if (DeploymentState == DeploymentStates.STOWED)
                {
                    cubes.SetCubeWeight("PACKED", 1);
                    cubes.SetCubeWeight("RCDEPLOYED", 0);
                }
                else
                {
                    cubes.SetCubeWeight("PACKED", 0);
                    cubes.SetCubeWeight("RCDEPLOYED", 1);
                }
            }

            //GUI
            window = new Rect(200, 100, 350, 400);
            drag   = new Rect(0, 0, 350, 30);
        }
 public HttpRequestHeaderValidator(ILogger <HttpRequestHeaderValidator> logger, CompatibilityChecker compatibilityChecker, InstanceHash instanceHash)
 {
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     CompatibilityChecker = compatibilityChecker ?? throw new System.ArgumentNullException(nameof(compatibilityChecker));
     InstanceHash         = instanceHash ?? throw new ArgumentNullException(nameof(instanceHash));
 }
        private void FixedUpdate()
        {
            //Flight values
            if (!CompatibilityChecker.IsAllCompatible() ||
                !HighLogic.LoadedSceneIsFlight ||
                FlightGlobals.ActiveVessel == null ||
                part.Rigidbody == null)
            {
                return;
            }
            pos     = part.partTransform.position;
            asl     = FlightGlobals.getAltitudeAtPos(pos);
            trueAlt = asl;
            if (vessel.mainBody.pqsController != null)
            {
                double terrainAlt = vessel.pqsAltitude;
                if (!vessel.mainBody.ocean || terrainAlt > 0)
                {
                    trueAlt -= terrainAlt;
                }
            }

            atmPressure = FlightGlobals.getStaticPressure(asl, vessel.mainBody) * PhysicsGlobals.KpaToAtmospheres;
            atmDensity  = part.atmDensity;
            Vector3 velocity = part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f();

            sqrSpeed   = velocity.sqrMagnitude;
            dragVector = -velocity.normalized;

            if (atmDensity > 0)
            {
                CalculateChuteFlux();
            }
            else
            {
                convFlux = 0;
            }

            CalculateSafeToDeployEstimate();

            if (!staged)
            {
                return;
            }
            //Checks if the parachute must disarm
            if (armed)
            {
                part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                if (CanDeploy)
                {
                    armed = false;
                }
            }
            //Parachute deployments
            else
            {
                //Parachutes
                if (CanDeploy)
                {
                    if (IsDeployed)
                    {
                        if (!CalculateChuteTemp())
                        {
                            return;
                        }
                        FollowDragDirection();
                    }

                    part.GetComponentCached(ref rigidbody);
                    switch (DeploymentState)
                    {
                    case DeploymentStates.STOWED:
                    {
                        part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                        if (PressureCheck && RandomDeployment)
                        {
                            PreDeploy();
                        }
                        break;
                    }

                    case DeploymentStates.PREDEPLOYED:
                    {
                        part.AddForceAtPosition(DragForce(0, preDeployedDiameter, 1f / semiDeploymentSpeed),
                                                ForcePosition);
                        if (trueAlt <= deployAltitude && dragTimer.Elapsed.TotalSeconds >= 1f / semiDeploymentSpeed)
                        {
                            Deploy();
                        }
                        break;
                    }

                    case DeploymentStates.DEPLOYED:
                    {
                        part.AddForceAtPosition(DragForce(preDeployedDiameter,
                                                          deployedDiameter,
                                                          1f / deploymentSpeed),
                                                ForcePosition);
                        break;
                    }
                    }
                }
                //Deactivation
                else
                {
                    if (IsDeployed)
                    {
                        Cut();
                    }
                    else
                    {
                        failedTimer.Start();
                        StagingReset();
                    }
                }
            }
        }
        private void Update()
        {
            if (!CompatibilityChecker.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            //Makes the chute icon blink if failed
            if (failedTimer.IsRunning)
            {
                double totalSeconds = failedTimer.Elapsed.TotalSeconds;
                if (totalSeconds <= 2.5)
                {
                    if (!displayed)
                    {
                        ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailDeploy"),
                                                         2.5f,
                                                         ScreenMessageStyle.UPPER_CENTER);
                        if (part.ShieldedFromAirstream)
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailShielded"),
                                                             2.5f,
                                                             ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (GroundStop)
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailGround"),
                                                             2.5f,
                                                             ScreenMessageStyle.UPPER_CENTER);
                        }
                        else if (atmPressure.NearlyEqual(0))
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailPres"),
                                                             2.5f,
                                                             ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            ScreenMessages.PostScreenMessage(Localizer.Format("RCLFailOther"),
                                                             2.5f,
                                                             ScreenMessageStyle.UPPER_CENTER);
                        }
                        displayed = true;
                    }

                    if (totalSeconds < 0.5 || totalSeconds >= 1 && totalSeconds < 1.5 || totalSeconds >= 2)
                    {
                        part.stackIcon.SetIconColor(XKCDColors.Red);
                    }
                    else
                    {
                        part.stackIcon.SetIconColor(XKCDColors.White);
                    }
                }
                else
                {
                    displayed = false;
                    part.stackIcon.SetIconColor(XKCDColors.White);
                    failedTimer.Reset();
                }
            }

            Disarm.active             = armed || showDisarm;
            DeployE.active            = !staged && DeploymentState != DeploymentStates.CUT;
            CutE.active               = IsDeployed;
            Repack.guiActiveUnfocused = CanRepack;
        }
Exemplo n.º 25
0
        public void Awake()
        {
            Profiler.DMPReferenceTime.Start();
            GameObject.DontDestroyOnLoad(this);
            assemblyPath = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).FullName;
            string kspPath = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName;

            //I find my abuse of Path.Combine distrubing.
            UnityEngine.Debug.Log("KSP installed at " + kspPath);
            UnityEngine.Debug.Log("DMP installed at " + assemblyPath);
            //Prevents symlink warning for development.
            if (Settings.fetch.disclaimerAccepted != 1)
            {
                modDisabled = true;
                DisclaimerWindow.Enable();
            }
            if (!CompatibilityChecker.IsCompatible())
            {
                modDisabled = true;
            }
            #if !DEBUG
            if (!InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
            }
            #endif
            SetupDirectoriesIfNeeded();
            //UniverseSyncCache needs to run expiry here
            UniverseSyncCache.fetch.ExpireCache();
            //Register events needed to bootstrap the workers.
            lock (eventLock)
            {
                resetEvent.Add(LockSystem.Reset);
                resetEvent.Add(AdminSystem.Reset);
                resetEvent.Add(AsteroidWorker.Reset);
                resetEvent.Add(ChatWorker.Reset);
                resetEvent.Add(CraftLibraryWorker.Reset);
                resetEvent.Add(DebugWindow.Reset);
                resetEvent.Add(DynamicTickWorker.Reset);
                resetEvent.Add(FlagSyncer.Reset);
                resetEvent.Add(HackyInAtmoLoader.Reset);
                resetEvent.Add(PlayerColorWorker.Reset);
                resetEvent.Add(PlayerStatusWindow.Reset);
                resetEvent.Add(PlayerStatusWorker.Reset);
                resetEvent.Add(PartKiller.Reset);
                resetEvent.Add(ScenarioWorker.Reset);
                resetEvent.Add(ScreenshotWorker.Reset);
                resetEvent.Add(TimeSyncer.Reset);
                resetEvent.Add(ToolbarSupport.Reset);
                resetEvent.Add(VesselWorker.Reset);
                resetEvent.Add(WarpWorker.Reset);
                GameEvents.onHideUI.Add(() =>
                {
                    showGUI = false;
                });
                GameEvents.onShowUI.Add(() =>
                {
                    showGUI = true;
                });
            }
            FireResetEvent();
            HandleCommandLineArgs();
            long testTime = Compression.TestSysIOCompression();
            DarkLog.Debug("System.IO compression works: " + Compression.sysIOCompressionWorks + ", test time: " + testTime + " ms.");
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
Exemplo n.º 26
0
        public void Start()
        {
            //Set buffered UDPMesh
            UDPMeshLib.UdpMeshCommon.USE_BUFFERS = true;
            //Set pool sizes for ByteRecycler
            ByteRecycler.AddPoolSize(SMALL_MESSAGE_SIZE);
            ByteRecycler.AddPoolSize(MEDIUM_MESSAGE_SIZE);
            ByteRecycler.AddPoolSize(LARGE_MESSAGE_SIZE);
            MessageWriter.RegisterType <ByteArray>(WriteByteArrayToStream);
            MessageReader.RegisterType <ByteArray>(ReadByteArrayFromStream);

            //Prevent loads if multiple copies of DMP are installed. KSP will instantate us twice.
            if (dmpClient != null)
            {
                warnDuplicateInstall = true;
                return;
            }

            if (!CompatibilityChecker.IsCompatible() || !InstallChecker.IsCorrectlyInstalled())
            {
                modDisabled = true;
                enabled     = false;
                return;
            }

            TimingManager.FixedUpdateAdd(TimingManager.TimingStage.BetterLateThanNever, TimingManagerFixedUpdate);
            dmpDir      = Path.Combine(Path.Combine(Path.Combine(KSPUtil.ApplicationRootPath, "GameData"), "DarkMultiPlayer"), "Plugins");
            dmpDataDir  = Path.Combine(dmpDir, "Data");
            gameDataDir = Path.Combine(KSPUtil.ApplicationRootPath, "GameData");
            kspRootPath = KSPUtil.ApplicationRootPath;

            //Fix DarkLog time/thread marker in the log during init.
            DarkLog.SetMainThread();
            lastClockTicks           = DateTime.UtcNow.Ticks;
            lastRealTimeSinceStartup = 0f;

            dmpClient = this;
            profiler  = new Profiler();
            kspTime   = profiler.GetCurrentTime;
            kspMemory = profiler.GetCurrentMemory;

            dmpSettings       = new Settings();
            toolbarSupport    = new ToolbarSupport(dmpSettings);
            universeSyncCache = new UniverseSyncCache(dmpSettings);
            modWindow         = new ModWindow();
            modWorker         = new ModWorker(modWindow);
            modWindow.SetDependenices(modWorker);
            universeConverter          = new UniverseConverter(dmpSettings);
            universeConverterWindow    = new UniverseConverterWindow(universeConverter);
            serverListDisclaimerWindow = new ServerListDisclaimerWindow(dmpSettings);
            optionsWindow        = new OptionsWindow(dmpSettings, universeSyncCache, modWorker, universeConverterWindow, toolbarSupport, serverListDisclaimerWindow);
            serverListConnection = new ServerListConnection(dmpSettings);
            serversWindow        = new ServersWindow(dmpSettings, optionsWindow, serverListConnection);
            serverListConnection.SetDependancy(serversWindow);
            connectionWindow = new ConnectionWindow(dmpSettings, optionsWindow, serversWindow, serverListDisclaimerWindow);
            disclaimerWindow = new DisclaimerWindow(dmpSettings);
            dmpModInterface  = new DMPModInterface();
            //SafetyBubble.RegisterDefaultLocations();


            if (dmpSettings.disclaimerAccepted != 1)
            {
                modDisabled = true;
                disclaimerWindow.SpawnDialog();
            }

            Application.wantsToQuit += WantsToQuit;
            DontDestroyOnLoad(this);

            // Prevents symlink warning for development.
            SetupDirectoriesIfNeeded();

            // UniverseSyncCache needs to run expiry here
            universeSyncCache.ExpireCache();

            GameEvents.onHideUI.Add(() =>
            {
                showGUI = false;
            });
            GameEvents.onShowUI.Add(() =>
            {
                showGUI = true;
            });

            HandleCommandLineArgs();
            DarkLog.Debug("DarkMultiPlayer " + Common.PROGRAM_VERSION + ", protocol " + Common.PROTOCOL_VERSION + " Initialized!");
        }
Exemplo n.º 27
0
        protected override void OnStart()
        {
            Debug.Log("FARVesselAero on " + vessel.name + " reporting startup");
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                this.enabled = false;
                return;
            }
            if (!HighLogic.LoadedSceneIsFlight)
            {
                this.enabled = false;
                return;
            }

            _currentGeoModules = new List <GeometryPartModule>();

            /*if (!vessel.rootPart)
             * {
             *  this.enabled = false;
             *  return;
             * }*/

            for (int i = 0; i < vessel.parts.Count; i++)
            {
                Part p = vessel.parts[i];
                p.maximum_drag = 0;
                p.minimum_drag = 0;
                p.angularDrag  = 0;

                /*p.dragModel = Part.DragModel.NONE;
                 * p.dragReferenceVector = Vector3.zero;
                 * p.dragScalar = 0;
                 * p.dragVector = Vector3.zero;
                 * p.dragVectorDir = Vector3.zero;
                 * p.dragVectorDirLocal = Vector3.zero;
                 * p.dragVectorMag = 0;
                 * p.dragVectorSqrMag = 0;
                 *
                 * p.bodyLiftMultiplier = 0;
                 * p.bodyLiftScalar = 0;*/

                GeometryPartModule g = p.GetComponent <GeometryPartModule>();
                if ((object)g != null)
                {
                    _currentGeoModules.Add(g);
                    if (g.Ready)
                    {
                        geoModulesReady++;
                    }
                }
                if (p.Modules.Contains <KerbalEVA>() || p.Modules.Contains <FlagSite>())
                {
                    Debug.Log("Handling Stuff for KerbalEVA / Flag");
                    g = (GeometryPartModule)p.AddModule("GeometryPartModule");
                    g.OnStart(StartState());
                    p.AddModule("FARAeroPartModule").OnStart(StartState());
                    _currentGeoModules.Add(g);
                }
            }
            RequestUpdateVoxel(false);

            this.enabled = true;
            //GameEvents.onVesselLoaded.Add(VesselUpdateEvent);
            //GameEvents.onVesselChange.Add(VesselUpdateEvent);
            //GameEvents.onVesselLoaded.Add(VesselUpdate);
            //GameEvents.onVesselCreate.Add(VesselUpdateEvent);

            //Debug.Log("Starting " + _vessel.vesselName + " aero properties");
        }
Exemplo n.º 28
0
        protected override void OnStart()
        {
            base.OnStart();

            if (!CompatibilityChecker.IsAllCompatible())
            {
                enabled = false;
                return;
            }

            showGUI = savedShowGUI;
            //since we're sharing the button, we need these shenanigans now
            if (FARDebugAndSettings.FARDebugButtonStock && HighLogic.LoadedSceneIsFlight)
            {
                if (showGUI)
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetTrue(false);
                }
                else
                {
                    FARDebugAndSettings.FARDebugButtonStock.SetFalse(false);
                }
            }


            _vessel                = GetComponent <Vessel>();
            _vesselAero            = GetComponent <FARVesselAero>();
            _physicsCalcs          = new PhysicsCalcs(_vessel, _vesselAero);
            _flightStatusGUI       = new FlightStatusGUI();
            _stabilityAugmentation = new StabilityAugmentation(_vessel);
            _flightDataGUI         = new FlightDataGUI();
            AeroVizGUI             = new AeroVisualizationGUI();

            settingsWindow = new GUIDropDown <int>(new[]
            {
                Localizer.Format("FARFlightGUIWindowSelect0"),
                Localizer.Format("FARFlightGUIWindowSelect1"),
                Localizer.Format("FARFlightGUIWindowSelect2"),
                Localizer.Format("FARFlightGUIWindowSelect3")
            },
                                                   new[] { 0, 1, 2, 3 });

            if (vesselFlightGUI.ContainsKey(_vessel))
            {
                vesselFlightGUI[_vessel] = this;
            }
            else
            {
                vesselFlightGUI.Add(_vessel, this);
            }

            enabled = true;

            if (FARDebugValues.useBlizzyToolbar)
            {
                GenerateBlizzyToolbarButton();
            }

            activeFlightGUICount++;

            if (_vessel == FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel == null)
            {
                LoadConfigs();
            }

            GameEvents.onShowUI.Add(ShowUI);
            GameEvents.onHideUI.Add(HideUI);
        }
Exemplo n.º 29
0
 public PackageArchive(CompatibilityChecker compatibilityChecker, IMessageSerializer serializer)
 {
     this.compatibilityChecker = compatibilityChecker ?? throw new ArgumentNullException(nameof(compatibilityChecker));
     this.serializer           = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }