void ApplyInputStrings()
        {
            //selectedGroup.RefLatitude = double.Parse(refLat);
            //selectedGroup.RefLongitude = double.Parse(refLng);

            selectedGroup.RadialPosition = KKMath.GetRadiadFromLatLng(selectedGroup.CelestialBody, selectedGroup.RefLatitude, selectedGroup.RefLongitude);

            float oldRotation = selectedGroup.RotationAngle;

            //float tgtheading = float.Parse(headingStr);
            //float diffHeading = (tgtheading - selectedGroup.heading);

            //selectedGroup.RotationAngle = oldRotation + diffHeading;

            ApplySettings();

            //selectedGroup.RefLatitude = double.Parse(refLat);
            //selectedGroup.RefLongitude = double.Parse(refLng);
        }
Example #2
0
        public static string PlaceStatic(string modelName, string bodyName, double lat, double lng, float alt, float rotation, bool isScanable = false)
        {
            StaticModel model = StaticDatabase.GetModelByName(modelName);

            if (model != null)
            {
                StaticInstance instance = new StaticInstance();
                instance.isInSavegame = true;

                instance.heighReference = HeightReference.Terrain;

                instance.gameObject      = UnityEngine.Object.Instantiate(model.prefab);
                instance.RadiusOffset    = alt;
                instance.CelestialBody   = ConfigUtil.GetCelestialBody(bodyName);
                instance.Group           = "Ungrouped";
                instance.RadialPosition  = KKMath.GetRadiadFromLatLng(instance.CelestialBody, lat, lng);
                instance.RotationAngle   = rotation;
                instance.Orientation     = Vector3.up;
                instance.VisibilityRange = (PhysicsGlobals.Instance.VesselRangesDefault.flying.unload + 3000);
                instance.RefLatitude     = lat;
                instance.RefLongitude    = lng;

                instance.model      = model;
                instance.configPath = null;
                instance.configUrl  = null;

                instance.isScanable = isScanable;

                instance.SpawnObject();

                return(instance.UUID);
            }

            Log.UserError("API:PlaceStatic: StaticModel not found in Database: " + modelName);
            return(null);
        }
        internal static void AddPQSCenter2(string tgtName)
        {
            CelestialBody body   = ConfigUtil.GetCelestialBody("HomeWorld");
            var           mods   = body.pqsController.GetComponentsInChildren <PQSCity2>(true);
            PQSCity2      tgtPQS = null;

            foreach (var m in mods)
            {
                //Log.Normal("PQS2Name: " + m.name);
                if (m.name == tgtName)
                {
                    tgtPQS = m;
                    continue;
                }
            }
            if (tgtPQS == null)
            {
                Log.Normal("No BasePQS found: " + tgtName);
                return;
            }

            GroupCenter newGroup = new GroupCenter();

            newGroup.isBuiltIn     = true;
            newGroup.Group         = tgtName + "_Builtin";
            newGroup.CelestialBody = body;

            newGroup.RotationAngle  = (float)tgtPQS.rotation;
            newGroup.RadialPosition = KKMath.GetRadiadFromLatLng(body, tgtPQS.lat, tgtPQS.lon);

            //newGroup.RadiusOffset = (float)0;
            newGroup.RadiusOffset        = (float)tgtPQS.alt;
            newGroup.SeaLevelAsReference = true;
            //newGroup.repositionToSphere = tgtPQS.repositionToSphere;
            newGroup.Spawn();
        }