IsTemperatureConditionOkAt() 공개 정적인 메소드

public static IsTemperatureConditionOkAt ( ThingDef_ClusterPlant plantDef, IntVec3 position ) : bool
plantDef ThingDef_ClusterPlant
position IntVec3
리턴 bool
예제 #1
0
파일: Cluster.cs 프로젝트: smileve/Rimworld
        public override void TickLong()
        {
            // Grow cluster and spawn symbiosis cluster.
            if ((Find.TickManager.TicksGame > this.nextGrownTick) &&
                ClusterPlant.IsTemperatureConditionOkAt(this.plantDef, this.Map, this.Position) &&
                ClusterPlant.IsLightConditionOkAt(this.plantDef, this.Map, this.Position))
            {
                this.nextGrownTick = Find.TickManager.TicksGame + (int)(this.plantDef.plant.reproduceMtbDays * GenDate.TicksPerDay);

                // Grow cluster.
                GenClusterPlantReproduction.TryGrowCluster(this);

                // Spawn symbiosis cluster.
                if ((this.actualSize == this.desiredSize) &&
                    (this.plantDef.symbiosisPlantDefEvolution != null))
                {
                    GenClusterPlantReproduction.TrySpawnNewSymbiosisCluster(this);
                }
            }

            // Spawn new cluster.
            if ((this.actualSize == this.desiredSize) &&
                (Find.TickManager.TicksGame > this.nextReproductionTick) &&
                ClusterPlant.IsTemperatureConditionOkAt(this.plantDef, this.Map, this.Position) &&
                ClusterPlant.IsLightConditionOkAt(this.plantDef, this.Map, this.Position))
            {
                GenClusterPlantReproduction.TrySpawnNewClusterAwayFrom(this);
                this.nextReproductionTick = Find.TickManager.TicksGame + (int)(this.plantDef.plant.reproduceMtbDays * 10f * GenDate.TicksPerDay);
            }
        }
예제 #2
0
        /// <summary>
        /// Check if position is valid to grow a plant. Does not check cluster exclusivity!
        /// </summary>
        public static bool IsValidPositionToGrowPlant(ThingDef_ClusterPlant plantDef, Map map, IntVec3 position, bool checkTemperature = true)
        {
            if (position.InBounds(map) == false)
            {
                return(false);
            }
            if (plantDef.isSymbiosisPlant)
            {
                // For symbiosis plant, only check there is a source symbiosis plant.
                if (position.GetFirstThing(map, plantDef.symbiosisPlantDefSource) != null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            // Check there is no building or cover.
            if ((position.GetEdifice(map) != null) ||
                (position.GetCover(map) != null))
            {
                return(false);
            }
            // Check terrain condition.
            if (ClusterPlant.CanTerrainSupportPlantAt(plantDef, map, position) == false)
            {
                return(false);
            }
            // Check temperature conditions.
            if (ClusterPlant.IsTemperatureConditionOkAt(plantDef, map, position) == false)
            {
                return(false);
            }
            // Check light conditions.
            if (ClusterPlant.IsLightConditionOkAt(plantDef, map, position) == false)
            {
                return(false);
            }
            // Check there is no other plant.
            if (map.thingGrid.ThingAt(position, ThingCategory.Plant) != null)
            {
                return(false);
            }
            // Check the cell is not blocked by a plant, an item, a pawn, a rock...
            List <Thing> thingList = map.thingGrid.ThingsListAt(position);

            for (int thingIndex = 0; thingIndex < thingList.Count; thingIndex++)
            {
                Thing thing = thingList[thingIndex];
                if (thing.def.BlockPlanting)
                {
                    return(false);
                }
                if (plantDef.passability == Traversability.Impassable &&
                    (thing.def.category == ThingCategory.Pawn ||
                     thing.def.category == ThingCategory.Item ||
                     thing.def.category == ThingCategory.Building ||
                     thing.def.category == ThingCategory.Plant))
                {
                    return(false);
                }
            }
            // Check snow level.
            if (GenPlant.SnowAllowsPlanting(position, map) == false)
            {
                return(false);
            }
            return(true);
        }