1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace ManiaLive\DedicatedApi\Callback;
13:
14: class Event extends \ManiaLive\Event\Event
15: {
16: const ON_PLAYER_CONNECT = 0x1;
17: const ON_PLAYER_DISCONNECT = 0x2;
18: const ON_PLAYER_CHAT = 0x4;
19: const ON_PLAYER_MANIALINK_PAGE_ANSWER = 0x8;
20: const ON_ECHO = 0x10;
21: const ON_SERVER_START = 0x20;
22: const ON_SERVER_STOP = 0x40;
23: const ON_BEGIN_MATCH = 0x80;
24: const ON_END_MATCH = 0x100;
25: const ON_BEGIN_MAP = 0x200;
26: const ON_END_MAP = 0x400;
27: const ON_BEGIN_ROUND = 0x800;
28: const ON_END_ROUND = 0x1000;
29: const ON_STATUS_CHANGED = 0x2000;
30: const ON_PLAYER_CHECKPOINT = 0x4000;
31: const ON_PLAYER_FINISH = 0x8000;
32: const ON_PLAYER_INCOHERENCE = 0x10000;
33: const ON_BILL_UPDATED = 0x20000;
34: const ON_TUNNEL_DATA_RECEIVED = 0x40000;
35: const ON_MAP_LIST_MODIFIED = 0x80000;
36: const ON_PLAYER_INFO_CHANGED = 0x100000;
37: const ON_MANUAL_FLOW_CONTROL_TRANSITION = 0x200000;
38: const ON_VOTE_UPDATED = 0x400000;
39: const ON_MODE_SCRIPT_CALLBACK = 0x800000;
40:
41: static private $rc;
42: protected $params;
43:
44: function __construct($method, $params = array())
45: {
46: parent::__construct(self::getOnWhat($method));
47: $this->params = $params;
48: }
49:
50: function fireDo($listener)
51: {
52: $p = $this->params;
53:
54: switch($this->onWhat)
55: {
56: case self::ON_PLAYER_CONNECT: $listener->onPlayerConnect($p[0], $p[1]); break;
57: case self::ON_PLAYER_DISCONNECT: $listener->onPlayerDisconnect($p[0]); break;
58: case self::ON_PLAYER_CHAT: $listener->onPlayerChat($p[0], $p[1], $p[2], $p[3]); break;
59: case self::ON_PLAYER_MANIALINK_PAGE_ANSWER: $listener->onPlayerManialinkPageAnswer($p[0], $p[1], $p[2], $p[3]); break;
60: case self::ON_ECHO: $listener->onEcho($p[0], $p[1]); break;
61: case self::ON_SERVER_START: $listener->onServerStart(); break;
62: case self::ON_SERVER_STOP: $listener->onServerStop(); break;
63: case self::ON_BEGIN_MATCH: $listener->onBeginMatch(); break;
64: case self::ON_END_MATCH: $listener->onEndMatch($p[0], $p[1]); break;
65: case self::ON_BEGIN_MAP:
66:
67: if(count($p) == 1)
68: $listener->onBeginMap($p[0], false, null);
69: else
70: $listener->onBeginMap($p[0], $p[1], $p[2]);
71: break;
72: case self::ON_END_MAP:
73:
74: if(count($p) == 1)
75: $listener->onEndMap(array(), $p[0], false, null, null);
76: else
77: $listener->onEndMap($p[0], $p[1], $p[2], $p[3], $p[4]);
78: break;
79: case self::ON_BEGIN_ROUND: $listener->onBeginRound(); break;
80: case self::ON_END_ROUND: $listener->onEndRound(); break;
81: case self::ON_STATUS_CHANGED: $listener->onStatusChanged($p[0], $p[1]); break;
82: case self::ON_PLAYER_CHECKPOINT: $listener->onPlayerCheckpoint($p[0], $p[1], $p[2], $p[3], $p[4]); break;
83: case self::ON_PLAYER_FINISH: $listener->onPlayerFinish($p[0], $p[1], $p[2]); break;
84: case self::ON_PLAYER_INCOHERENCE: $listener->onPlayerIncoherence($p[0], $p[1]); break;
85: case self::ON_BILL_UPDATED: $listener->onBillUpdated($p[0], $p[1], $p[2], $p[3]); break;
86: case self::ON_TUNNEL_DATA_RECEIVED: $listener->onTunnelDataReceived($p[0], $p[1], $p[2]); break;
87: case self::ON_MAP_LIST_MODIFIED: $listener->onMapListModified($p[0], $p[1], $p[2]); break;
88: case self::ON_PLAYER_INFO_CHANGED: $listener->onPlayerInfoChanged($p[0]); break;
89: case self::ON_MANUAL_FLOW_CONTROL_TRANSITION: $listener->onManualFlowControlTransition($p[0]); break;
90: case self::ON_VOTE_UPDATED: $listener->onVoteUpdated($p[0], $p[1], $p[2], $p[3]); break;
91: case self::ON_MODE_SCRIPT_CALLBACK: $listener->onModeScriptCallback($p[0], $p[1]); break;
92: }
93: }
94:
95: private static function getOnWhat($method)
96: {
97: $constName = 'ON_'.strtoupper(preg_replace('/([a-z])([A-Z])/', '$1_$2', $method));
98:
99: if(!self::$rc)
100: self::$rc = new \ReflectionClass(get_called_class());
101:
102: return self::$rc->getConstant($constName);
103: }
104: }
105:
106: ?>