Пример #1
0
        public override void MapComponentTick()
        {
            if (speciality == null)
            {
                return;
            }
            IntVec3 place;

            if (speciality.AnimalSpeciality != null && Find.TickManager.TicksGame % 1210 == 0 && Rand.Value < 0.0268888883f * map.wildSpawner.DesiredAnimalDensity(map) * (1 + pawnExtraSpawn) && RCellFinder.TryFindRandomPawnEntryCell(out place, this.map, CellFinder.EdgeRoadChance_Animal, null))
            {
                spawnAnimalsAt(place);
            }
            ThingDef plantDef = speciality.PlantSpeciality;

            if (plantDef != null)
            {
                float num = map.gameConditionManager.AggregatePlantDensityFactor();
                if (num > 0.0001f)
                {
                    int   num2 = map.Size.x * 2 + map.Size.z * 2;
                    float num3 = 650f / ((float)num2 / 100f);
                    int   num4 = (int)(num3 / num);
                    if (num4 <= 0 || Find.TickManager.TicksGame % num4 == 0)
                    {
                        if (RCellFinder.TryFindRandomCellToPlantInFromOffMap(plantDef, map, out place))
                        {
                            GenPlantReproduction.TryReproduceFrom(place, plantDef, SeedTargFindMode.MapEdge, map);
                        }
                    }
                }
            }
        }
 public override void TickLong()
 {
     CheckTemperatureMakeLeafless();
     if (Destroyed)
     {
         return;
     }
     if (GrowthSeasonNow(Position, Map))
     {
         if (!HasEnoughLightToGrow)
         {
             unlitTicks += 2000;
         }
         else
         {
             unlitTicks = 0;
         }
         float num  = growthInt;
         bool  flag = LifeStage == PlantLifeStage.Mature;
         growthInt += GrowthPerTick * 2000f;
         if (growthInt > 1f)
         {
             growthInt = 1f;
         }
         if (((!flag && LifeStage == PlantLifeStage.Mature) || (int)(num * 10f) != (int)(growthInt * 10f)) && CurrentlyCultivated())
         {
             Map.mapDrawer.MapMeshDirty(Position, MapMeshFlag.Things);
         }
         if (def.plant.LimitedLifespan)
         {
             ageInt += 2000;
             if (Dying)
             {
                 Map  map    = Map;
                 bool isCrop = IsCrop;
                 int  amount = Mathf.CeilToInt(10f);
                 TakeDamage(new DamageInfo(DamageDefOf.Rotting, amount, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
                 if (Destroyed)
                 {
                     if (isCrop && def.plant.Harvestable && MessagesRepeatAvoider.MessageShowAllowed("MessagePlantDiedOfRot-" + def.defName, 240f))
                     {
                         Messages.Message("MessagePlantDiedOfRot".Translate(new object[]
                         {
                             Label
                         }).CapitalizeFirst(), new TargetInfo(Position, map, false), MessageTypeDefOf.NegativeEvent);
                     }
                     return;
                 }
             }
         }
         if (def.plant.reproduces && growthInt >= 0.6f && Rand.MTBEventOccurs(def.plant.reproduceMtbDays, 60000f, 2000f))
         {
             if (!GenPlant.SnowAllowsPlanting(Position, Map))
             {
                 return;
             }
             GenPlantReproduction.TryReproduceFrom(Position, def, SeedTargFindMode.Reproduce, Map);
         }
     }
     hardyCachedLabelMouseover = null;
 }