UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

700 lines (699 loc) • 29.9 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DebugDisplay = void 0; const decorators_1 = require("../../../decorators"); const console_1 = require("../../../functions/console"); const Feature_1 = require("../../private/Feature"); const DebugDisplayBomb_1 = require("./debugDisplay/DebugDisplayBomb"); const DebugDisplayDoor_1 = require("./debugDisplay/DebugDisplayDoor"); const DebugDisplayEffect_1 = require("./debugDisplay/DebugDisplayEffect"); const DebugDisplayFamiliar_1 = require("./debugDisplay/DebugDisplayFamiliar"); const DebugDisplayKnife_1 = require("./debugDisplay/DebugDisplayKnife"); const DebugDisplayLaser_1 = require("./debugDisplay/DebugDisplayLaser"); const DebugDisplayNPC_1 = require("./debugDisplay/DebugDisplayNPC"); const DebugDisplayPickup_1 = require("./debugDisplay/DebugDisplayPickup"); const DebugDisplayPit_1 = require("./debugDisplay/DebugDisplayPit"); const DebugDisplayPlayer_1 = require("./debugDisplay/DebugDisplayPlayer"); const DebugDisplayPoop_1 = require("./debugDisplay/DebugDisplayPoop"); const DebugDisplayPressurePlate_1 = require("./debugDisplay/DebugDisplayPressurePlate"); const DebugDisplayProjectile_1 = require("./debugDisplay/DebugDisplayProjectile"); const DebugDisplayRock_1 = require("./debugDisplay/DebugDisplayRock"); const DebugDisplaySlot_1 = require("./debugDisplay/DebugDisplaySlot"); const DebugDisplaySpikes_1 = require("./debugDisplay/DebugDisplaySpikes"); const DebugDisplayTear_1 = require("./debugDisplay/DebugDisplayTear"); const DebugDisplayTNT_1 = require("./debugDisplay/DebugDisplayTNT"); class DebugDisplay extends Feature_1.Feature { mod; player = new DebugDisplayPlayer_1.DebugDisplayPlayer(); // 1 tear = new DebugDisplayTear_1.DebugDisplayTear(); // 2 familiar = new DebugDisplayFamiliar_1.DebugDisplayFamiliar(); // 3 bomb = new DebugDisplayBomb_1.DebugDisplayBomb(); // 4 pickup = new DebugDisplayPickup_1.DebugDisplayPickup(); // 5 slot = new DebugDisplaySlot_1.DebugDisplaySlot(); // 6 laser = new DebugDisplayLaser_1.DebugDisplayLaser(); // 7 knife = new DebugDisplayKnife_1.DebugDisplayKnife(); // 8 projectile = new DebugDisplayProjectile_1.DebugDisplayProjectile(); // 9 effect = new DebugDisplayEffect_1.DebugDisplayEffect(); // 1000 npc = new DebugDisplayNPC_1.DebugDisplayNPC(); rock = new DebugDisplayRock_1.DebugDisplayRock(); // 2, 3, 4, 5, 6, 22, 24, 25, 26, 27 pit = new DebugDisplayPit_1.DebugDisplayPit(); // 7 spikes = new DebugDisplaySpikes_1.DebugDisplaySpikes(); // 8, 9 tnt = new DebugDisplayTNT_1.DebugDisplayTNT(); // 12 poop = new DebugDisplayPoop_1.DebugDisplayPoop(); // 14 door = new DebugDisplayDoor_1.DebugDisplayDoor(); // 16 pressurePlate = new DebugDisplayPressurePlate_1.DebugDisplayPressurePlate(); // 20 /** @internal */ constructor(mod) { super(); this.mod = mod; } // ------------- // Set Functions // ------------- /** * If the "togglePlayerDisplay" function is called, text will be drawn on the screen next to each * player. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * For example, this would draw the number of the player's collectibles next to their head: * * ```ts * setPlayerDisplay((player) => { * return `collectible count: ${player.GetCollectibleCount()}`; * }); * ``` * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setPlayerDisplay(textCallback) { this.player.textCallback = textCallback; } /** * If the "toggleTearDisplay" function is called, text will be drawn on the screen next to each * tear. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setTearDisplay(textCallback) { this.tear.textCallback = textCallback; } /** * If the "toggleFamiliarDisplay" function is called, text will be drawn on the screen next to * each familiar. Use this function to specify a callback function that returns the string that * should be drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setFamiliarDisplay(textCallback) { this.familiar.textCallback = textCallback; } /** * If the "toggleBombDisplay" function is called, text will be drawn on the screen next to each * bomb. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setBombDisplay(textCallback) { this.bomb.textCallback = textCallback; } /** * If the "togglePickupDisplay" function is called, text will be drawn on the screen next to each * pickup. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setPickupDisplay(textCallback) { this.pickup.textCallback = textCallback; } /** * If the "toggleSlotDisplay" function is called, text will be drawn on the screen next to each * slot. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setSlotDisplay(textCallback) { this.slot.textCallback = textCallback; } /** * If the "toggleLaserDisplay" function is called, text will be drawn on the screen next to each * laser. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setLaserDisplay(textCallback) { this.laser.textCallback = textCallback; } /** * If the "toggleKnifeDisplay" function is called, text will be drawn on the screen next to each * knife. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setKnifeDisplay(textCallback) { this.knife.textCallback = textCallback; } /** * If the "toggleProjectileDisplay" function is called, text will be drawn on the screen next to * each projectile. Use this function to specify a callback function that returns the string that * should be drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setProjectileDisplay(textCallback) { this.projectile.textCallback = textCallback; } /** * If the "extra console commands" feature is specified, the "effectDisplay" console command will * draw text on the screen next to each effect. Use this function to specify a callback function * that returns the string that should be drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setEffectDisplay(textCallback) { this.effect.textCallback = textCallback; } /** * If the "toggleNPCDisplay" function is called, text will be drawn on the screen next to each * NPC. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setNPCDisplay(textCallback) { this.npc.textCallback = textCallback; } /** * If the "toggleRockDisplay" function is called, text will be drawn on the screen next to each * rock. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setRockDisplay(textCallback) { this.rock.textCallback = textCallback; } /** * If the "togglePitDisplay" function is called, text will be drawn on the screen next to each * pit. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setPitDisplay(textCallback) { this.pit.textCallback = textCallback; } /** * If the "toggleSpikesDisplay" function is called, text will be drawn on the screen next to each * spikes. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setSpikesDisplay(textCallback) { this.spikes.textCallback = textCallback; } /** * If the "toggleTNTDisplay" function is called, text will be drawn on the screen next to each * TNT. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setTNTDisplay(textCallback) { this.tnt.textCallback = textCallback; } /** * If the "togglePoopDisplay" function is called, text will be drawn on the screen next to each * poop. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setPoopDisplay(textCallback) { this.poop.textCallback = textCallback; } /** * If the "toggleDoorDisplay" function is called, text will be drawn on the screen next to each * door. Use this function to specify a callback function that returns the string that should be * drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setDoorDisplay(textCallback) { this.door.textCallback = textCallback; } /** * If the "togglePressurePlateDisplay" function is called, text will be drawn on the screen next * to each pressure plate. Use this function to specify a callback function that returns the * string that should be drawn. * * Once the function is set, the library will call it automatically on every frame. For this * reason, you typically only need to set the function once at the beginning of your mod. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @public */ setPressurePlateDisplay(textCallback) { this.pressurePlate.textCallback = textCallback; } // ---------------- // Toggle Functions // ---------------- toggleFeature(feature, featureName, force) { let shouldInit = !feature.initialized; if (force !== undefined) { shouldInit = force; } if (shouldInit) { this.mod.initFeature(feature); } else { this.mod.uninitFeature(feature); } (0, console_1.printEnabled)(feature.initialized, `${featureName} display`); } /** * Toggles the debug display for players, which will draw text on the screen next to each player. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ togglePlayerDisplay(force) { this.toggleFeature(this.player, "player", force); } /** * Toggles the debug display for tears, which will draw text on the screen next to each tear. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleTearDisplay(force) { this.toggleFeature(this.tear, "tear", force); } /** * Toggles the debug display for familiars, which will draw text on the screen next to each * familiar. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleFamiliarDisplay(force) { this.toggleFeature(this.familiar, "familiar", force); } /** * Toggles the debug display for bombs, which will draw text on the screen next to each bomb. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleBombDisplay(force) { this.toggleFeature(this.bomb, "bomb", force); } /** * Toggles the debug display for pickups, which will draw text on the screen next to each pickup. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ togglePickupDisplay(force) { this.toggleFeature(this.pickup, "pickup", force); } /** * Toggles the debug display for slots, which will draw text on the screen next to each slot. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleSlotDisplay(force) { this.toggleFeature(this.slot, "slot", force); } /** * Toggles the debug display for lasers, which will draw text on the screen next to each laser. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleLaserDisplay(force) { this.toggleFeature(this.laser, "laser", force); } /** * Toggles the debug display for knives, which will draw text on the screen next to each knife. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleKnifeDisplay(force) { this.toggleFeature(this.knife, "knife", force); } /** * Toggles the debug display for projectiles, which will draw text on the screen next to each * projectile. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleProjectileDisplay(force) { this.toggleFeature(this.projectile, "projectile", force); } /** * Toggles the debug display for effects, which will draw text on the screen next to each effect. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleEffectDisplay(force) { this.toggleFeature(this.effect, "effect", force); } /** * Toggles the debug display for NPCs, which will draw text on the screen next to each NPC. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleNPCDisplay(force) { this.toggleFeature(this.npc, "NPC", force); } /** * Toggles the debug display for rocks, which will draw text on the screen next to each rock. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleRockDisplay(force) { this.toggleFeature(this.rock, "rock", force); } /** * Toggles the debug display for pits, which will draw text on the screen next to each pit. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ togglePitDisplay(force) { this.toggleFeature(this.pit, "pit", force); } /** * Toggles the debug display for spikes, which will draw text on the screen next to each spike. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleSpikesDisplay(force) { this.toggleFeature(this.spikes, "spikes", force); } /** * Toggles the debug display for TNT, which will draw text on the screen next to each TNT. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleTNTDisplay(force) { this.toggleFeature(this.tnt, "tnt", force); } /** * Toggles the debug display for poops, which will draw text on the screen next to each poop. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ togglePoopDisplay(force) { this.toggleFeature(this.poop, "poop", force); } /** * Toggles the debug display for doors, which will draw text on the screen next to each door. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ toggleDoorDisplay(force) { this.toggleFeature(this.door, "door", force); } /** * Toggles the debug display for pressure plates, which will draw text on the screen next to each * pressure plate. * * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. * * @param force Optional. A boolean that represents the value to force the display to. For * example, you can specify true to always make the display turn on, regardless of * whether it is already on. * @public */ togglePressurePlateDisplay(force) { this.toggleFeature(this.pressurePlate, "pressure plate", force); } } exports.DebugDisplay = DebugDisplay; __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setPlayerDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setTearDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setFamiliarDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setBombDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setPickupDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setSlotDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setLaserDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setKnifeDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setProjectileDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setEffectDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setNPCDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setRockDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setPitDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setSpikesDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setTNTDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setPoopDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setDoorDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "setPressurePlateDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "togglePlayerDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleTearDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleFamiliarDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleBombDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "togglePickupDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleSlotDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleLaserDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleKnifeDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleProjectileDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleEffectDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleNPCDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleRockDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "togglePitDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleSpikesDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleTNTDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "togglePoopDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "toggleDoorDisplay", null); __decorate([ decorators_1.Exported ], DebugDisplay.prototype, "togglePressurePlateDisplay", null);