import * as PIXI from "../../pixi/pixi.mjs" import { addToCleaningQueue } from "../GameState/GameState"; /** * Base class for all game objects. */ export class GameObject { //currently not in use majorId = -1; //primary game object id minorId = -1; #tickEnabled = true; #markedPendingKill = false; // markedAsInitialized = false; /** * GameObject id * @param {Boolean} tickAble */ constructor(tickAble = true) { this.#tickEnabled = tickAble; }; /** * inits GameObject with id. Without id object will not be added to the scene. id must be unique */ init_byGameState(major_id, minor_id) { this.majorId = major_id; this.minorId = minor_id; }; /** * Removes object from scene in the next frame and delete it completely after several frames */ kill() { if(this.#markedPendingKill) return; this.preDestroy(); this.#markedPendingKill = true; addToCleaningQueue(this.majorId, this.minorId); }; /** * called before object's destruction */ preDestroy(){}; /** * called after spawn */ onSpawn(){}; /** * called after initialization */ onInit(){}; /** * called every frame * @param {PIXI.Ticker} ticker */ tick(ticker){}; isTickEnabled(){return this.#tickEnabled;}; isMarkedPendingKill(){return this.#markedPendingKill;}; };