2017-03-25 11:53:55 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
|
|
|
|
|
|
|
|
2017-03-30 19:49:45 +02:00
|
|
|
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
2020-04-21 17:57:36 +02:00
|
|
|
|
|
|
|
|
2017-03-25 11:53:55 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Players\Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Structure Class for the OnCapture Structure Callback
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-25 11:53:55 +01:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2020-01-22 10:39:35 +01:00
|
|
|
* @copyright 2014-2020 ManiaControl Team
|
2017-03-25 11:53:55 +01:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
|
|
*/
|
|
|
|
class OnCaptureStructure extends BaseStructure {
|
|
|
|
|
2017-03-26 12:42:20 +02:00
|
|
|
private $time;
|
2017-03-25 12:55:09 +01:00
|
|
|
private $landMark;
|
2017-03-25 11:53:55 +01:00
|
|
|
|
|
|
|
private $playerArray = array();
|
|
|
|
|
2017-04-07 23:26:35 +02:00
|
|
|
/**
|
|
|
|
* OnCaptureStructure constructor.
|
|
|
|
*
|
|
|
|
* @param \ManiaControl\ManiaControl $maniaControl
|
|
|
|
* @param $data
|
|
|
|
*/
|
2017-03-25 11:53:55 +01:00
|
|
|
public function __construct(ManiaControl $maniaControl, $data) {
|
|
|
|
parent::__construct($maniaControl, $data);
|
|
|
|
|
|
|
|
$jsonObj = $this->getPlainJsonObject();
|
|
|
|
|
|
|
|
$this->time = $jsonObj->time;
|
|
|
|
$this->playerArray = $jsonObj->players;
|
|
|
|
|
2017-05-10 09:12:00 +02:00
|
|
|
//TODO Verify why it doesnt work for siege
|
|
|
|
/*if (property_exists($jsonObj, 'landmark')) {
|
2017-05-09 22:36:40 +02:00
|
|
|
$this->landMark = new Landmark();
|
|
|
|
$this->landMark->setTag($jsonObj->landmark->tag);
|
|
|
|
$this->landMark->setOrder($jsonObj->landmark->order);
|
|
|
|
$this->landMark->setId($jsonObj->landmark->id);
|
2017-03-25 11:53:55 +01:00
|
|
|
|
2017-05-09 22:36:40 +02:00
|
|
|
$position = new Position();
|
|
|
|
$position->setX($jsonObj->landmark->position->x);
|
|
|
|
$position->setY($jsonObj->landmark->position->y);
|
|
|
|
$position->setZ($jsonObj->landmark->position->z);
|
2017-03-25 11:53:55 +01:00
|
|
|
|
2017-05-09 22:36:40 +02:00
|
|
|
$this->landMark->setPosition($position);
|
2017-05-10 09:12:00 +02:00
|
|
|
}*/
|
2017-03-25 11:53:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get the logins as Array
|
2017-03-25 11:53:55 +01:00
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-26 12:42:20 +02:00
|
|
|
* @return string[]
|
2017-03-25 11:53:55 +01:00
|
|
|
*/
|
|
|
|
public function getLoginArray() {
|
|
|
|
return $this->playerArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Get the Players as Player Array
|
2017-03-25 11:53:55 +01:00
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-25 11:53:55 +01:00
|
|
|
* @return Player[]
|
|
|
|
*/
|
|
|
|
public function getPlayerArray() {
|
|
|
|
$playerArray = array();
|
|
|
|
foreach ($this->playerArray as $login) {
|
|
|
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
|
|
|
if ($player) {
|
|
|
|
$playerArray[$login] = $player;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $playerArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-26 12:42:20 +02:00
|
|
|
* Returns Information about the Captured Landmark
|
|
|
|
*
|
2017-04-07 23:26:35 +02:00
|
|
|
* @api
|
2017-03-26 12:42:20 +02:00
|
|
|
* @return \ManiaControl\Callbacks\Structures\ShootMania\Models\LandMark
|
2017-03-25 11:53:55 +01:00
|
|
|
*/
|
|
|
|
public function getLandMark() {
|
|
|
|
return $this->landMark;
|
|
|
|
}
|
|
|
|
}
|