Projectile: added API to modify projectile base damage multiplier

This adds two new methods:
- Projectile->getBaseDamage()
- Projectile->setBaseDamage()
This commit is contained in:
Dylan K. Taylor 2018-06-23 10:38:58 +01:00
parent 4c9ca53b32
commit f1970492c1
2 changed files with 23 additions and 2 deletions

View File

@ -52,7 +52,8 @@ class Arrow extends Projectile{
protected $gravity = 0.05;
protected $drag = 0.01;
protected $damage = 2;
/** @var float */
protected $damage = 2.0;
/** @var int */
protected $pickupMode = self::PICKUP_ANY;

View File

@ -46,7 +46,8 @@ abstract class Projectile extends Entity{
public const DATA_SHOOTER_ID = 17;
protected $damage = 0;
/** @var float */
protected $damage = 0.0;
/** @var Vector3|null */
protected $blockHit;
@ -112,6 +113,25 @@ abstract class Projectile extends Entity{
return false;
}
/**
* Returns the base damage applied on collision. This is multiplied by the projectile's speed to give a result
* damage.
*
* @return float
*/
public function getBaseDamage() : float{
return $this->damage;
}
/**
* Sets the base amount of damage applied by the projectile.
*
* @param float $damage
*/
public function setBaseDamage(float $damage) : void{
$this->damage = $damage;
}
/**
* Returns the amount of damage this projectile will deal to the entity it hits.
* @return int