2014-10-10 14:40:00 +02:00
|
|
|
<?php
|
2014-12-13 16:25:11 +01:00
|
|
|
/**
|
|
|
|
* Player Hit Structure
|
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
2014-10-10 14:40:00 +02:00
|
|
|
namespace ManiaControl\Callbacks\Structures;
|
|
|
|
|
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Players\Player;
|
|
|
|
|
|
|
|
class PlayerHitStructure {
|
2014-10-24 20:20:12 +02:00
|
|
|
/*
|
|
|
|
* Private properties
|
|
|
|
*/
|
2014-10-10 14:40:00 +02:00
|
|
|
private $shooter;
|
|
|
|
private $victim;
|
|
|
|
private $damage;
|
|
|
|
private $shooterPoints;
|
|
|
|
private $weapon;
|
2014-12-13 16:25:11 +01:00
|
|
|
private $hitDistance = 0;
|
|
|
|
|
2014-10-10 14:40:00 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
|
|
|
private $maniaControl;
|
|
|
|
|
2014-10-24 20:20:12 +02:00
|
|
|
/**
|
|
|
|
* Construct new Player Hit Structure
|
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
* @param array $data
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl, array $data) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-10-10 14:40:00 +02:00
|
|
|
$this->shooter = $data[0];
|
|
|
|
$this->victim = $data[1];
|
|
|
|
$this->damage = $data[2];
|
|
|
|
$this->weapon = $data[3];
|
|
|
|
$this->shooterPoints = $data[4];
|
2014-12-21 23:21:59 +01:00
|
|
|
|
2014-12-13 16:25:11 +01:00
|
|
|
//TODO remove key check in some months (hitDistance got implemented 2014-10-16)
|
|
|
|
if (array_key_exists(5, $data)) {
|
|
|
|
$this->hitDistance = $data[5];
|
|
|
|
}
|
2014-10-10 14:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-24 20:20:12 +02:00
|
|
|
* Get the shooter
|
|
|
|
*
|
|
|
|
* @return Player
|
2014-10-10 14:40:00 +02:00
|
|
|
*/
|
|
|
|
public function getShooter() {
|
2014-10-24 20:20:12 +02:00
|
|
|
return $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
2014-10-10 14:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-24 20:20:12 +02:00
|
|
|
* Get the victim
|
|
|
|
*
|
|
|
|
* @return Player
|
2014-10-10 14:40:00 +02:00
|
|
|
*/
|
|
|
|
public function getVictim() {
|
2014-10-24 20:20:12 +02:00
|
|
|
return $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
2014-10-10 14:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-24 20:20:12 +02:00
|
|
|
* Get the damage
|
|
|
|
*
|
2014-10-10 14:40:00 +02:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getDamage() {
|
2014-12-21 23:21:59 +01:00
|
|
|
return intval($this->damage);
|
2014-10-10 14:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-24 20:20:12 +02:00
|
|
|
* Get the shooter points
|
|
|
|
*
|
2014-10-10 14:40:00 +02:00
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getShooterPoints() {
|
2014-12-21 23:21:59 +01:00
|
|
|
return intval($this->shooterPoints);
|
2014-10-10 14:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-24 20:20:12 +02:00
|
|
|
* Get the weapon
|
|
|
|
*
|
2014-10-10 14:40:00 +02:00
|
|
|
* @return int
|
|
|
|
*/
|
2014-10-24 20:20:12 +02:00
|
|
|
public function getWeapon() {
|
|
|
|
// TODO: any way of returning type "Weapon?"
|
2014-10-10 14:40:00 +02:00
|
|
|
return $this->weapon;
|
|
|
|
}
|
2014-12-13 16:25:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get The Hit Distance
|
|
|
|
*
|
2014-12-21 23:21:59 +01:00
|
|
|
* @return double
|
2014-12-13 16:25:11 +01:00
|
|
|
*/
|
|
|
|
public function getHitDistance() {
|
2014-12-21 23:21:59 +01:00
|
|
|
return doubleval($this->hitDistance);
|
2014-12-13 16:25:11 +01:00
|
|
|
}
|
2014-10-24 20:20:12 +02:00
|
|
|
}
|