|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Framework\GameManiaplanet\DataProviders; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Framework\Core\DataProviders\AbstractDataProvider; |
|
6
|
|
|
use eXpansion\Framework\Core\Storage\MapStorage; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class MapDataProvider |
|
10
|
|
|
* |
|
11
|
|
|
* @package eXpansion\Framework\GameManiaplanet\DataProviders; |
|
12
|
|
|
* @author oliver de Cramer <[email protected]> |
|
13
|
|
|
*/ |
|
14
|
|
|
class MapDataProvider extends AbstractDataProvider |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var MapStorage */ |
|
17
|
|
|
protected $mapStorage; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* BaseDataProvider constructor. |
|
21
|
|
|
* |
|
22
|
|
|
* @param MapStorage $mapStorage |
|
23
|
|
|
*/ |
|
24
|
|
|
public function __construct(MapStorage $mapStorage) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->mapStorage = $mapStorage; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Callback sent when the "StartMap" section start. |
|
31
|
|
|
* |
|
32
|
|
|
* @param array $params |
|
33
|
|
|
*/ |
|
34
|
|
|
public function onStartMapStart($params) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->dispatchMapEvent('onStartMapStart', $params); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Callback sent when the "StartMatch" section start. |
|
41
|
|
|
* |
|
42
|
|
|
* @param array $params |
|
43
|
|
|
*/ |
|
44
|
|
|
public function onStartMapEnd($params) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->dispatchMapEvent('onStartMapEnd', $params); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Callback sent when the "EndMap" section start. |
|
52
|
|
|
* |
|
53
|
|
|
* @param array $params |
|
54
|
|
|
*/ |
|
55
|
|
|
public function onEndMapStart($params) |
|
56
|
|
|
{ |
|
57
|
|
|
$this->dispatchMapEvent('onEndMapStart', $params); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Callback sent when the "EndMap" section ends. |
|
62
|
|
|
* |
|
63
|
|
|
* @param array $params |
|
64
|
|
|
*/ |
|
65
|
|
|
public function onEndMapEnd($params) |
|
66
|
|
|
{ |
|
67
|
|
|
$this->dispatchMapEvent('onEndMapEnd', $params); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Dispatch map event. |
|
72
|
|
|
* |
|
73
|
|
|
* @param $eventName |
|
74
|
|
|
* @param $params |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function dispatchMapEvent($eventName, $params) |
|
77
|
|
|
{ |
|
78
|
|
|
$map = $this->mapStorage->getMap($params['map']['uid']); |
|
79
|
|
|
|
|
80
|
|
|
$this->dispatch( |
|
81
|
|
|
$eventName, |
|
82
|
|
|
[ |
|
83
|
|
|
$params['count'], |
|
84
|
|
|
isset($params['time']) ? $params['time'] : time(), |
|
85
|
|
|
isset($params['restarted']) ? $params['restarted'] : false, |
|
86
|
|
|
$map, |
|
87
|
|
|
] |
|
88
|
|
|
); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|