コード例 #1
0
        /// <summary>
        /// This method will reduce the load/unload distances using a closer range to avoid issues.
        /// </summary>
        private void UnloadLandedVessels()
        {
            var vesselsCount = FlightGlobals.Vessels.Count;

            ScreenMessages.PostScreenMessage(
                "[PhysicsRangeExtender] Unloading landed vessels during active orbital fly.", 3f, ScreenMessageStyle.UPPER_CENTER);
            for (var i = 0; i < vesselsCount; i++)
            {
                if (FlightGlobals.Vessels[i].LandedOrSplashed)
                {
                    var safeSituation = new VesselRanges.Situation(
                        load: FlightGlobals.ActiveVessel.orbit.referenceBody.inverseRotThresholdAltitude * 0.90f,
                        unload: FlightGlobals.ActiveVessel.orbit.referenceBody.inverseRotThresholdAltitude * 0.95f,
                        pack: PreSettings.GlobalRange * 1000 * 1.10f,
                        unpack: PreSettings.GlobalRange * 1000 * 0.99f);

                    var newRanges = new VesselRanges
                    {
                        escaping   = _globalSituation,
                        flying     = _globalSituation,
                        landed     = safeSituation,
                        orbit      = _globalSituation,
                        prelaunch  = safeSituation,
                        splashed   = safeSituation,
                        subOrbital = _globalSituation
                    };

                    FlightGlobals.Vessels[i].vesselRanges = newRanges;
                }
            }
        }
コード例 #2
0
        public static void UpdateRanges(bool updatingFromUi = false)
        {
            Debug.Log("[PhysicsRangeExtender]:  Updating ranges");
            FloatingOrigin.fetch.threshold = Mathf.Pow(PreSettings.GlobalRange * 1000 * 1.20f, 2);

            if (updatingFromUi)
            {
                TerrainExtender.UpdateSphere();
            }

            _globalSituation = new VesselRanges.Situation(
                PreSettings.GlobalRange * 1000,
                PreSettings.GlobalRange * 1000 * 1.05f,
                PreSettings.GlobalRange * 1000 * 1.10f,
                PreSettings.GlobalRange * 1000 * 0.99f);

            _baseRanges = new VesselRanges
            {
                escaping   = _globalSituation,
                flying     = _globalSituation,
                landed     = _globalSituation,
                orbit      = _globalSituation,
                prelaunch  = _globalSituation,
                splashed   = _globalSituation,
                subOrbital = _globalSituation
            };
            ApplyRangesToVessels(updatingFromUi);
        }
コード例 #3
0
ファイル: OrXLog.cs プロジェクト: DoctorDavinci/OrX_Kontinuum
        public void SetRange(Vessel v, float _range)
        {
            float _modRange = 10000;

            if (OrXHoloKron.instance.bdaChallenge)
            {
                _modRange = _preLoadRange * 1000;
                try
                {
                    var pqs = FlightGlobals.currentMainBody.pqsController;
                    if (pqs != null)
                    {
                        if (pqs.horizonDistance <= _modRange)
                        {
                            pqs.horizonDistance               = _modRange;
                            pqs.maxDetailDistance             = _modRange;
                            pqs.minDetailDistance             = _modRange;
                            pqs.visRadSeaLevelValue           = 200;
                            pqs.collapseSeaLevelValue         = 200;
                            FloatingOrigin.fetch.threshold    = _modRange;
                            FloatingOrigin.fetch.thresholdSqr = _modRange * _modRange;
                            Debug.Log("[OrX Log Set Range] === FLOATING ORIGIN THRESHOLD: " + FloatingOrigin.fetch.threshold + " meters =====");
                        }
                    }
                }
                catch { }

                if (v.vesselRanges.landed.load <= _modRange * 950f)
                {
                    _vesselLanded = new VesselRanges.Situation(_modRange, _modRange, _modRange, _modRange);
                    _vesselFlying = new VesselRanges.Situation(_modRange * 4, _modRange * 4, _modRange * 4, _modRange * 4);
                    _vesselOther  = new VesselRanges.Situation(_modRange * 10, _modRange * 10, _modRange * 10, _modRange * 10);

                    _vesselRanges = new VesselRanges
                    {
                        escaping   = _vesselOther,
                        flying     = _vesselFlying,
                        landed     = _vesselLanded,
                        orbit      = _vesselOther,
                        prelaunch  = _vesselLanded,
                        splashed   = _vesselFlying,
                        subOrbital = _vesselOther
                    };

                    v.vesselRanges = new VesselRanges(_vesselRanges);
                }
            }
            else
            {
                SetGoalRange(v);
            }
        }
コード例 #4
0
        public void UpdateCacheSettings()
        {
            float highestVisibility = 0;
            float furthestDist      = 0;

            centerPoint = Vector3.zero;
            StaticInstance soCenter = null;
            Vector3        vRadPos  = Vector3.zero;


            // FIRST ONE IS THE CENTER
            groupCenter = groupInstances[0];
            centerPoint = groupInstances[0].gameObject.transform.position;
            vRadPos     = (Vector3)groupInstances[0].RadialPosition;
            groupInstances[0].GroupCenter = "true";
            soCenter = groupInstances[0];

            for (int i = 0; i < groupInstances.Length; i++)
            {
                if (groupInstances[i] != soCenter)
                {
                    groupInstances[i].GroupCenter = "false";
                }

                if (groupInstances[i].VisibilityRange > highestVisibility)
                {
                    highestVisibility = groupInstances[i].VisibilityRange;
                }

                float dist = Vector3.Distance(centerPoint, groupInstances[i].gameObject.transform.position);

                if (dist > furthestDist)
                {
                    furthestDist = dist;
                }
            }

            VesselRanges.Situation unloadRange = PhysicsGlobals.Instance.VesselRangesDefault.flying;
            visibilityRange = Math.Max(unloadRange.unload, highestVisibility) + (furthestDist * 2);
        }
コード例 #5
0
        public static void UpdateRanges(bool updatingFromUi = false)
        {
            Debug.Log("Updating ranges");
            FloatingOrigin.fetch.threshold = Mathf.Pow(PreSettings.GlobalRange * 1000 * 1.20f, 2);

            _globalSituation = new VesselRanges.Situation(
                load: PreSettings.GlobalRange * 1000,
                unload: PreSettings.GlobalRange * 1000 * 1.05f,
                pack: PreSettings.GlobalRange * 1000 * 1.10f,
                unpack: PreSettings.GlobalRange * 1000 * 0.99f);

            _baseRanges = new VesselRanges
            {
                escaping   = _globalSituation,
                flying     = _globalSituation,
                landed     = _globalSituation,
                orbit      = _globalSituation,
                prelaunch  = _globalSituation,
                splashed   = _globalSituation,
                subOrbital = _globalSituation
            };
            ApplyRangesToVessels(updatingFromUi);
        }
コード例 #6
0
        public void UpdateCacheSettings()
        {
            float highestVisibility = 0;
            float furthestDist      = 0;


            for (int i = 0; i < groupInstances.Length; i++)
            {
                if (groupInstances[i].VisibilityRange > highestVisibility)
                {
                    highestVisibility = groupInstances[i].VisibilityRange;
                }

                float dist = Vector3.Distance(centerPoint, groupInstances[i].gameObject.transform.position);

                if (dist > furthestDist)
                {
                    furthestDist = dist;
                }
            }

            VesselRanges.Situation unloadRange = PhysicsGlobals.Instance.VesselRangesDefault.flying;
            visibilityRange = Math.Max(unloadRange.unload, highestVisibility) + (furthestDist * 2);
        }
コード例 #7
0
ファイル: LoadDistanceValue.cs プロジェクト: Whitecaribou/KOS
 public SituationLoadDistanceValue(VesselRanges.Situation situation)
 {
     situationValue = situation;
     InitializeSuffixes();
 }
コード例 #8
0
        private VesselRanges.Situation ClampedSituationLanded(VesselRanges.Situation input, VesselRanges.Situation minSituation)
        {
            float maxLanded = 11000;
            float load = Mathf.Clamp(input.load, minSituation.load, maxLanded*.9f*.9f);
            float unload = Mathf.Clamp(input.unload, minSituation.unload, maxLanded*.9f);
            float pack = Mathf.Clamp(input.pack, minSituation.pack, maxLanded);
            float unpack = Mathf.Clamp(input.unpack, minSituation.unpack, maxLanded*.9f*.9f*.9f);

            VesselRanges.Situation output = new VesselRanges.Situation(load, unload, pack, unpack);
            return output;
        }
コード例 #9
0
        private VesselRanges.Situation ClampedSituation(VesselRanges.Situation input, VesselRanges.Situation minSituation)
        {
            float load = Mathf.Clamp(input.load, minSituation.load, 81000);
            float unload = Mathf.Clamp(input.unload, minSituation.unload, 90000);
            float pack = Mathf.Clamp(input.pack, minSituation.pack, 100000);
            float unpack = Mathf.Clamp(input.unpack, minSituation.unpack, 72900);

            VesselRanges.Situation output = new VesselRanges.Situation(load, unload, pack, unpack);
            return output;
        }
コード例 #10
0
        public void ApplyPhysRange()
        {
            if(!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if(PHYSICS_RANGE <= 2500) PHYSICS_RANGE = 0;

            if(PHYSICS_RANGE > 0)
            {
                float pack = PHYSICS_RANGE;
                float unload = PHYSICS_RANGE * 0.9f;
                float load = unload * 0.9f;
                float unpack = load * 0.9f;

                VesselRanges defaultRanges = PhysicsGlobals.Instance.VesselRangesDefault;
                VesselRanges.Situation combatSituation = new VesselRanges.Situation(load, unload, pack, unpack);

                VesselRanges.Situation combatFlyingSituation = ClampedSituation(combatSituation, defaultRanges.flying);
                VesselRanges.Situation combatLandedSituation = ClampedSituationLanded(combatSituation, defaultRanges.landed);
                VesselRanges.Situation combatSplashedSituation = ClampedSituation(combatSituation, defaultRanges.splashed);
                VesselRanges.Situation combatOrbitSituation = ClampedSituation(combatSituation, defaultRanges.orbit);
                VesselRanges.Situation combatSubOrbitSituation = ClampedSituation(combatSituation, defaultRanges.subOrbital);
                VesselRanges.Situation combatPrelaunchSituation = ClampedSituation(combatSituation, defaultRanges.prelaunch);

                combatVesselRanges.flying = combatFlyingSituation;
                combatVesselRanges.landed = combatLandedSituation;
                combatVesselRanges.splashed = combatSplashedSituation;
                combatVesselRanges.orbit = combatOrbitSituation;
                combatVesselRanges.subOrbital = combatSubOrbitSituation;
                combatVesselRanges.prelaunch = combatPrelaunchSituation;

                foreach(Vessel v in FlightGlobals.Vessels)
                {
                    v.vesselRanges = new VesselRanges(combatVesselRanges);
                }

                FloatingOrigin.fetch.threshold = Mathf.Pow(PHYSICS_RANGE + 3500, 2);
            }
            else
            {
                foreach(Vessel v in FlightGlobals.Vessels)
                {
                    v.vesselRanges = PhysicsGlobals.Instance.VesselRangesDefault;
                }

                FloatingOrigin.fetch.threshold = Mathf.Pow(6000, 2);
            }
        }
コード例 #11
0
        public static void DrawVessel(Vessel shipToDraw)
        {
            if (!vesselIsBuilt[shipToDraw])
            {
                if (DistantObjectSettings.debugMode)
                {
                    print("DistObj: Drawing vessel " + shipToDraw.vesselName);
                }

                vesselIsBuilt[shipToDraw] = true;

                List <ProtoPartSnapshot> partList = shipToDraw.protoVessel.protoPartSnapshots;
                foreach (ProtoPartSnapshot a in partList)
                {
                    string partName;
                    if (a.refTransformName.Contains(" "))
                    {
                        partName = a.partName.Substring(0, a.refTransformName.IndexOf(" "));
                    }
                    else
                    {
                        partName = a.partName;
                    }

                    AvailablePart avPart = PartLoader.getPartInfoByName(partName);

                    if (a.modules.Find(n => n.moduleName == "LaunchClamp") != null)
                    {
                        if (DistantObjectSettings.debugMode)
                        {
                            print("Ignoring part " + partName);
                        }

                        continue;
                    }

                    if (!partModelNameLookup.ContainsKey(partName))
                    {
                        partName = partName.Replace('.', '_');
                        if (!partModelNameLookup.ContainsKey(partName))
                        {
                            if (DistantObjectSettings.debugMode)
                            {
                                print("DistObj ERROR: Could not find config definition for " + partName);
                            }
                            continue;
                        }
                    }

                    GameObject clone = GameDatabase.Instance.GetModel(partModelNameLookup[partName]);
                    if (clone == null)
                    {
                        if (DistantObjectSettings.debugMode)
                        {
                            print("DistObj ERROR: Could not load part model " + partModelNameLookup[partName]);
                        }
                        continue;
                    }
                    GameObject cloneMesh = Mesh.Instantiate(clone) as GameObject;
                    DestroyObject(clone);
                    cloneMesh.transform.SetParent(shipToDraw.transform);
                    cloneMesh.transform.localPosition = a.position;
                    cloneMesh.transform.localRotation = a.rotation;

                    VesselRanges.Situation situation = shipToDraw.vesselRanges.GetSituationRanges(shipToDraw.situation);
                    if (Vector3d.Distance(cloneMesh.transform.position, FlightGlobals.ship_position) < situation.load)
                    {
                        Debug.LogError(Constants.DistantObject + " -- Tried to draw part " + partName + " within rendering distance of active vessel!");
                        continue;
                    }
                    cloneMesh.SetActive(true);

                    foreach (Collider col in cloneMesh.GetComponentsInChildren <Collider>())
                    {
                        col.enabled = false;
                    }

                    //check if part is a solar panel
                    ProtoPartModuleSnapshot solarPanel = a.modules.Find(n => n.moduleName == "ModuleDeployableSolarPanel");
                    if (solarPanel != null)
                    {
                        if (solarPanel.moduleValues.GetValue("stateString") == "EXTENDED")
                        {
                            //grab the animation name specified in the part cfg
                            string animName = avPart.partPrefab.GetComponent <ModuleDeployableSolarPanel>().animationName;
                            //grab the actual animation istelf
                            var animator = avPart.partPrefab.FindModelAnimators();
                            if (animator != null && animator.Length > 0)
                            {
                                AnimationClip animClip = animator[0].GetClip(animName);
                                //grab the animation control module on the actual drawn model
                                Animation anim = cloneMesh.GetComponentInChildren <Animation>();
                                //copy the animation over to the new part!
                                anim.AddClip(animClip, animName);
                                anim[animName].enabled        = true;
                                anim[animName].normalizedTime = 1f;
                            }
                        }
                    }

                    //check if part is a light
                    ProtoPartModuleSnapshot light = a.modules.Find(n => n.moduleName == "ModuleLight");
                    if (light != null)
                    {
                        //Oddly enough the light already renders no matter what, so we'll kill the module if it's suppsed to be turned off
                        if (light.moduleValues.GetValue("isOn") == "False")
                        {
                            Destroy(cloneMesh.GetComponentInChildren <Light>());
                        }
                    }

                    //check if part is a landing gear
                    ProtoPartModuleSnapshot landingGear = a.modules.Find(n => n.moduleName == "ModuleWheelDeployment");
                    if (landingGear != null)
                    {
                        // MOARdV TODO: This wasn't really right to start with.
                        // There is no field "savedAnimationTime".
                        //if (landingGear.moduleValues.GetValue("savedAnimationTime") != "0")
                        {
                            //grab the animation name specified in the part cfg
                            string animName = avPart.partPrefab.GetComponent <ModuleWheels.ModuleWheelDeployment>().animationStateName;
                            var    animator = avPart.partPrefab.FindModelAnimators();
                            if (animator != null && animator.Length > 0)
                            {
                                //grab the actual animation istelf
                                AnimationClip animClip = animator[0].GetClip(animName);
                                //grab the animation control module on the actual drawn model
                                Animation anim = cloneMesh.GetComponentInChildren <Animation>();
                                //copy the animation over to the new part!
                                anim.AddClip(animClip, animName);
                                anim[animName].enabled        = true;
                                anim[animName].normalizedTime = 1f;
                            }
                        }
                    }

                    //check if part has a generic animation
                    ProtoPartModuleSnapshot animGeneric = a.modules.Find(n => n.moduleName == "ModuleAnimateGeneric");
                    if (animGeneric != null)
                    {
                        if (animGeneric.moduleValues.GetValue("animTime") != "0")
                        {
                            //grab the animation name specified in the part cfg
                            string animName = avPart.partPrefab.GetComponent <ModuleAnimateGeneric>().animationName;
                            var    animator = avPart.partPrefab.FindModelAnimators();
                            if (animator != null && animator.Length > 0)
                            {
                                //grab the actual animation istelf
                                AnimationClip animClip = animator[0].GetClip(animName);
                                //grab the animation control module on the actual drawn model
                                Animation anim = cloneMesh.GetComponentInChildren <Animation>();
                                //copy the animation over to the new part!
                                anim.AddClip(animClip, animName);
                                anim[animName].enabled        = true;
                                anim[animName].normalizedTime = 1f;
                            }
                        }
                    }

                    referencePart.Add(cloneMesh, a);
                    meshListLookup[shipToDraw].Add(cloneMesh);
                }
            }
        }
コード例 #12
0
 public SituationLoadDistanceValue(VesselRanges.Situation situation)
 {
     situationValue = situation;
     InitializeSuffixes();
 }
コード例 #13
0
 void LogRanges(string n, VesselRanges.Situation vr)
 {
     Log.Info("LogRanges: " + n + ", load: " + vr.load + ", unload: " + vr.unload + ", pack: " + vr.pack + ", unpack: " + vr.unpack);
 }