Skip to content

Commit 9ba2ef9

Browse files
starswaitforussolcloud
authored andcommitted
Fire sound
1 parent 561118c commit 9ba2ef9

6 files changed

Lines changed: 27 additions & 9 deletions

File tree

server/src/Event/GrillEvent.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(
4545
private readonly int $flameRadius,
4646
private readonly int $flameHeight,
4747
private readonly Graph $graph,
48-
Point $start,
48+
private readonly Point $start,
4949
)
5050
{
5151
$flameArea = ($this->flameRadius * 2 + 1) ** 2;
@@ -163,4 +163,13 @@ public function playerHit(int $playerId, int $tickId): void
163163
$this->playerTickHits[$playerId] = $tickId;
164164
}
165165

166+
public function serialize(): array
167+
{
168+
return [
169+
'position' => $this->start->toArray(),
170+
'maxTime' => $this->item->getMaxTimeMs(),
171+
'maxFlames' => $this->maxFlameCount,
172+
];
173+
}
174+
166175
}

www/assets/js/EventProcessor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class EventProcessor {
109109
}
110110

111111
eventsCallback[EventList.GrillEvent] = function (data) {
112-
// todo play grill song
112+
game.grillStart(data.position, data.maxTime, data.maxFlames)
113113
}
114114

115115
this.#callbacks = eventsCallback

www/assets/js/Game.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ export class Game {
313313
delete this.#throwables[id]
314314
}
315315

316+
grillStart(position, maxTimeMs, maxFlamesCount) {
317+
this.#world.playSound('338301_4811732-lq.mp3', position, false)
318+
}
319+
316320
spawnFlame(point, size, height, fireId, flameId) {
317321
if (this.#flammable[fireId] === undefined) {
318322
this.#flammable[fireId] = {}

www/assets/js/SoundRepository.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ export class SoundRepository {
133133
return null
134134
}
135135

136-
if (type === SoundType.FLAME_SPAWN) {
137-
return null // todo
138-
}
139-
if (type === SoundType.FLAME_EXTINGUISH) {
140-
return null // todo
136+
if (type === SoundType.FLAME_SPAWN || type === SoundType.FLAME_EXTINGUISH) {
137+
return null
141138
}
142139
if (type === SoundType.GRENADE_AIR) {
143140
return '575509__awildfilli__granada_tiro.wav'

www/assets/js/World.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class World {
1010
#modelRepository
1111
#decals = []
1212
#flames = []
13+
#flameGeometry = null
1314
volume = 30
1415

1516
constructor() {
@@ -174,9 +175,16 @@ export class World {
174175
}
175176

176177
spawnFlame(size, height) {
178+
if (this.#flameGeometry === null){
179+
this.#flameGeometry = []
180+
this.#flameGeometry.push(new THREE.ConeGeometry(size, height, 4))
181+
this.#flameGeometry.push(new THREE.ConeGeometry(size, height, 5))
182+
this.#flameGeometry.push(new THREE.ConeGeometry(size, height, 6))
183+
this.#flameGeometry.push(new THREE.ConeGeometry(size, height, 7))
184+
}
177185
let mesh = new THREE.Mesh(
178-
new THREE.ConeGeometry(size, height, randomInt(4, 7)),
179-
new THREE.MeshStandardMaterial({color: new THREE.Color(`hsl(53, 100%, ${Math.random() * 70 + 20}%, 1)`)}),
186+
this.#flameGeometry[randomInt(0, this.#flameGeometry.length - 1)],
187+
new THREE.MeshBasicMaterial({color: new THREE.Color(`hsl(53, 100%, ${Math.random() * 70 + 20}%, 1)`)}),
180188
)
181189

182190
mesh.castShadow = false
71.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)