Пример #1
0
        /// <summary>
        /// constructor
        /// </summary>
        internal MapDecalInstance()
        {
            gameObject = new GameObject();
            mapDecal   = gameObject.AddComponent <PQSMod_MapDecal>();
            Name       = "KK_MapDecal_" + DecalsDatabase.allMapDecalInstances.Length.ToString();

            mapDecal.radius = 0;

            DecalsDatabase.RegisterMapDecalInstance(this);
        }
        public void OnDestroy()
        {
            if (CanImpact)                                                     //Deform terrain
            {
                mainPQS = attachedTo.mainBody.gameObject.GetComponent <PQS>(); //Just in case...

                print("PlanetUI: Created a nice explosion...");


                PQSMod_MapDecal crater = mainPQS.gameObject.AddComponent <PQSMod_MapDecal>();
                crater.position           = curPos;
                crater.removeScatter      = true;
                crater.radius             = UnityEngine.Random.Range(3000, 6000);
                crater.heightMapDeformity = -UnityEngine.Random.Range(3000, 6000);
                crater.heightMap          = new MapSO();
                crater.heightMap.CreateMap(MapSO.MapDepth.Greyscale, Utils.LoadTexture("GameData/KittopiaSpace/Textures/Default/Crater.png"));
                crater.sphere = mainPQS;

                crater.name = "AsteriodCrater";
                crater.RebuildSphere();
            }
        }
Пример #3
0
 public MapDecal(PQSMod template)
 {
     _mod = template as PQSMod_MapDecal;
     _mod.transform.parent = Utility.Deactivator;
     base.mod = _mod;
 }
Пример #4
0
 public MapDecal()
 {
     // Create the base mod
     GameObject modObject = new GameObject("MapDecal");
     modObject.transform.parent = Utility.Deactivator;
     _mod = modObject.AddComponent<PQSMod_MapDecal>();
     base.mod = _mod;
 }
Пример #5
0
        static bool PatchPQS(CelestialBody body, ConfigNode node, double origRadius)
        {
            List <string> PQSs     = new List <string>();
            bool          modified = false;
            bool          custom   = false;

            if (node != null && node.HasNode("PQS"))
            {
                foreach (ConfigNode n in node.GetNode("PQS").nodes)
                {
                    PQSs.Add(n.name);
                }
                custom = true;
            }
            else
            {
                if (body.Radius != origRadius)
                {
                    PQSs.Add(body.bodyName);
                    PQSs.Add(body.bodyName + "Ocean");
                }
            }
            foreach (string pName in PQSs)
            {
                print("**Patching PQS " + pName);
                // yeah, slow, but juuuuuuuuust in case.
                foreach (PQS p in Resources.FindObjectsOfTypeAll(typeof(PQS)))
                {
                    if (p.name.Equals(pName))
                    {
                        /*if (body.pqsController != p)
                         *  if (body.pqsController != p.parentSphere)
                         *      continue;*/
                        if (p.radius != body.Radius)
                        {
                            modified = true;
                        }

                        p.radius = body.Radius;
                        // do nothing yet, because I don't want to copy-paste all my code
                        var mods = p.transform.GetComponentsInChildren(typeof(PQSMod), true);
                        // rebuilding should catch it, but...
                        foreach (var m in mods)
                        {
                            if (m is PQSCity)
                            {
                                PQSCity mod = (PQSCity)m;
                                try
                                {
                                    mod.OnSetup();
                                    mod.OnPostSetup();
                                }
                                catch
                                {
                                }
                                //SpaceCenter.Instance.transform.localPosition = mod.transform.localPosition;
                                //SpaceCenter.Instance.transform.localRotation = mod.transform.localRotation;
                            }
                            if (m is PQSMod_MapDecal)
                            {
                                PQSMod_MapDecal mod = (PQSMod_MapDecal)m;
                                mod.radius   *= globalRescale;
                                mod.position *= (float)globalRescale;
                                try
                                {
                                    mod.OnSetup();
                                    mod.OnPostSetup();
                                }
                                catch
                                {
                                }
                            }
                            if (m is PQSMod_MapDecalTangent)
                            {
                                PQSMod_MapDecalTangent mod = (PQSMod_MapDecalTangent)m;
                                mod.radius   *= globalRescale;
                                mod.position *= (float)globalRescale;
                                try
                                {
                                    mod.OnSetup();
                                    mod.OnPostSetup();
                                }
                                catch
                                {
                                }
                            }
                        }
                        try
                        {
                            p.RebuildSphere();
                        }
                        catch (Exception e)
                        {
                            print("Rebuild sphere for " + node.name + " failed: " + e.Message);
                        }
                    }
                }
            }
            return(modified);
        }