Added Place() to plants library

rope
Felix Wagner 2012-06-07 01:45:38 +01:00
parent 6928332a0a
commit a10ba81b3e
2 changed files with 30 additions and 15 deletions

View File

@ -11,20 +11,47 @@ public func IsPlant()
return true;
}
/* Placement */
/** Places the given amount of plants inside the area. If no area is given, the whole landscape is used.
@param amount The amount of plants to be created (not necessarily every plant is created).
@param rectangle The area where to put the plants.
*/
public func Place(int amount, proplist rectangle)
{
// No calls to objects, only definitions
if (GetType(this) == C4V_C4Object) return;
if (!rectangle)
rectangle = Rectangle(0,0, LandscapeWidth(), LandscapeHeight());
for (var i = 0 ; i < amount ; i++)
PlaceVegetation(this, rectangle.x, rectangle.y, rectangle.w, rectangle.h, 100000);
}
/* Reproduction */
/** Chance to reproduce plant. Chances are one out of return value. Default is 500.
@return the chance, higher = less chance.
*/
private func SeedChance() { return 500; }
private func SeedChance()
{
return 500;
}
/** Distance the seeds may travel. Default is 250.
@return the maximum distance.
*/
private func SeedArea() { return 250; }
private func SeedArea()
{
return 250;
}
/** The amount of plants allowed within SeedAreaSize. Default is 10.
@return the maximum amount of plants.
*/
private func SeedAmount() { return 10; }
private func SeedAmount()
{
return 10;
}
/** Automated positioning via RootSurface, make sure to call this if needed (in case Construction is overloaded)
*/
@ -106,7 +133,6 @@ protected func Damage()
_inherited(...);
}
// restarts the growing of the tree (for example after taking damage)
func RestartGrowth(int old_value)
{

View File

@ -18,17 +18,6 @@ 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)
{
// place some sprout berries
var bush = PlaceVegetation(SproutBerryBush, 0, LandscapeHeight() / 3, LandscapeWidth(), LandscapeHeight(), 100000);
if(bush)
for (var i = 1; i < amount; i++)
PlaceVegetation(SproutBerryBush, bush->GetX() - 200, bush->GetY() - 200, 400, 400, 100000);
return true;
}
func Construction()
{
SetCon(100);