From 8260ad825b26b6f061f54514aee5a88de800d717 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Mon, 14 Apr 2025 20:42:01 -0400 Subject: [PATCH] ShellExecution --- src/core/execution/ShellExecution.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/execution/ShellExecution.ts b/src/core/execution/ShellExecution.ts index c2def8f79..2a4161fac 100644 --- a/src/core/execution/ShellExecution.ts +++ b/src/core/execution/ShellExecution.ts @@ -6,9 +6,9 @@ import { PathFinder } from "../pathfinding/PathFinding"; export class ShellExecution implements Execution { private active = true; - private pathFinder: PathFinder; - private shell: Unit; - private mg: Game; + private pathFinder: PathFinder | null = null; + private shell: Unit | null = null; + private mg: Game | null = null; private destroyAtTick: number = -1; constructor( @@ -24,7 +24,10 @@ export class ShellExecution implements Execution { } tick(ticks: number): void { - if (this.shell == null) { + if (this.mg === null || this.pathFinder === null) { + throw new Error("Not initialized"); + } + if (this.shell === null) { this.shell = this._owner.buildUnit(UnitType.Shell, 0, this.spawn); } if (!this.shell.isActive()) { @@ -33,15 +36,15 @@ export class ShellExecution implements Execution { } if ( !this.target.isActive() || - this.target.owner() == this.shell.owner() || - (this.destroyAtTick != -1 && this.mg.ticks() >= this.destroyAtTick) + this.target.owner() === this.shell.owner() || + (this.destroyAtTick !== -1 && this.mg.ticks() >= this.destroyAtTick) ) { this.shell.delete(false); this.active = false; return; } - if (this.destroyAtTick == -1 && !this.ownerUnit.isActive()) { + if (this.destroyAtTick === -1 && !this.ownerUnit.isActive()) { this.destroyAtTick = this.mg.ticks() + this.mg.config().warshipShellLifetime(); }