예제 #1
0
 internal static void Postfix(ref bool __result, IntVec3 c, ThingDef plantDef, Map map)
 {
     if (__result && plantDef.HasModExtension <DM_ModExtension>())
     {
         DM_ModExtension ext  = plantDef.GetModExtension <DM_ModExtension>();
         Tile            tile = Find.WorldGrid[map.Tile];
         Log.Message("rainrate is " + map.weatherManager.curWeather.rainRate);
         if (tile.rainfall < ext.minRainfall || tile.rainfall > ext.maxRainfall || tile.temperature < ext.minTemperature || tile.temperature > ext.maxTemperature)
         {
             __result = false;
             return;
         }
         if (ext.needsRain && map.weatherManager.curWeather.rainRate < 1)
         {
             __result = false;
             return;
         }
         if (__result == false)
         {
             return;
         }
         if (ext.needsRain && map.weatherManager.curWeather.rainRate >= 1)
         {
             GenSpawn.Spawn(plantDef, c, map);
             __result = false;
         }
     }
 }
예제 #2
0
        internal static void Postfix(ref float __result, Map ___map, ThingDef plant)
        {
            if (!plant.HasModExtension <DM_ModExtension>())
            {
                return;
            }
            DM_ModExtension ext = plant.GetModExtension <DM_ModExtension>();

            if (SeasonUtility.GetPreviousSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInPreviousSeason)
            {
                __result = (ext.commonality / 2);
                return;
            }
            __result = ext.commonality;
        }
예제 #3
0
        internal static void Postfix(IntVec3 c, Map ___map, List <ThingDef> outPlants)
        {
            List <ThingDef> thingDefs = DefDatabase <ThingDef> .AllDefsListForReading;

            foreach (ThingDef thingDef in thingDefs.Where(x => x.HasModExtension <DM_ModExtension>()))
            {
                outPlants.Remove(thingDef);
                DM_ModExtension ext = thingDef.GetModExtension <DM_ModExtension>();
                if (!thingDef.CanEverPlantAt_NewTemp(c, ___map))
                {
                    return;
                }
                if (GenLocalDate.Season(___map) == ext.season || (SeasonUtility.GetPreviousSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInPreviousSeason) || (DMSeasonUtility.GetNextSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInNextSeason))
                {
                    outPlants.Add(thingDef);
                }
            }
        }
예제 #4
0
        // If a plant has a max harvest growth, reduce yield the older it gets.
        public override int YieldNow()
        {
            if (!CanYieldNow())
            {
                return(0);
            }
            float           harvestYield = def.plant.harvestYield;
            float           num;
            DM_ModExtension ext = def.GetModExtension <DM_ModExtension>();

            if (ext != null && ext.harvestMaxGrowth != null)
            {
                num = Mathf.InverseLerp((float)ext.harvestMaxGrowth, def.plant.harvestMinGrowth, growthInt);
            }
            else
            {
                num = Mathf.InverseLerp(def.plant.harvestMinGrowth, 1f, growthInt);
            }
            num = 0.5f + num * 0.5f;
            return(GenMath.RoundRandom(harvestYield * num * Mathf.Lerp(0.5f, 1f, (float)HitPoints / (float)base.MaxHitPoints) * Find.Storyteller.difficultyValues.cropYieldFactor));
        }