コード例 #1
0
        // Load config file of planets to add, 1 per line (planet type, row, column)
        public List <Tuple <SpaceDestinationType, int, int> > LoadConfig()
        {
            // List to hold planets
            List <Tuple <SpaceDestinationType, int, int> > planets = new List <Tuple <SpaceDestinationType, int, int> >();

            // Create path to the config file
            string fileName = Path.Combine(this.path, "config.txt");

            // Read all the lines
            if (File.Exists(fileName))
            {
                string[] lines = File.ReadAllLines(fileName, Encoding.UTF8);

                // Get the list of destination types for converting the text names from the config
                SpaceDestinationTypes spaceDestinationTypes = Db.Get().SpaceDestinationTypes;

                // Copy in each planet to add, 1 per line in format (type, row)
                foreach (string line in lines)
                {
                    // Split around comma
                    string[] parts = line.Split(',');

                    // Convert the text and get the type
                    SpaceDestinationType spaceDestinationType = convertSpaceDestinationType(spaceDestinationTypes, parts[0]);

                    // Add the type and the row number
                    planets.Add(new Tuple <SpaceDestinationType, int, int>(spaceDestinationType, int.Parse(parts[1]), int.Parse(parts[2])));
                }
            }

            return(planets);
        }
コード例 #2
0
        public static string GetNotificationColor(this SpaceDestinationType type)
        {
            var mappings = new Dictionary <string, string>
            {
                { Db.Get().SpaceDestinationTypes.Wormhole.Id, "ED2DFE" },
                { Db.Get().SpaceDestinationTypes.RedDwarf.Id, "D32F2F" }
            };

            mappings.TryGetValue(type.Id, out var color);
            return(color ?? "FFC107");
        }
コード例 #3
0
            public static void Postfix()
            {
                SpaceDestinationType dustyMoon = Db.Get().SpaceDestinationTypes.DustyMoon;

                if (dustyMoon.recoverableEntities == null)
                {
                    dustyMoon.recoverableEntities = new System.Collections.Generic.Dictionary <string, int>();
                }
                if (!dustyMoon.recoverableEntities.ContainsKey("Mole"))
                {
                    dustyMoon.recoverableEntities.Add("Mole", 2);
                }
            }
コード例 #4
0
        public static Notification GetNotification(this SpaceDestinationType type,
                                                   NotificationType notificationType = NotificationType.Good,
                                                   string group = "SDT")
        {
            var color = type.GetNotificationColor();
            var title = string.Format(UI.STARMAP.ANALYSIS_AMOUNT.text,
                                      $" <color=#{color}><b>{type.Name}</b></color>");
            var notification = new Notification(
                title,
                notificationType,
                group,
                (list, o) => type.description);

            return(notification);
        }
コード例 #5
0
        private static void CloneArtifactDropRateTable(SpaceDestinationType destination, ArtifactTier tier, float weight_percent)
        {
            var   result = new ArtifactDropRate();
            float weight = destination.artifactDropTable.totalWeight * weight_percent;

            foreach (var rate in destination.artifactDropTable.rates)
            {
                if (rate.first == DECOR.SPACEARTIFACT.TIER_NONE)
                {
                    result.AddItem(rate.first, rate.second - weight);
                }
                else
                {
                    result.AddItem(rate.first, rate.second);
                }
            }
            result.AddItem(tier, weight);
            destination.artifactDropTable = result;
        }
コード例 #6
0
        public MySpaceDestinationTypes(ResourceSet parent) : base(parent)
        {
            destinationDictionary = new Dictionary <string, SpaceDestinationType>();
            foreach (var dest in resources)
            {
                destinationDictionary.Add(dest.Id, dest);
            }
            //flush out the old resources now that they have been added
            resources.Clear();

            var planetDefs = new Dictionary <string, JConfig.PlanetDefinition>();

            foreach (string planetDefString in JConfig.ReadPlanetFiles())
            {
                JConfig.PlanetDefinition pDef = JsonConvert.DeserializeObject <JConfig.PlanetDefinition>(planetDefString);

                bool isNew = !destinationDictionary.ContainsKey(pDef.ID);

                //Debug.Log("pDef: " + pDef.ID + " table: ");
                //foreach (var kvpair in pDef.elementTable)
                //    Debug.Log("element: " + kvpair.Key + " min: "+kvpair.Value.min+" max: "+kvpair.Value.max);

                planetDefs.Add(pDef.ID, pDef);
                ArtifactDropRate artifactDropRate = null;
                switch (pDef.artifactDropRate)
                {
                case "Bad":
                    artifactDropRate = Db.Get().ArtifactDropRates.Bad;
                    break;

                case "Mediocre":
                    artifactDropRate = Db.Get().ArtifactDropRates.Mediocre;
                    break;

                case "Good":
                    artifactDropRate = Db.Get().ArtifactDropRates.Good;
                    break;

                case "Great":
                    artifactDropRate = Db.Get().ArtifactDropRates.Great;
                    break;

                case "Amazing":
                    artifactDropRate = Db.Get().ArtifactDropRates.Amazing;
                    break;

                case "Perfect":
                    artifactDropRate = Db.Get().ArtifactDropRates.Perfect;
                    break;

                case null:
                    if (isNew)
                    {
                        artifactDropRate = Db.Get().ArtifactDropRates.Bad;
                    }
                    break;
                }
                SpaceDestinationType planet;
                if (isNew)
                {
                    //If planet is new, create new definition
                    planet = new SpaceDestinationType(pDef.ID, parent, pDef.typeName, pDef.description, pDef.iconSize, pDef.spriteName, JConfig.convertElementTable(pDef.elementTable), pDef.recoverableEntities, artifactDropRate);

                    destinationDictionary.Add(pDef.ID, planet);
                }
                else
                {
                    planet = destinationDictionary[pDef.ID];
                    if (pDef.description != null)
                    {
                        destinationDictionary[pDef.ID].description = pDef.description;
                    }
                    if (pDef.iconSize != 0)
                    {
                        destinationDictionary[pDef.ID].iconSize = pDef.iconSize;
                    }
                    if (pDef.spriteName != null)
                    {
                        destinationDictionary[pDef.ID].spriteName = pDef.spriteName;
                    }
                    if (pDef.elementTable != null)
                    {
                        destinationDictionary[pDef.ID].elementTable = JConfig.convertElementTable(pDef.elementTable);
                    }
                    if (pDef.recoverableEntities != null)
                    {
                        destinationDictionary[pDef.ID].recoverableEntities = pDef.recoverableEntities;
                    }
                    if (artifactDropRate != null)
                    {
                        destinationDictionary[pDef.ID].artifactDropTable = artifactDropRate;
                    }
                }

                base.Add(planet);
            }
            if (planetDefs.Count == 0)
            {
                Debug.Log("PlanetaryCustomization: Could not find any planet definitions!");
            }
            else
            {
                Debug.Log("PlanetaryCustomization: Loaded " + planetDefs.Count + " planet definitions!");
            }

            //create destination pools for random planet rolls
            destPools = new List <List <string> >();
            for (double dist = 9999.0; dist < 110001.0; dist += 10000.0)
            {
                var distPool = new List <string>();

                foreach (var pDef in planetDefs)
                {
                    if (pDef.Value.distanceRange.min < dist && pDef.Value.distanceRange.max > dist)
                    {
                        distPool.Add(pDef.Value.ID);
                    }
                }

                destPools.Add(distPool);
            }

            /*
             * //This exists for compatibility reasons so mods that modify existing planets _maybe_ don't get screwed (please don't smack me Cairath :( )
             * base.Satellite = destinationDictionary["Satellite"];
             *
             * base.MetallicAsteroid = destinationDictionary["MetallicAsteroid"];
             *
             * base.RockyAsteroid = destinationDictionary["RockyAsteroid"];
             *
             * base.CarbonaceousAsteroid = destinationDictionary["CarbonaceousAsteroid"];
             *
             * base.IcyDwarf = destinationDictionary["IcyDwarf"];
             *
             * base.OrganicDwarf = destinationDictionary["OrganicDwarf"];
             *
             * base.DustyMoon = destinationDictionary["DustyMoon"];
             *
             * base.TerraPlanet = destinationDictionary["TerraPlanet"];
             *
             * base.VolcanoPlanet = destinationDictionary["VolcanoPlanet"];
             *
             * base.GasGiant = destinationDictionary["GasGiant"];
             *
             * base.IceGiant = destinationDictionary["IceGiant"];*/
        }
コード例 #7
0
        // Converts text names of planets to their types
        private static SpaceDestinationType convertSpaceDestinationType(SpaceDestinationTypes spaceDestinationTypes, String destinationType)
        {
            SpaceDestinationType spaceDestinationType = null;

            switch (destinationType)
            {
            case "Satellite":
                spaceDestinationType = spaceDestinationTypes.Satellite;
                break;

            case "MetallicAsteroid":
                spaceDestinationType = spaceDestinationTypes.MetallicAsteroid;
                break;

            case "RockyAsteroid":
                spaceDestinationType = spaceDestinationTypes.RockyAsteroid;
                break;

            case "CarbonaceousAsteroid":
                spaceDestinationType = spaceDestinationTypes.CarbonaceousAsteroid;
                break;

            case "IcyDwarf":
                spaceDestinationType = spaceDestinationTypes.IcyDwarf;
                break;

            case "OrganicDwarf":
                spaceDestinationType = spaceDestinationTypes.OrganicDwarf;
                break;

            case "TerraPlanet":
                spaceDestinationType = spaceDestinationTypes.TerraPlanet;
                break;

            case "VolcanoPlanet":
                spaceDestinationType = spaceDestinationTypes.VolcanoPlanet;
                break;

            case "GasGiant":
                spaceDestinationType = spaceDestinationTypes.GasGiant;
                break;

            case "IceGiant":
                spaceDestinationType = spaceDestinationTypes.IceGiant;
                break;

            case "DustyDwarf":
                spaceDestinationType = spaceDestinationTypes.DustyMoon;
                break;

            case "Wormhole":
                spaceDestinationType = spaceDestinationTypes.Wormhole;
                break;

            case "SaltDwarf":
                spaceDestinationType = spaceDestinationTypes.SaltDwarf;
                break;

            case "RustPlanet":
                spaceDestinationType = spaceDestinationTypes.RustPlanet;
                break;

            case "ForestPlanet":
                spaceDestinationType = spaceDestinationTypes.ForestPlanet;
                break;

            case "RedDwarf":
                spaceDestinationType = spaceDestinationTypes.RedDwarf;
                break;

            case "GoldAsteroid":
                spaceDestinationType = spaceDestinationTypes.GoldAsteroid;
                break;

            case "HydrogenGiant":
                spaceDestinationType = spaceDestinationTypes.HydrogenGiant;
                break;

            case "OilyAsteroid":
                spaceDestinationType = spaceDestinationTypes.OilyAsteroid;
                break;

            case "ShinyPlanet":
                spaceDestinationType = spaceDestinationTypes.ShinyPlanet;
                break;

            case "ChlorinePlanet":
                spaceDestinationType = spaceDestinationTypes.ChlorinePlanet;
                break;

            case "SaltDesertPlanet":
                spaceDestinationType = spaceDestinationTypes.SaltDesertPlanet;
                break;

            case "Earth":
                spaceDestinationType = spaceDestinationTypes.Earth;
                break;
            }
            return(spaceDestinationType);
        }