@@ -30,6 +30,9 @@ final class GrillEvent extends Event implements ForOneRoundMax
3030 private readonly int $ damageCoolDownTickCount ;
3131 private readonly int $ maxFlameCount ;
3232
33+ public readonly Point $ boundaryMin ;
34+ public readonly Point $ boundaryMax ;
35+
3336 /** @var SplQueue<Node> $queue */
3437 private SplQueue $ queue ;
3538 /** @var array<string,bool> */
@@ -59,6 +62,8 @@ public function __construct(
5962 }
6063
6164 $ this ->id = "grill- {$ this ->initiator ->getId ()}- {$ this ->world ->getTickId ()}" ;
65+ $ this ->boundaryMin = $ start ->clone ();
66+ $ this ->boundaryMax = $ start ->clone ();
6267 $ this ->queue = new SplQueue ();
6368 $ this ->queue ->enqueue ($ startNode );
6469 $ this ->igniteFlames ();
@@ -100,6 +105,17 @@ public function process(int $tick): void
100105 private function igniteFlames (): void
101106 {
102107 foreach ($ this ->loadFlames () as $ candidate ) {
108+ $ this ->boundaryMin ->set (
109+ min ($ this ->boundaryMin ->x , $ candidate ->x - $ this ->flameRadius ),
110+ min ($ this ->boundaryMin ->y , $ candidate ->y - 0 ),
111+ min ($ this ->boundaryMin ->z , $ candidate ->z - $ this ->flameRadius ),
112+ );
113+ $ this ->boundaryMax ->set (
114+ max ($ this ->boundaryMax ->x , $ candidate ->x + $ this ->flameRadius ),
115+ max ($ this ->boundaryMax ->y , $ candidate ->y + $ this ->flameHeight ),
116+ max ($ this ->boundaryMax ->z , $ candidate ->z + $ this ->flameRadius ),
117+ );
118+
103119 $ flame = new Flame ($ candidate , $ this ->flameRadius , $ this ->flameHeight );
104120 $ this ->flames [] = $ flame ;
105121 $ this ->lastFlameSpawnTickId = $ this ->world ->getTickId ();
@@ -119,16 +135,17 @@ private function loadFlames(): array
119135 $ output = [];
120136 while (!$ this ->queue ->isEmpty () && count ($ output ) < min ($ this ->spawnFlameCount , $ loadCount )) {
121137 $ current = $ this ->queue ->dequeue ();
122- if (array_key_exists ($ current ->getId (), $ this ->visited )) {
138+ $ currentKey = $ current ->getId ();
139+ if (array_key_exists ($ currentKey , $ this ->visited )) {
123140 continue ;
124141 }
125142
126- $ this ->visited [$ current -> getId () ] = true ;
143+ $ this ->visited [$ currentKey ] = true ;
127144 /** @var Point $point */
128145 $ point = $ current ->getData ();
129146 $ output [] = $ point ;
130147
131- foreach ($ this ->graph ->getNeighbors ( $ current ) as $ node ) {
148+ foreach ($ this ->graph ->getGeneratedNeighbors ( $ currentKey ) as $ node ) {
132149 $ this ->queue ->enqueue ($ node );
133150 }
134151 }
0 commit comments