Пример #1
0
        public static void Postfix(Plant __instance, ThingDef parentDef)
        {
            if (__instance.def.HasModExtension <ThingWeatherReaction>())
            {
                ThingWeatherReaction mod = __instance.def.GetModExtension <ThingWeatherReaction>();

                if (!mod.frostGraphicPath.NullOrEmpty())
                {
                    string id = __instance.def.defName + "frost";
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        __instance.Map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, mod.frostGraphicPath, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                    });
                }
                if (!mod.droughtGraphicPath.NullOrEmpty())
                {
                    string id = __instance.def.defName + "drought";
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        __instance.Map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, mod.droughtGraphicPath, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                    });
                }
                if (!mod.floweringGraphicPath.NullOrEmpty())
                {
                    string id = __instance.def.defName + "flowering";
                    LongEventHandler.ExecuteWhenFinished(delegate
                    {
                        __instance.Map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, mod.floweringGraphicPath, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                    });
                }
            }
        }
        public bool canPutOnTerrain(IntVec3 c, ThingDef thingDef, Map map)
        {
            TerrainDef terrain = c.GetTerrain(map);

            //make sure plants are spawning on terrain that they're limited to:
            ThingWeatherReaction weatherReaction = thingDef.GetModExtension <ThingWeatherReaction>();

            if (weatherReaction != null && terrain != null && weatherReaction.allowedTerrains != null)
            {
                //if they're only allowed to spawn in certain terrains, stop it from spawning.
                if (!weatherReaction.allowedTerrains.Contains(terrain))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #3
0
        private void clearLoot()
        {
            if (!location.IsValid)
            {
                return;
            }
            List <Thing>  things = location.GetThingList(this.map);
            List <string> remove = new List <string>()
            {
                "FilthSlime",
                "TKKN_FilthShells",
                "TKKN_FilthPuddle",
                "TKKN_FilthSeaweed",
                "TKKN_FilthDriftwood",
                "TKKN_Sculpture_Shell",
                "Kibble",
                "Steel",
                "Cloth",
                "WoodLog",
                "Synthread",
                "Hyperweave",
                "Kibble",
                "SimpleProstheticLeg",
                "MedicineIndustrial",
                "ComponentIndustrial",
                "Neutroamine",
                "Chemfuel",
                "MealSurvivalPack",
                "Pemmican",
                "Silver",
                "Plasteel",
                "Gold",
                "Uranium",
                "Jade",
                "Heart",
                "Lung",
                "BionicEye",
                "ScytherBlade",
                "ElephantTusk",
                "AIPersonaCore",
                "MechSerumHealer",
                "MechSerumNeurotrainer",
                "ComponentSpacer",
                "MedicineUltratech",
                "ThrumboHorn",
            };

            for (int i = things.Count - 1; i >= 0; i--)
            {
                if (remove.Contains(things[i].def.defName))
                {
                    things[i].Destroy();
                    continue;
                }

                //remove any plants that might've grown:
                Plant plant = things[i] as Plant;;
                if (plant != null)
                {
                    if (plant.def.HasModExtension <ThingWeatherReaction>())
                    {
                        TerrainDef           terrain      = currentTerrain;
                        ThingWeatherReaction thingWeather = plant.def.GetModExtension <ThingWeatherReaction>();
                        List <TerrainDef>    okTerrains   = thingWeather.allowedTerrains;
                        if (!okTerrains.Contains <TerrainDef>(currentTerrain))
                        {
                            Log.Warning("Destroying " + plant.def.defName + " at " + location.ToString() + " on " + currentTerrain.defName);
                            plant.Destroy();
                        }
                    }
                    else
                    {
                        plant.Destroy();
                    }
                }
            }
        }
Пример #4
0
        private void leaveLoot()
        {
            float leaveSomething = Rand.Value;

            if (leaveSomething < 0.001f)
            {
                float         leaveWhat = Rand.Value;
                List <string> allowed   = new List <string>();
                if (leaveWhat > 0.1f)
                {
                    //leave trash;
                    allowed = new List <string>
                    {
                        "Filth_Slime",
                        "TKKN_FilthShells",
                        "TKKN_FilthPuddle",
                        "TKKN_FilthSeaweed",
                        "TKKN_FilthDriftwood",
                        "TKKN_Sculpture_Shell",
                        "Kibble",
                        "EggRoeFertilized",
                        "EggRoeUnfertilized",
                    };
                }
                else if (leaveWhat > 0.05f)
                {
                    //leave resource;
                    allowed = new List <string>
                    {
                        "Steel",
                        "Cloth",
                        "WoodLog",
                        "Synthread",
                        "Hyperweave",
                        "Kibble",
                        "SimpleProstheticLeg",
                        "MedicineIndustrial",
                        "ComponentIndustrial",
                        "Neutroamine",
                        "Chemfuel",
                        "MealSurvivalPack",
                        "Pemmican",
                    };
                }
                else if (leaveWhat > 0.03f)
                {
                    // leave treasure.
                    allowed = new List <string>
                    {
                        "Silver",
                        "Plasteel",
                        "Gold",
                        "Uranium",
                        "Jade",
                        "Heart",
                        "Lung",
                        "BionicEye",
                        "ScytherBlade",
                        "ElephantTusk",
                    };

                    string text = "TKKN_NPS_TreasureWashedUpText".Translate();
                    Messages.Message(text, MessageTypeDefOf.NeutralEvent);
                }
                else if (leaveWhat > 0.02f)
                {
                    //leave ultrarare
                    allowed = new List <string>
                    {
                        "AIPersonaCore",
                        "MechSerumHealer",
                        "MechSerumNeurotrainer",
                        "ComponentSpacer",
                        "MedicineUltratech",
                        "ThrumboHorn",
                    };
                    string text = "TKKN_NPS_UltraRareWashedUpText".Translate();
                    Messages.Message(text, MessageTypeDefOf.NeutralEvent);
                }
                if (allowed.Count > 0)
                {
                    int   leaveWhat2 = Rand.Range(1, allowed.Count) - 1;
                    Thing loot       = ThingMaker.MakeThing(ThingDef.Named(allowed[leaveWhat2]), null);
                    if (loot != null)
                    {
                        GenSpawn.Spawn(loot, location, this.map);
                    }
                    else
                    {
                        //	Log.Error(allowed[leaveWhat2]);
                    }
                }
            }
            else

            //grow water and shore plants:
            if (leaveSomething < 0.002f && location.GetPlant(map) == null && location.GetCover(this.map) == null)
            {
                List <ThingDef> plants = this.map.Biome.AllWildPlants;
                for (int i = plants.Count - 1; i >= 0; i--)
                {
                    //spawn some water plants:
                    ThingDef plantDef = plants[i];
                    if (plantDef.HasModExtension <ThingWeatherReaction>())
                    {
                        TerrainDef           terrain      = currentTerrain;
                        ThingWeatherReaction thingWeather = plantDef.GetModExtension <ThingWeatherReaction>();
                        List <TerrainDef>    okTerrains   = thingWeather.allowedTerrains;
                        if (okTerrains != null && okTerrains.Contains <TerrainDef>(currentTerrain))
                        {
                            Plant plant = (Plant)ThingMaker.MakeThing(plantDef, null);
                            plant.Growth = Rand.Range(0.07f, 1f);
                            if (plant.def.plant.LimitedLifespan)
                            {
                                plant.Age = Rand.Range(0, Mathf.Max(plant.def.plant.LifespanTicks - 50, 0));
                            }
                            GenSpawn.Spawn(plant, location, map);
                            break;
                        }
                    }
                }
            }
        }
Пример #5
0
        public static void Postfix(Plant __instance, ref Graphic __result)
        {
            string id = __instance.def.defName;

            if (!__instance.def.HasModExtension <ThingWeatherReaction>())
            {
                return;
            }

            ThingWeatherReaction mod = __instance.def.GetModExtension <ThingWeatherReaction>();
            Map map = __instance.Map;

            string path = "";

            //get flowering or drought graphic if it's over 70
            if (__instance.AmbientTemperature > 21)
            {
                Watcher  watcher = map.GetComponent <Watcher>();
                cellData cell;
                if (watcher.cellWeatherAffects[__instance.Position] != null)
                {
                    cell = watcher.cellWeatherAffects[__instance.Position];
                    Vector2 location = Find.WorldGrid.LongLatOf(__instance.MapHeld.Tile);
                    Season  season   = GenDate.Season((long)Find.TickManager.TicksAbs, location);

                    if (!String.IsNullOrEmpty(mod.floweringGraphicPath) && ((cell.howWetPlants > 60 && map.weatherManager.RainRate <= .001f) || season == Season.Spring))
                    {
                        id  += "flowering";
                        path = mod.floweringGraphicPath;
                    }

                    if (!String.IsNullOrEmpty(mod.droughtGraphicPath) && cell.howWetPlants < 20)
                    {
                        id  += "drought";
                        path = mod.droughtGraphicPath;
                    }
                    else
                    if (__instance.def.plant.leaflessGraphic != null && cell.howWetPlants < 20)
                    {
                        id  += "drought";
                        path = __instance.def.plant.leaflessGraphic.path;
                    }
                }
            }
            if (path != "")
            {
                if (!map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    //only load the image once.
                    map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                }
                if (map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    __result = map.GetComponent <Watcher>().graphicHolder[id];
                }
                return;
            }

            if (Settings.showCold)
            {
                //get snow graphic
                if (map.snowGrid.GetDepth(__instance.Position) >= 0.5f)
                {
                    if (!String.IsNullOrEmpty(mod.snowGraphicPath))
                    {
                        id  += "snow";
                        path = mod.snowGraphicPath;
                    }
                }
                else if (map.GetComponent <FrostGrid>().GetDepth(__instance.Position) >= 0.6f)
                {
                    if (!String.IsNullOrEmpty(mod.frostGraphicPath))
                    {
                        id  += "frost";
                        path = mod.frostGraphicPath;
                    }
                }

                if (String.IsNullOrEmpty(path))
                {
                    return;
                }
                //if it's leafless
                if (__instance.def.plant.leaflessGraphic == __result)
                {
                    id   += "leafless";
                    path  = path.Replace("Frosted", "Frosted/Leafless");
                    path  = path.Replace("Snow", "Snow/Leafless");
                    path += "_Leafless";
                }
                else if (__instance.def.blockWind)
                {
                    //make it so snow doesn't fall under the tree until it's leafless.
                    //	map.snowGrid.AddDepth(__instance.Position, -.05f);
                }
            }


            if (!map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
            {
                //only load the image once.
                map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
            }
            if (map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
            {
                __result = map.GetComponent <Watcher>().graphicHolder[id];
            }
            return;
        }
Пример #6
0
            public static void Postfix(Plant __instance, ref Graphic __result)
            {
                //return;
                if (!Settings.showCold)
                {
                    return;
                }
                string id = __instance.def.defName;

                if (!__instance.def.HasModExtension <ThingWeatherReaction>())
                {
                    return;
                }

                ThingWeatherReaction mod = __instance.def.GetModExtension <ThingWeatherReaction>();

                string path = "";

                //get snow graphic
                if (__instance.Map.snowGrid.GetDepth(__instance.Position) >= 0.5f)
                {
                    if (!String.IsNullOrEmpty(mod.snowGraphicPath))
                    {
                        id  += "snow";
                        path = mod.snowGraphicPath;
                    }
                }
                else if (__instance.Map.GetComponent <FrostGrid>().GetDepth(__instance.Position) >= 0.6f)
                {
                    if (!String.IsNullOrEmpty(mod.frostGraphicPath))
                    {
                        id  += "frost";
                        path = mod.frostGraphicPath;
                    }
                }

                if (String.IsNullOrEmpty(path))
                {
                    return;
                }
                //if it's leafless
                if (__instance.def.plant.leaflessGraphic == __result)
                {
                    id   += "leafless";
                    path  = path.Replace("Frosted", "Frosted/Leafless");
                    path  = path.Replace("Snow", "Snow/Leafless");
                    path += "_Leafless";
                }
                else if (__instance.def.blockWind)
                {
                    //make it so snow doesn't fall under the tree until it's leafless.
                    //	__instance.Map.snowGrid.AddDepth(__instance.Position, -.05f);
                }


                if (!__instance.Map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    //only load the image once.
                    __instance.Map.GetComponent <Watcher>().graphicHolder.Add(id, GraphicDatabase.Get(__instance.def.graphicData.graphicClass, path, __instance.def.graphic.Shader, __instance.def.graphicData.drawSize, __instance.def.graphicData.color, __instance.def.graphicData.colorTwo));
                }
                if (__instance.Map.GetComponent <Watcher>().graphicHolder.ContainsKey(id))
                {
                    //only load the image once.
                    __result = __instance.Map.GetComponent <Watcher>().graphicHolder[id];
                }
            }