callback improvements, new structures for shootmania callbacks
This commit is contained in:
parent
1feeb768b2
commit
27efcabb6e
@ -84,12 +84,19 @@ interface Callbacks {
|
|||||||
/** Returns if the GameMode has Warmup activated, returned after param1 Scores */ //returned after TODO
|
/** Returns if the GameMode has Warmup activated, returned after param1 Scores */ //returned after TODO
|
||||||
const WARMUPSTATUS = 'Callbacks.WarmupStatus';
|
const WARMUPSTATUS = 'Callbacks.WarmupStatus';
|
||||||
|
|
||||||
|
/** OnShoot Callback: Player, WeaponNumber (see Weapons Structure) */
|
||||||
const ONSHOOT = 'Callbacks.OnShoot';
|
const ONSHOOT = 'Callbacks.OnShoot';
|
||||||
|
|
||||||
/** OnShoot Callback: PlayerHitStructure */
|
/** OnHit Callback: PlayerHitStructure */
|
||||||
const ONHIT = 'Callbacks.OnHit';
|
const ONHIT = 'Callbacks.OnHit';
|
||||||
/** OnNearMiss Callback: NearMissStructure */
|
/** OnNearMiss Callback: NearMissStructure */
|
||||||
const ONNEARMISS = 'Callbacks.OnNearMiss';
|
const ONNEARMISS = 'Callbacks.OnNearMiss';
|
||||||
|
/** OnArmorEmpty Callback: ArmorEmptyStructure */
|
||||||
|
const ONARMOREMPTY = 'Callbacks.OnArmorEmpty';
|
||||||
|
/** OnCapture Callback: CaptureStructure */
|
||||||
|
const ONCAPTURE = 'Callbacks.OnCapture';
|
||||||
|
/** OnPlayerRequestRespawn Callback: Player */
|
||||||
|
const ONPLAYERREQUESTRESPAWN = 'Callbacks.OnPlayerRequestRespawn';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TrackMania Callbacks
|
* TrackMania Callbacks
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Callbacks;
|
namespace ManiaControl\Callbacks;
|
||||||
|
|
||||||
|
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
|
||||||
|
use ManiaControl\Callbacks\Structures\CaptureStructure;
|
||||||
|
use ManiaControl\Callbacks\Structures\NearMissStructure;
|
||||||
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
|
use ManiaControl\Callbacks\Structures\PlayerHitStructure;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
@ -115,13 +118,26 @@ class LibXmlRpcCallbacks implements CallbackListener {
|
|||||||
case 'LibXmlRpc_OnStunt':
|
case 'LibXmlRpc_OnStunt':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTUNT, $data);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSTUNT, $data);
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_OnShoot': //TODO testing
|
case 'LibXmlRpc_OnShoot':
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHOOT, $player, $data[1]);
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONSHOOT, $player, $data[1]);
|
||||||
break;
|
break;
|
||||||
case 'LibXmlRpc_OnHit':
|
case 'LibXmlRpc_OnHit':
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONHIT, new PlayerHitStructure($this->maniaControl, $data));
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONHIT, new PlayerHitStructure($this->maniaControl, $data));
|
||||||
break;
|
break;
|
||||||
|
case 'LibXmlRpc_OnNearMiss':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONHIT, new NearMissStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
case 'LibXmlRpc_OnArmorEmpty':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new ArmorEmptyStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
case 'LibXmlRpc_OnCapture':
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, new CaptureStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
case 'LibXmlRpc_OnPlayerRequestRespawn':
|
||||||
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($data[0]);
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::ONARMOREMPTY, $player);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
62
core/Callbacks/Structures/ArmorEmptyStructure.php
Normal file
62
core/Callbacks/Structures/ArmorEmptyStructure.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Callbacks\Structures;
|
||||||
|
|
||||||
|
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
|
|
||||||
|
class ArmorEmptyStructure {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
29
core/Callbacks/Structures/CaptureStructure.php
Normal file
29
core/Callbacks/Structures/CaptureStructure.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ManiaControl\Callbacks\Structures;
|
||||||
|
|
||||||
|
|
||||||
|
use ManiaControl\Players\Player;
|
||||||
|
|
||||||
|
class CaptureStructure {
|
||||||
|
private $playerArray;
|
||||||
|
|
||||||
|
public function __construct($maniaControl, $data) {
|
||||||
|
$this->playerArray = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLoginArray() {
|
||||||
|
return $this->playerArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Player[]
|
||||||
|
*/
|
||||||
|
public function getPlayerArray() {
|
||||||
|
//TODO build array with player objects
|
||||||
|
return $this->playerArray;
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,7 @@ class NearMissStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player
|
* @return Player|null
|
||||||
*/
|
*/
|
||||||
public function getShooter() {
|
public function getShooter() {
|
||||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
||||||
@ -31,7 +31,7 @@ class NearMissStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player
|
* @return Player|null
|
||||||
*/
|
*/
|
||||||
public function getVictim() {
|
public function getVictim() {
|
||||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
||||||
|
@ -24,7 +24,7 @@ class PlayerHitStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player
|
* @return Player|null
|
||||||
*/
|
*/
|
||||||
public function getShooter() {
|
public function getShooter() {
|
||||||
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
$shooter = $this->maniaControl->getPlayerManager()->getPlayer($this->shooter);
|
||||||
@ -32,7 +32,7 @@ class PlayerHitStructure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Player
|
* @return Player|null
|
||||||
*/
|
*/
|
||||||
public function getVictim() {
|
public function getVictim() {
|
||||||
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
$victim = $this->maniaControl->getPlayerManager()->getPlayer($this->victim);
|
||||||
|
Loading…
Reference in New Issue
Block a user