added trackmania switch case for callbacks
This commit is contained in:
parent
e8586586a3
commit
9a19691420
@ -80,6 +80,9 @@ interface Callbacks {
|
|||||||
const SM_ONPLAYERTHROWSOBJECT = "Shootmania.Event.OnPlayerThrowsObject";
|
const SM_ONPLAYERTHROWSOBJECT = "Shootmania.Event.OnPlayerThrowsObject";
|
||||||
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
|
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
|
||||||
|
|
||||||
|
|
||||||
|
const TM_EVENTDEFAULT = "Trackmania.Event.Default";
|
||||||
|
|
||||||
//ManiaControl Callbacks
|
//ManiaControl Callbacks
|
||||||
/** BeginMap Callback: Map */
|
/** BeginMap Callback: Map */
|
||||||
const BEGINMAP = 'Callbacks.BeginMap';
|
const BEGINMAP = 'Callbacks.BeginMap';
|
||||||
|
@ -75,7 +75,6 @@ class ShootManiaCallbacks implements CallbackListener {
|
|||||||
case Callbacks::SM_ONCAPTURE:
|
case Callbacks::SM_ONCAPTURE:
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data));
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONCAPTURE, new OnCaptureStructure($this->maniaControl, $data));
|
||||||
break;
|
break;
|
||||||
break;
|
|
||||||
//Old Callbacks
|
//Old Callbacks
|
||||||
case 'LibXmlRpc_Rankings':
|
case 'LibXmlRpc_Rankings':
|
||||||
$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]);
|
$this->maniaControl->getServer()->getRankingManager()->updateRankings($data[0]);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace ManiaControl\Callbacks;
|
namespace ManiaControl\Callbacks;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\Models\RecordCallback;
|
use ManiaControl\Callbacks\Models\RecordCallback;
|
||||||
|
use ManiaControl\Callbacks\Structures\Trackmania\DefaultEventStructure;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
@ -29,12 +30,35 @@ class TrackManiaCallbacks implements CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
|
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
// Register for script callbacks
|
||||||
|
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks');
|
||||||
|
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$callbackManager->registerCallbackListener(Callbacks::ONWAYPOINT, $this, 'handleOnWayPointCallback');
|
$callbackManager->registerCallbackListener(Callbacks::ONWAYPOINT, $this, 'handleOnWayPointCallback');
|
||||||
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpointCallback');
|
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERCHECKPOINT, $this, 'handlePlayerCheckpointCallback');
|
||||||
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinishCallback');
|
$callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinishCallback');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Script Callbacks
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $data
|
||||||
|
*/
|
||||||
|
public function handleScriptCallbacks($name, $data) {
|
||||||
|
if (!$this->maniaControl->getCallbackManager()->callbackListeningExists($name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ($name) {
|
||||||
|
//MP4 New Callbacks
|
||||||
|
case Callbacks::TM_EVENTDEFAULT:
|
||||||
|
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_EVENTDEFAULT, new DefaultEventStructure($this->maniaControl, $data));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle OnWayPoint Callback
|
* Handle OnWayPoint Callback
|
||||||
*
|
*
|
||||||
@ -52,11 +76,11 @@ class TrackManiaCallbacks implements CallbackListener {
|
|||||||
$wayPointCallback->rawCallback = $callback;
|
$wayPointCallback->rawCallback = $callback;
|
||||||
$wayPointCallback->setPlayer($player);
|
$wayPointCallback->setPlayer($player);
|
||||||
$wayPointCallback->blockId = $callback[1];
|
$wayPointCallback->blockId = $callback[1];
|
||||||
$wayPointCallback->time = (int)$callback[2];
|
$wayPointCallback->time = (int) $callback[2];
|
||||||
$wayPointCallback->checkpoint = (int)$callback[3];
|
$wayPointCallback->checkpoint = (int) $callback[3];
|
||||||
$wayPointCallback->isEndRace = Formatter::parseBoolean($callback[4]);
|
$wayPointCallback->isEndRace = Formatter::parseBoolean($callback[4]);
|
||||||
$wayPointCallback->lapTime = (int)$callback[5];
|
$wayPointCallback->lapTime = (int) $callback[5];
|
||||||
$wayPointCallback->lapCheckpoint = (int)$callback[6];
|
$wayPointCallback->lapCheckpoint = (int) $callback[6];
|
||||||
$wayPointCallback->lap = 0;
|
$wayPointCallback->lap = 0;
|
||||||
$wayPointCallback->isEndLap = Formatter::parseBoolean($callback[7]);
|
$wayPointCallback->isEndLap = Formatter::parseBoolean($callback[7]);
|
||||||
|
|
||||||
@ -94,9 +118,9 @@ class TrackManiaCallbacks implements CallbackListener {
|
|||||||
$checkpointCallback->isLegacyCallback = true;
|
$checkpointCallback->isLegacyCallback = true;
|
||||||
$checkpointCallback->rawCallback = $callback;
|
$checkpointCallback->rawCallback = $callback;
|
||||||
$checkpointCallback->setPlayer($player);
|
$checkpointCallback->setPlayer($player);
|
||||||
$checkpointCallback->time = (int)$data[2];
|
$checkpointCallback->time = (int) $data[2];
|
||||||
$checkpointCallback->lap = (int)$data[3];
|
$checkpointCallback->lap = (int) $data[3];
|
||||||
$checkpointCallback->checkpoint = (int)$data[4];
|
$checkpointCallback->checkpoint = (int) $data[4];
|
||||||
$checkpointCallback->lapCheckpoint = $checkpointCallback->checkpoint;
|
$checkpointCallback->lapCheckpoint = $checkpointCallback->checkpoint;
|
||||||
|
|
||||||
if ($checkpointCallback->lap > 0) {
|
if ($checkpointCallback->lap > 0) {
|
||||||
@ -132,7 +156,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
|||||||
$finishCallback->isLegacyCallback = true;
|
$finishCallback->isLegacyCallback = true;
|
||||||
$finishCallback->rawCallback = $callback;
|
$finishCallback->rawCallback = $callback;
|
||||||
$finishCallback->setPlayer($player);
|
$finishCallback->setPlayer($player);
|
||||||
$finishCallback->time = (int)$data[2];
|
$finishCallback->time = (int) $data[2];
|
||||||
|
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback($finishCallback);
|
$this->maniaControl->getCallbackManager()->triggerCallback($finishCallback);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user