callbacks improvements begin
This commit is contained in:
parent
9642433363
commit
1feeb768b2
@ -73,4 +73,3 @@
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
|
@ -84,6 +84,13 @@ interface Callbacks {
|
||||
/** Returns if the GameMode has Warmup activated, returned after param1 Scores */ //returned after TODO
|
||||
const WARMUPSTATUS = 'Callbacks.WarmupStatus';
|
||||
|
||||
const ONSHOOT = 'Callbacks.OnShoot';
|
||||
|
||||
/** OnShoot Callback: PlayerHitStructure */
|
||||
const ONHIT = 'Callbacks.OnHit';
|
||||
/** OnNearMiss Callback: NearMissStructure */
|
||||
const ONNEARMISS = 'Callbacks.OnNearMiss';
|
||||
|
||||
/*
|
||||
* TrackMania Callbacks
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace ManiaControl\Callbacks;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
@ -37,6 +38,7 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function handleScriptCallback($name, $data) {
|
||||
var_dump($name);
|
||||
switch ($name) {
|
||||
case 'LibXmlRpc_BeginMatch':
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
|
||||
@ -113,9 +115,17 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
||||
case 'LibXmlRpc_OnStunt':
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTUNT, $data);
|
||||
break;
|
||||
case 'LibXmlRpc_OnShoot': //TODO testing
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHOOT, $player, $data[1]);
|
||||
break;
|
||||
case 'LibXmlRpc_OnHit':
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONHIT, new PlayerHitStructure($this->maniaControl, $data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trigger the Ranking of a Player
|
||||
*
|
||||
|
55
core/Callbacks/Structures/NearMissStructure.php
Normal file
55
core/Callbacks/Structures/NearMissStructure.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
class NearMissStructure {
|
||||
private $shooter;
|
||||
private $victim;
|
||||
private $distance;
|
||||
private $weapon;
|
||||
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl;
|
||||
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
$this->shooter = $data[0];
|
||||
$this->victim = $data[1];
|
||||
$this->weapon = $data[2];
|
||||
$this->distance = $data[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getShooter() {
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
||||
return $shooter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getVictim() {
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
||||
return $victim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDistance() {
|
||||
return $this->distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getWeapon() {
|
||||
return $this->weapon;
|
||||
}
|
||||
|
||||
}
|
62
core/Callbacks/Structures/PlayerHitStructure.php
Normal file
62
core/Callbacks/Structures/PlayerHitStructure.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
class PlayerHitStructure {
|
||||
private $shooter;
|
||||
private $victim;
|
||||
private $damage;
|
||||
private $shooterPoints;
|
||||
private $weapon;
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl;
|
||||
|
||||
public function __construct(ManiaControl $maniaControl, $data) {
|
||||
$this->shooter = $data[0];
|
||||
$this->victim = $data[1];
|
||||
$this->damage = $data[2];
|
||||
$this->weapon = $data[3];
|
||||
$this->shooterPoints = $data[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getShooter() {
|
||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
||||
return $shooter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getVictim() {
|
||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
||||
return $victim;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDamage() {
|
||||
return $this->damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getShooterPoints() {
|
||||
return $this->shooterPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWeapon() { //TODO any way of returning type "Weapon?"
|
||||
return $this->weapon;
|
||||
}
|
||||
}
|
17
core/Callbacks/Structures/Weapons.php
Normal file
17
core/Callbacks/Structures/Weapons.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures;
|
||||
|
||||
/**
|
||||
* Weapons Interface
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface Weapons {
|
||||
const LASER = 1;
|
||||
const ROCKET = 2;
|
||||
const NUCLEUS = 3;
|
||||
const ARROW = 5;
|
||||
}
|
Loading…
Reference in New Issue
Block a user