public override void Resolve(ResolveParams rp)
        {
            ThingDef thingDef = rp.cultivatedPlantDef ?? SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect);
            bool     flag     = rp.rect.Width >= 7 && rp.rect.Height >= 7 && (rp.rect.Width > 12 || rp.rect.Height > 12 || Rand.Bool) && thingDef.plant.Harvestable;

            if (flag)
            {
                CellRect rect = new CellRect(rp.rect.maxX - 3, rp.rect.maxZ - 3, 4, 4);
                ThingDef harvestedThingDef = thingDef.plant.harvestedThingDef;
                int      num = Rand.RangeInclusive(2, 3);
                for (int i = 0; i < num; i++)
                {
                    ResolveParams resolveParams = rp;
                    resolveParams.rect                  = rect.ContractedBy(1);
                    resolveParams.singleThingDef        = harvestedThingDef;
                    resolveParams.singleThingStackCount = new int?(Rand.RangeInclusive(Mathf.Min(10, harvestedThingDef.stackLimit), Mathf.Min(50, harvestedThingDef.stackLimit)));
                    BaseGen.symbolStack.Push("thing", resolveParams);
                }
                ResolveParams resolveParams2 = rp;
                resolveParams2.rect = rect;
                BaseGen.symbolStack.Push("ensureCanReachMapEdge", resolveParams2);
                ResolveParams resolveParams3 = rp;
                resolveParams3.rect = rect;
                BaseGen.symbolStack.Push("emptyRoom", resolveParams3);
            }
            ResolveParams resolveParams4 = rp;

            resolveParams4.cultivatedPlantDef = thingDef;
            BaseGen.symbolStack.Push("cultivatedPlants", resolveParams4);
        }
Exemplo n.º 2
0
        public override void Resolve(ResolveParams rp)
        {
            Map      map      = BaseGen.globalSettings.map;
            ThingDef thingDef = rp.cultivatedPlantDef ?? SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect);

            if (thingDef != null)
            {
                float growth = Rand.Range(0.2f, 1f);
                int   age    = thingDef.plant.LimitedLifespan ? Rand.Range(0, Mathf.Max(thingDef.plant.LifespanTicks - 2500, 0)) : 0;
                CellRect.CellRectIterator iterator = rp.rect.GetIterator();
                while (!iterator.Done())
                {
                    float num = map.fertilityGrid.FertilityAt(iterator.Current);
                    if (!(num < thingDef.plant.fertilityMin) && this.TryDestroyBlockingThingsAt(iterator.Current))
                    {
                        Plant plant = (Plant)GenSpawn.Spawn(thingDef, iterator.Current, map);
                        plant.Growth = growth;
                        if (plant.def.plant.LimitedLifespan)
                        {
                            plant.Age = age;
                        }
                    }
                    iterator.MoveNext();
                }
            }
        }
 public override bool CanResolve(ResolveParams rp)
 {
     if (base.CanResolve(rp))
     {
         if (rp.cultivatedPlantDef == null)
         {
             return(SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect) != null);
         }
         return(true);
     }
     return(false);
 }
 public override bool CanResolve(ResolveParams rp)
 {
     return(base.CanResolve(rp) && (rp.cultivatedPlantDef != null || SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect) != null));
 }
 public override bool CanResolve(ResolveParams rp)
 {
     return(base.CanResolve(rp) && BaseGen.globalSettings.basePart_buildingsResolved >= BaseGen.globalSettings.minBuildings && BaseGen.globalSettings.basePart_emptyNodesResolved >= BaseGen.globalSettings.minEmptyNodes && BaseGen.globalSettings.basePart_farmsCoverage + (float)rp.rect.Area / (float)BaseGen.globalSettings.mainRect.Area < 0.55f && (rp.rect.Width <= 15 && rp.rect.Height <= 15) && (rp.cultivatedPlantDef != null || SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect) != null));
 }