예제 #1
0
 private void KillButton()
 {
     HailerGUI.CloseAllGUIs();
     if (button != null && ApplicationLauncher.Instance != null)
     {
         ApplicationLauncher.Instance.RemoveModApplication(button);
         button = null;
     }
 }
예제 #2
0
        public static void CloseGUI(Vessel hostVessel)
        {
            HailerGUI hailerGUI = openWindows.FirstOrDefault((HailerGUI gui) => (UnityEngine.Object)gui.vessel == (UnityEngine.Object)hostVessel);

            if ((UnityEngine.Object)hailerGUI != (UnityEngine.Object)null)
            {
                UnityEngine.Object.Destroy(hailerGUI);
            }
        }
예제 #3
0
        public static void CloseGUI(Vessel hostVessel)
        {
            HailerGUI hailerGUI = openWindows.FirstOrDefault(gui => gui.vessel == hostVessel);

            if (hailerGUI != null)
            {
                Destroy(hailerGUI);
            }
        }
예제 #4
0
        public static HailerGUI ActivateGUI(Vessel hostVessel)
        {
            HailerGUI hailerGUI = openWindows.FirstOrDefault((HailerGUI gui) => (UnityEngine.Object)gui.vessel == (UnityEngine.Object)hostVessel);

            if ((UnityEngine.Object)hailerGUI != (UnityEngine.Object)null)
            {
                return(hailerGUI);
            }
            hailerGUI        = hostVessel.gameObject.AddComponent <HailerGUI>();
            hailerGUI.vessel = hostVessel;
            return(hailerGUI);
        }
예제 #5
0
        public static HailerGUI ActivateGUI(Vessel hostVessel)
        {
            HailerGUI hailerGUI = openWindows.FirstOrDefault(gui => gui.vessel == hostVessel);

            if (hailerGUI != null)
            {
                return(hailerGUI);
            }
            hailerGUI        = hostVessel.gameObject.AddComponent <HailerGUI>();
            hailerGUI.vessel = hostVessel;
            return(hailerGUI);
        }
예제 #6
0
        private void KillButton()
        {
            HailerGUI.CloseAllGUIs();
            toolbarControl.OnDestroy();
            Destroy(toolbarControl);
#if false
            if (button != null && ApplicationLauncher.Instance != null)
            {
                ApplicationLauncher.Instance.RemoveModApplication(button);
                button = null;
            }
#endif
        }
예제 #7
0
 public TargetDetails(Vessel target, HailerGUI hailerGUI)
 {
     this.hailerGUI = hailerGUI;
     targetVessel   = target;
     vesselName     = target.vesselName;
     if (hailerGUI.nearBeacon != null)
     {
         pathCheck = new PathCheck(hailerGUI.nearBeacon.Vessel, targetVessel, hailerGUI.nearBeacon.PathGLimit);
     }
     else
     {
         pathCheck = new PathCheck(null, targetVessel, 0f);
     }
     Update();
 }
예제 #8
0
 public void HailerDeactivate()
 {
     hailerActive = false;
     if (!base.vessel.FindPartModulesImplementing <ESLDHailer>().Any((ESLDHailer hailer) => hailer.hailerActive))
     {
         HailerGUI.CloseGUI(base.vessel);
     }
     base.Events["HailerDeactivate"].active = false;
     base.Events["HailerActivate"].active   = true;
     base.Events["HailerGUIOpen"].active    = false;
     base.Events["HailerGUIClose"].active   = false;
     ((BaseFieldList <BaseField, KSPField>)base.Fields)["hasNearBeacon"].guiActive      = false;
     ((BaseFieldList <BaseField, KSPField>)base.Fields)["nearBeaconDistance"].guiActive = false;
     ((BaseFieldList <BaseField, KSPField>)base.Fields)["nearBeaconRelVel"].guiActive   = false;
 }
예제 #9
0
        public void OnVesselChange(Vessel vessel)
        {
            HailerGUI.CloseGUI(this.vessel);
            this.vessel = vessel;

            hailer = vessel?.FindPartModulesImplementing <ESLDHailer>().FirstOrDefault();

            canHail = hailer != null;

            if (canHail && button == null)
            {
                OnGUIApplicationLauncherReady();
            }
            else if (!canHail && button != null)
            {
                KillButton();
            }
        }
예제 #10
0
        public static float GetHCUCost(Vessel vessel, IEnumerable <Part> HCUParts = null, float multiplier = 1f)
        {
            float HCUCost = 0f;

            if (HCUParts == null)
            {
                HCUParts = HailerGUI.GetHCUParts(vessel).Keys.ToList();
            }
            foreach (Part HCUPart in HCUParts)
            {
                foreach (PartResource resource in HCUPart.Resources)
                {
                    if (HailerGUI.highEnergyResources.ContainsKey(resource.resourceName) && resource.amount > 0.0)
                    {
                        HCUCost += resource.info.density * (float)resource.amount * 0.1f / 0.0058f * HailerGUI.highEnergyResources[resource.resourceName];
                    }
                }
            }
            HCUCost += (float)vessel.GetCrewCount() * 0.9f / 1.13f;
            return(HCUCost * multiplier);
        }
예제 #11
0
 private void OnFalse()
 => HailerGUI.CloseAllGUIs();
예제 #12
0
 private void OnTrue()
 {
     OnVesselChange(FlightGlobals.ActiveVessel);
     HailerGUI.ActivateGUI(FlightGlobals.ActiveVessel);
 }
예제 #13
0
 public void HailerGUIClose()
 {
     base.Events["HailerGUIClose"].active = false;
     base.Events["HailerGUIOpen"].active  = true;
     HailerGUI.CloseGUI(base.vessel);
 }
예제 #14
0
 public void HailerGUIOpen()
 {
     base.Events["HailerGUIOpen"].active  = false;
     base.Events["HailerGUIClose"].active = true;
     hailerGui = HailerGUI.ActivateGUI(base.vessel);
 }
예제 #15
0
        public void Warp(Vessel target, Vessel destination, float precision, List <Part> unsafeParts = null)
        {
            float tripdist  = Vector3.Distance(base.vessel.GetWorldPos3D(), destination.GetWorldPos3D());
            float totalMass = target.GetTotalMass();
            float cost      = GetTripFinalCost(GetTripBaseCost(tripdist, totalMass), target, destination, totalMass, unsafeParts);

            HailerGUI.PathCheck pathCheck = new HailerGUI.PathCheck(base.vessel, destination, gLimitEff);
            if (pathCheck.clear)
            {
                if (jumpResources.All(res => RequireResource(res.resID, (double)(res.ratio * cost), false)))
                {
                    jumpResources.All(res => RequireResource(res.resID, (double)(res.ratio * cost), true));

                    HailerButton.Instance.Dazzle();

                    Vector3d transferVelOffset = GetJumpVelOffset(target, destination);
                    if (hasAMU)
                    {
                        transferVelOffset = destination.orbit.vel;
                    }

                    Vector3d vector3d = (UnityEngine.Random.onUnitSphere + UnityEngine.Random.insideUnitSphere) / 2f * precision;
                    // Making the spread less likely to throw you outside the SoI of the body.
                    if ((destination.orbit.pos + vector3d).magnitude > destination.mainBody.sphereOfInfluence)
                    {
                        vector3d = -vector3d;                        // Negative random is equally random.
                    }
                    OrbitDriver orbitDriver = target.orbitDriver;
                    Orbit       orbit       = orbitDriver.orbit;
                    Orbit       orbit2      = new Orbit(orbit.inclination, orbit.eccentricity, orbit.semiMajorAxis, orbit.LAN, orbit.argumentOfPeriapsis, orbit.meanAnomalyAtEpoch, orbit.epoch, orbit.referenceBody);
                    orbit2.UpdateFromStateVectors(destination.orbit.pos + vector3d, transferVelOffset, destination.mainBody, Planetarium.GetUniversalTime());
                    target.Landed   = false;
                    target.Splashed = false;
                    target.landedAt = string.Empty;
                    OrbitPhysicsManager.HoldVesselUnpack(60);
                    List <Vessel> vessels = FlightGlobals.Vessels;
                    foreach (Vessel item in vessels.AsEnumerable())
                    {
                        if (!item.packed)
                        {
                            item.GoOnRails();
                        }
                    }
                    CelestialBody referenceBody = target.orbitDriver.orbit.referenceBody;
                    orbit.inclination         = orbit2.inclination;
                    orbit.eccentricity        = orbit2.eccentricity;
                    orbit.semiMajorAxis       = orbit2.semiMajorAxis;
                    orbit.LAN                 = orbit2.LAN;
                    orbit.argumentOfPeriapsis = orbit2.argumentOfPeriapsis;
                    orbit.meanAnomalyAtEpoch  = orbit2.meanAnomalyAtEpoch;
                    orbit.epoch               = orbit2.epoch;
                    orbit.referenceBody       = orbit2.referenceBody;
                    orbit.Init();
                    orbit.UpdateFromUT(Planetarium.GetUniversalTime());
                    if ((UnityEngine.Object)orbit.referenceBody != (UnityEngine.Object)orbit2.referenceBody)
                    {
                        orbitDriver.OnReferenceBodyChange?.Invoke(orbit2.referenceBody);
                    }
                    target.orbitDriver.pos = target.orbit.pos.xzy;
                    target.orbitDriver.vel = target.orbit.vel;
                    if ((UnityEngine.Object)target.orbitDriver.orbit.referenceBody != (UnityEngine.Object)referenceBody)
                    {
                        GameEvents.onVesselSOIChanged.Fire(new GameEvents.HostedFromToAction <Vessel, CelestialBody>(target, referenceBody, target.orbitDriver.orbit.referenceBody));
                    }
                    if (UnsafeTransfer)
                    {
                        if (unsafeParts == null)
                        {
                            unsafeParts = HailerGUI.GetHCUParts(target).Keys.ToList();
                        }
                        for (int i = unsafeParts.Count - 1; i >= 0; i--)
                        {
                            unsafeParts[i].explosionPotential = Mathf.Max(1f, unsafeParts[i].explosionPotential);
                            unsafeParts[i].explode();
                        }
                        for (int i = base.vessel.parts.Count - 1; i >= 0; i--)
                        {
                            Part part = base.vessel.parts[i];
                            for (int j = part.protoModuleCrew.Count - 1; j >= 0; j--)
                            {
                                ProtoCrewMember protoCrewMember = part.protoModuleCrew[j];
                                ScreenMessages.PostScreenMessage(protoCrewMember.name + " was killed in transit!", 5f, ScreenMessageStyle.UPPER_CENTER);
                                base.vessel.parts[i].RemoveCrewmember(protoCrewMember);
                                protoCrewMember.Die();
                            }
                        }
                    }
                }
                else
                {
                    ScreenMessages.PostScreenMessage("Jump failed!  Origin beacon did not have enough fuel to execute transfer.", 5f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
        }