forked from Mirrors/openclonk
re-added Place() function for sprout berry bushes again, it never inherited from Library_Plant and uses a bit more sophisticated placement that is in sync with some of its behavior
parent
b830d15280
commit
41e56f6a01
|
@ -18,6 +18,38 @@ static const SproutBerryBush_water_per_berry = 10;
|
|||
static const SproutBerryBush_max_sprouts = 8;
|
||||
static const SproutBerryBush_evolve_steps_per_new_sprout = 2;
|
||||
|
||||
// static function
|
||||
func Place(int amount, proplist rectangle, proplist settings)
|
||||
{
|
||||
// No calls to objects, only definitions
|
||||
if (GetType(this) == C4V_C4Object) return;
|
||||
// Default parameters
|
||||
amount = amount ?? (LandscapeWidth() / 150);
|
||||
settings = settings ?? { growth = 100000, keep_area = false };
|
||||
settings.growth = settings.growth ?? 100000;
|
||||
rectangle = rectangle ?? Rectangle(0,0, LandscapeWidth(), LandscapeHeight());
|
||||
|
||||
var plants = [];
|
||||
while(amount > 0)
|
||||
{
|
||||
// place some sprout berries
|
||||
var bush = PlaceVegetation(SproutBerryBush, rectangle.x, rectangle.y, rectangle.w, rectangle.h, 100000);
|
||||
if(!bush) break;
|
||||
--amount;
|
||||
PushBack(plants, bush);
|
||||
var cluster = Random(3) + 3;
|
||||
while(cluster > 0 && amount > 0)
|
||||
{
|
||||
var p = PlaceVegetation(SproutBerryBush, bush->GetX() - 200, bush->GetY() - 200, 400, 400, 100000);
|
||||
if(!p) break;
|
||||
--amount;
|
||||
--cluster;
|
||||
PushBack(plants, p);
|
||||
}
|
||||
}
|
||||
return plants;
|
||||
}
|
||||
|
||||
func Construction()
|
||||
{
|
||||
SetCon(100);
|
||||
|
|
|
@ -14,8 +14,9 @@ protected func Initialize()
|
|||
|
||||
// Place some trees.
|
||||
//Tree_Coniferous->Place(16+Random(4), Rectangle(0,LandscapeHeight()/3, LandscapeWidth(), LandscapeHeight()));
|
||||
PlaceForest([Tree_Coniferous, SproutBerryBush],0, LandscapeHeight()/2+50, nil, true);
|
||||
PlaceForest([Tree_Coniferous], 0, LandscapeHeight()/2+50, nil, true);
|
||||
|
||||
SproutBerryBush->Place();
|
||||
PlaceGrass(100);
|
||||
|
||||
CreateEnvironmentObjects("Temperate");
|
||||
|
|
Loading…
Reference in New Issue