TrackManiaControl/core/Callbacks/Structures/PlayerHitStructure.php

103 lines
2.0 KiB
PHP
Raw Normal View History

2014-10-10 14:40:00 +02:00
<?php
/**
* Player Hit Structure
*
* @author ManiaControl Team <mail@maniacontrol.com>
2015-01-19 11:06:20 +01:00
* @copyright 2014-2015 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;
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
//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;
}
/**
* Get The Hit Distance
*
2014-12-21 23:21:59 +01:00
* @return double
*/
public function getHitDistance() {
2014-12-21 23:21:59 +01:00
return doubleval($this->hitDistance);
}
2014-10-24 20:20:12 +02:00
}