Skip to content

Commit d07f9f9

Browse files
Fix crash (#181)
* Fix crash Removed spawn location initialization from constructor. * spawnBoss function now picks location Set boss spawn location based on arena's spawn point. * Fix * Update Manager.ts * preTick and postTick now done by Game
1 parent 04b25e4 commit d07f9f9

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/Entity/Boss/AbstractBoss.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ export default class AbstractBoss extends LivingEntity {
116116
public constructor(game: GameServer) {
117117
super(game);
118118

119-
const {x, y} = this.game.arena.findSpawnLocation();
120-
this.positionData.values.x = x;
121-
this.positionData.values.y = y;
122-
123119
this.relationsData.values.team = this.cameraEntity;
124120

125121
this.physicsData.values.absorbtionFactor = 0.05;
@@ -132,7 +128,7 @@ export default class AbstractBoss extends LivingEntity {
132128
this.ai['_findTargetInterval'] = 0;
133129
this.inputs = this.ai.inputs;
134130

135-
// default ehColor
131+
// Default color
136132
this.styleData.values.color = Color.Fallen;
137133

138134
this.physicsData.values.sides = 1;
@@ -189,10 +185,12 @@ export default class AbstractBoss extends LivingEntity {
189185

190186
this.positionData.angle = Math.atan2(this.ai.inputs.mouse.y - y, this.ai.inputs.mouse.x - x);
191187
}
188+
192189
this.velocity.add({
193190
x: this.inputs.movement.x * this.movementSpeed,
194191
y: this.inputs.movement.y * this.movementSpeed,
195192
});
193+
196194
this.inputs.movement.set({
197195
x: 0,
198196
y: 0

src/Game.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,15 @@ export default class GameServer {
218218

219219
/** Ticks the game. */
220220
private tickLoop() {
221-
222221
this.tick += 1;
223222

223+
this.entities.collisionManager.preTick(this.tick);
224+
224225
// process inputs before ticking entities for lower input latency
225226
for (const client of this.clients) client.tick(this.tick);
226-
227+
227228
this.entities.tick(this.tick);
229+
230+
this.entities.collisionManager.postTick(this.tick);
228231
}
229232
}

src/Native/Arena.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ export default class ArenaEntity extends Entity implements TeamGroupEntity {
339339
[~~(Math.random() * 5)];
340340

341341
this.boss = new TBoss(this.game);
342+
343+
const { x, y } = this.game.arena.findSpawnLocation();
344+
this.boss.positionData.values.x = x;
345+
this.boss.positionData.values.y = y;
342346
}
343347

344348
public tick(tick: number) {

src/Native/Manager.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ export default class EntityManager {
135135

136136
/** Ticks all entities in the game. */
137137
public tick(tick: number) {
138-
this.collisionManager.preTick(this.game.tick);
139-
140138
while (!this.inner[this.lastId] && this.lastId >= 0) {
141139
this.lastId -= 1;
142140
}
@@ -190,7 +188,5 @@ export default class EntityManager {
190188
entity.wipeState();
191189
}
192190
}
193-
194-
this.collisionManager.postTick(this.game.tick);
195191
}
196192
}

0 commit comments

Comments
 (0)