TrackManiaControl/core/Callbacks/Structures/PlayerHitStructure.php

103 lines
1.9 KiB
PHP
Raw Normal View History

2014-10-10 14:40:00 +02:00
<?php
/**
* 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;
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];
//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() {
return $this->damage;
}
/**
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() {
return $this->shooterPoints;
}
/**
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
*
* @return int
*/
public function getHitDistance() {
return $this->hitDistance;
}
2014-10-24 20:20:12 +02:00
}