public override void Generate(Map map, GenStepParams parms)
 {
     if (this.allowInWaterBiome || !map.TileInfo.WaterCovered)
     {
         int      count = base.CalculateFinalCount(map);
         IntRange one;
         if (this.thingDef.ingestible != null && this.thingDef.ingestible.IsMeal && this.thingDef.stackLimit <= 10)
         {
             one = IntRange.one;
         }
         else if (this.thingDef.stackLimit > 5)
         {
             one = new IntRange(Mathf.RoundToInt((float)this.thingDef.stackLimit * 0.5f), this.thingDef.stackLimit);
         }
         else
         {
             one = new IntRange(this.thingDef.stackLimit, this.thingDef.stackLimit);
         }
         List <int> list = GenStep_ScatterThings.CountDividedIntoStacks(count, one);
         for (int i = 0; i < list.Count; i++)
         {
             IntVec3 intVec;
             if (!this.TryFindScatterCell(map, out intVec))
             {
                 return;
             }
             this.ScatterAt(intVec, map, list[i]);
             this.usedSpots.Add(intVec);
         }
         this.usedSpots.Clear();
         this.clusterCenter = IntVec3.Invalid;
         this.leftInCluster = 0;
     }
 }
Ejemplo n.º 2
0
        public override void Generate(Map map)
        {
            if (!base.allowOnWater && map.TileInfo.WaterCovered)
            {
                return;
            }
            int        count          = base.CalculateFinalCount(map);
            IntRange   stackSizeRange = (this.thingDef.ingestible == null || !this.thingDef.ingestible.IsMeal || this.thingDef.stackLimit > 10) ? ((this.thingDef.stackLimit <= 5) ? new IntRange(this.thingDef.stackLimit, this.thingDef.stackLimit) : new IntRange(Mathf.RoundToInt((float)((float)this.thingDef.stackLimit * 0.5)), this.thingDef.stackLimit)) : IntRange.one;
            List <int> list           = GenStep_ScatterThings.CountDividedIntoStacks(count, stackSizeRange);
            int        num            = 0;

            while (num < list.Count)
            {
                IntVec3 intVec = default(IntVec3);
                if (((GenStep_Scatterer)this).TryFindScatterCell(map, out intVec))
                {
                    this.ScatterAt(intVec, map, list[num]);
                    base.usedSpots.Add(intVec);
                    num++;
                    continue;
                }
                return;
            }
            base.usedSpots.Clear();
            this.clusterCenter = IntVec3.Invalid;
            this.leftInCluster = 0;
        }