From ffc5679970e74598599e7b7391ab1a1b1be81fb6 Mon Sep 17 00:00:00 2001 From: Math-Man Date: Sat, 9 Nov 2024 10:05:12 +0300 Subject: [PATCH] Formatted some files, cleaned up. --- src/callbacks/MCEntityTakeDamage.ts | 38 +- src/callbacks/MCEvaluateCache.ts | 20 +- src/callbacks/MCPostCollectibleRemoved.ts | 12 +- src/callbacks/MCPostGameStarted.ts | 14 +- src/callbacks/MCPostItemPickup.ts | 30 +- src/callbacks/MCPostNewRoom.ts | 8 +- src/callbacks/MCPostPlayerInit.ts | 4 +- src/callbacks/MCPostRender.ts | 12 +- src/callbacks/MCPostRenderPickup.ts | 8 +- src/callbacks/MCPostRenderPlayer.ts | 8 +- src/callbacks/MCPostTearUpdate.ts | 8 +- src/callbacks/MCPostUpdate.ts | 8 +- src/callbacks/MCPreGameExit.ts | 14 +- src/config/McmHandler.ts | 403 +++++++++++----------- src/data/StateData.ts | 68 ++-- src/data/Tuneable.ts | 126 +++---- src/data/saveFile/SaveDataHandler.ts | 2 - src/data/saveFile/SaveDataManager.ts | 3 +- src/data/saveFile/SaveDataSource.ts | 2 + 19 files changed, 393 insertions(+), 395 deletions(-) diff --git a/src/callbacks/MCEntityTakeDamage.ts b/src/callbacks/MCEntityTakeDamage.ts index 06960a3..8c1d817 100644 --- a/src/callbacks/MCEntityTakeDamage.ts +++ b/src/callbacks/MCEntityTakeDamage.ts @@ -1,28 +1,28 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { DamageFlagsCustom } from "../enums/DamageFlagsCustom"; -import { playerHasSamuraisBladeItem } from "../helpers/Helpers"; -import { SamuraiBladeEntityDamage } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {DamageFlagsCustom} from "../enums/DamageFlagsCustom"; +import {playerHasSamuraisBladeItem} from "../helpers/Helpers"; +import {SamuraiBladeEntityDamage} from "../items/SamuraisBlade"; export function entityTakeDamageInit(mod: Mod): void { - mod.AddCallback(ModCallback.ENTITY_TAKE_DMG, entityTakeDamageMain); + mod.AddCallback(ModCallback.ENTITY_TAKE_DMG, entityTakeDamageMain); } function entityTakeDamageMain( - tookDamage: Entity, - damageAmount: number, - damageFlags: BitFlag, - damageSource: EntityRef, - damageCountdownFrames: number, + tookDamage: Entity, + damageAmount: number, + damageFlags: BitFlag, + damageSource: EntityRef, + damageCountdownFrames: number, ): boolean | undefined { - const player = damageSource.Entity?.ToPlayer(); + const player = damageSource.Entity?.ToPlayer(); - // flog(`Extending berserk! ${player} ${tookDamage.HasMortalDamage()}}`); - // if (player) { - // extendBerserk(player); - // } + // flog(`Extending berserk! ${player} ${tookDamage.HasMortalDamage()}}`); + // if (player) { + // extendBerserk(player); + // } - if (player !== undefined && playerHasSamuraisBladeItem(player) && tookDamage.IsVulnerableEnemy() && damageFlags === DamageFlagsCustom.SB_BLADE_DAMAGE) { - SamuraiBladeEntityDamage(tookDamage, damageAmount, damageFlags, damageSource, damageCountdownFrames); - } - return undefined; + if (player !== undefined && playerHasSamuraisBladeItem(player) && tookDamage.IsVulnerableEnemy() && damageFlags === DamageFlagsCustom.SB_BLADE_DAMAGE) { + SamuraiBladeEntityDamage(tookDamage, damageAmount, damageFlags, damageSource, damageCountdownFrames); + } + return undefined; } diff --git a/src/callbacks/MCEvaluateCache.ts b/src/callbacks/MCEvaluateCache.ts index fbfe74e..fe47fab 100644 --- a/src/callbacks/MCEvaluateCache.ts +++ b/src/callbacks/MCEvaluateCache.ts @@ -1,18 +1,18 @@ -import { CacheFlag, ModCallback } from "isaac-typescript-definitions"; -import { getPlayerStateDataNoCreate } from "../data/StateData"; -import { flog } from "../helpers/DebugHelper"; -import { playerHasSamuraisBladeItem } from "../helpers/Helpers"; -import { SamuraiBladeEvalCache } from "../items/SamuraisBlade"; +import {CacheFlag, ModCallback} from "isaac-typescript-definitions"; +import {getPlayerStateDataNoCreate} from "../data/StateData"; +import {flog} from "../helpers/DebugHelper"; +import {playerHasSamuraisBladeItem} from "../helpers/Helpers"; +import {SamuraiBladeEvalCache} from "../items/SamuraisBlade"; const LOG_ID = "MCEvaluateCache"; export function evaluateCacheInit(mod: Mod): void { - mod.AddCallback(ModCallback.EVALUATE_CACHE, main); + mod.AddCallback(ModCallback.EVALUATE_CACHE, main); } function main(player: EntityPlayer, cacheFlag: CacheFlag) { - if (cacheFlag === CacheFlag.LUCK && getPlayerStateDataNoCreate(player) === undefined && playerHasSamuraisBladeItem(player)) { - flog("Player is now motivated", LOG_ID); - SamuraiBladeEvalCache(player, cacheFlag); - } + if (cacheFlag === CacheFlag.LUCK && getPlayerStateDataNoCreate(player) === undefined && playerHasSamuraisBladeItem(player)) { + flog("Player is now motivated", LOG_ID); + SamuraiBladeEvalCache(player, cacheFlag); + } } diff --git a/src/callbacks/MCPostCollectibleRemoved.ts b/src/callbacks/MCPostCollectibleRemoved.ts index 9cbe558..92f8b52 100644 --- a/src/callbacks/MCPostCollectibleRemoved.ts +++ b/src/callbacks/MCPostCollectibleRemoved.ts @@ -1,12 +1,12 @@ -import { CollectibleType } from "isaac-typescript-definitions"; -import { ModCallbackCustom, ModUpgraded } from "isaacscript-common"; -import { CollectibleTypeCustom } from "../enums/CollectibleTypeCustom"; -import { infoLog } from "../helpers/DebugHelper"; +import {CollectibleType} from "isaac-typescript-definitions"; +import {ModCallbackCustom, ModUpgraded} from "isaacscript-common"; +import {CollectibleTypeCustom} from "../enums/CollectibleTypeCustom"; +import {infoLog} from "../helpers/DebugHelper"; export function postCollectibleRemoved(mod: ModUpgraded): void { - mod.AddCallbackCustom(ModCallbackCustom.POST_PLAYER_COLLECTIBLE_REMOVED, main, CollectibleTypeCustom.SB_SAMURAI_BLADE); + mod.AddCallbackCustom(ModCallbackCustom.POST_PLAYER_COLLECTIBLE_REMOVED, main, CollectibleTypeCustom.SB_SAMURAI_BLADE); } function main(player: EntityPlayer, collectibleType: CollectibleType) { - infoLog(`Item is gone, this is so sad. so sad indeed... ${collectibleType} `); + infoLog(`Item is gone, this is so sad. so sad indeed... ${collectibleType} `); } diff --git a/src/callbacks/MCPostGameStarted.ts b/src/callbacks/MCPostGameStarted.ts index 3773d9e..3082223 100644 --- a/src/callbacks/MCPostGameStarted.ts +++ b/src/callbacks/MCPostGameStarted.ts @@ -1,13 +1,13 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { ModUpgraded } from "isaacscript-common"; -import { SamuraiBladePostGameStarted } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {ModUpgraded} from "isaacscript-common"; +import {SamuraiBladePostGameStarted} from "../items/SamuraisBlade"; export function postGameStartedInit(mod: ModUpgraded): void { - mod.AddCallback(ModCallback.POST_GAME_STARTED, () => { - main(mod); - }); + mod.AddCallback(ModCallback.POST_GAME_STARTED, () => { + main(mod); + }); } function main(mod: ModUpgraded) { - SamuraiBladePostGameStarted(mod); + SamuraiBladePostGameStarted(mod); } diff --git a/src/callbacks/MCPostItemPickup.ts b/src/callbacks/MCPostItemPickup.ts index 7b3444f..fc6076f 100644 --- a/src/callbacks/MCPostItemPickup.ts +++ b/src/callbacks/MCPostItemPickup.ts @@ -1,23 +1,19 @@ -import { ItemType } from "isaac-typescript-definitions"; -import { - ModCallbackCustom, - ModUpgraded, - PickingUpItem, -} from "isaacscript-common"; -import { CollectibleTypeCustom } from "../enums/CollectibleTypeCustom"; -import { flog } from "../helpers/DebugHelper"; -import { SamuraiBladePostPickup } from "../items/SamuraisBlade"; +import {ItemType} from "isaac-typescript-definitions"; +import {ModCallbackCustom, ModUpgraded, PickingUpItem,} from "isaacscript-common"; +import {CollectibleTypeCustom} from "../enums/CollectibleTypeCustom"; +import {flog} from "../helpers/DebugHelper"; +import {SamuraiBladePostPickup} from "../items/SamuraisBlade"; export function postItemPickupInit(mod: ModUpgraded): void { - mod.AddCallbackCustom( - ModCallbackCustom.POST_ITEM_PICKUP, - main, - ItemType.PASSIVE, - CollectibleTypeCustom.SB_SAMURAI_BLADE, - ); + mod.AddCallbackCustom( + ModCallbackCustom.POST_ITEM_PICKUP, + main, + ItemType.PASSIVE, + CollectibleTypeCustom.SB_SAMURAI_BLADE, + ); } function main(player: EntityPlayer, pickingUpItem: PickingUpItem) { - flog("Item:" + pickingUpItem, "CALLBACK"); - SamuraiBladePostPickup(player); + flog("Item:" + pickingUpItem, "CALLBACK"); + SamuraiBladePostPickup(player); } diff --git a/src/callbacks/MCPostNewRoom.ts b/src/callbacks/MCPostNewRoom.ts index d41e7df..1c60282 100644 --- a/src/callbacks/MCPostNewRoom.ts +++ b/src/callbacks/MCPostNewRoom.ts @@ -1,10 +1,10 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { SamuraiBladePostNewRoom } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {SamuraiBladePostNewRoom} from "../items/SamuraisBlade"; export function postNewRoomInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_NEW_ROOM, main); + mod.AddCallback(ModCallback.POST_NEW_ROOM, main); } function main() { - SamuraiBladePostNewRoom(); + SamuraiBladePostNewRoom(); } diff --git a/src/callbacks/MCPostPlayerInit.ts b/src/callbacks/MCPostPlayerInit.ts index 89f6821..c06e8cc 100644 --- a/src/callbacks/MCPostPlayerInit.ts +++ b/src/callbacks/MCPostPlayerInit.ts @@ -1,7 +1,7 @@ -import { ModCallback } from "isaac-typescript-definitions"; +import {ModCallback} from "isaac-typescript-definitions"; export function postPlayerInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_PLAYER_INIT, main); + mod.AddCallback(ModCallback.POST_PLAYER_INIT, main); } function main() { diff --git a/src/callbacks/MCPostRender.ts b/src/callbacks/MCPostRender.ts index 8d5857a..d9d50c5 100644 --- a/src/callbacks/MCPostRender.ts +++ b/src/callbacks/MCPostRender.ts @@ -1,13 +1,13 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { renderHudForPlayers } from "../items/samuraiBlade/hud/HudRenderer"; -import { SamuraiBladePostRender } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {renderHudForPlayers} from "../items/samuraiBlade/hud/HudRenderer"; +import {SamuraiBladePostRender} from "../items/SamuraisBlade"; export function postRenderInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_RENDER, main); + mod.AddCallback(ModCallback.POST_RENDER, main); } function main() { - SamuraiBladePostRender(); + SamuraiBladePostRender(); - renderHudForPlayers(); + renderHudForPlayers(); } diff --git a/src/callbacks/MCPostRenderPickup.ts b/src/callbacks/MCPostRenderPickup.ts index 8a723b0..ca71c01 100644 --- a/src/callbacks/MCPostRenderPickup.ts +++ b/src/callbacks/MCPostRenderPickup.ts @@ -1,10 +1,10 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { SamuraiBladePostRenderPickup } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {SamuraiBladePostRenderPickup} from "../items/SamuraisBlade"; export function postRenderPickupInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_PICKUP_RENDER, main); + mod.AddCallback(ModCallback.POST_PICKUP_RENDER, main); } function main() { - SamuraiBladePostRenderPickup(); + SamuraiBladePostRenderPickup(); } diff --git a/src/callbacks/MCPostRenderPlayer.ts b/src/callbacks/MCPostRenderPlayer.ts index c94ce43..154ac7e 100644 --- a/src/callbacks/MCPostRenderPlayer.ts +++ b/src/callbacks/MCPostRenderPlayer.ts @@ -1,10 +1,10 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { SamuraiBladePostRenderPlayer } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {SamuraiBladePostRenderPlayer} from "../items/SamuraisBlade"; export function postRenderPlayerInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_PLAYER_RENDER, main); + mod.AddCallback(ModCallback.POST_PLAYER_RENDER, main); } function main() { - SamuraiBladePostRenderPlayer(); + SamuraiBladePostRenderPlayer(); } diff --git a/src/callbacks/MCPostTearUpdate.ts b/src/callbacks/MCPostTearUpdate.ts index 0398932..0ea0732 100644 --- a/src/callbacks/MCPostTearUpdate.ts +++ b/src/callbacks/MCPostTearUpdate.ts @@ -1,10 +1,10 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { SamuraiBladePostTearUpdate } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {SamuraiBladePostTearUpdate} from "../items/SamuraisBlade"; export function postTearUpdateInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_TEAR_UPDATE, main); + mod.AddCallback(ModCallback.POST_TEAR_UPDATE, main); } function main(tear: EntityTear) { - SamuraiBladePostTearUpdate(tear); + SamuraiBladePostTearUpdate(tear); } diff --git a/src/callbacks/MCPostUpdate.ts b/src/callbacks/MCPostUpdate.ts index 45731f7..89bea22 100644 --- a/src/callbacks/MCPostUpdate.ts +++ b/src/callbacks/MCPostUpdate.ts @@ -1,10 +1,10 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { SamuraiBladePostUpdate } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {SamuraiBladePostUpdate} from "../items/SamuraisBlade"; export function postUpdateInit(mod: Mod): void { - mod.AddCallback(ModCallback.POST_UPDATE, main); + mod.AddCallback(ModCallback.POST_UPDATE, main); } function main() { - SamuraiBladePostUpdate(); + SamuraiBladePostUpdate(); } diff --git a/src/callbacks/MCPreGameExit.ts b/src/callbacks/MCPreGameExit.ts index beb1573..f35cf61 100644 --- a/src/callbacks/MCPreGameExit.ts +++ b/src/callbacks/MCPreGameExit.ts @@ -1,13 +1,13 @@ -import { ModCallback } from "isaac-typescript-definitions"; -import { ModUpgraded } from "isaacscript-common"; -import { SamuraiBladePreGameExit } from "../items/SamuraisBlade"; +import {ModCallback} from "isaac-typescript-definitions"; +import {ModUpgraded} from "isaacscript-common"; +import {SamuraiBladePreGameExit} from "../items/SamuraisBlade"; export function preGameExitInit(mod: ModUpgraded): void { - mod.AddCallback(ModCallback.PRE_GAME_EXIT, () => { - main(mod); - }); + mod.AddCallback(ModCallback.PRE_GAME_EXIT, () => { + main(mod); + }); } function main(mod: ModUpgraded) { - SamuraiBladePreGameExit(mod); + SamuraiBladePreGameExit(mod); } diff --git a/src/config/McmHandler.ts b/src/config/McmHandler.ts index cc82117..27c4831 100644 --- a/src/config/McmHandler.ts +++ b/src/config/McmHandler.ts @@ -1,233 +1,234 @@ -import { LOSCheckBehaviourAsString } from "../enums/LineOfSightCheckBehaviour"; -import { TearFiringBehaviourAsString } from "../enums/TearFiringBehaviour"; -import { flog, infoLog } from "../helpers/DebugHelper"; -import { HudPositionOptionsAsString } from "../items/samuraiBlade/hud/HudPositionOptions"; +import {LOSCheckBehaviourAsString} from "../enums/LineOfSightCheckBehaviour"; +import {TearFiringBehaviourAsString} from "../enums/TearFiringBehaviour"; +import {flog, infoLog} from "../helpers/DebugHelper"; +import {HudPositionOptionsAsString} from "../items/samuraiBlade/hud/HudPositionOptions"; import {configDataObject} from "../data/saveFile/ConfigSaveDataHandler"; const LOG_ID = "MCM CONFIG"; export function setupMCM(): void { - flog("Setting up MCM for samurai blade!", LOG_ID); - const modCategoryName = "Samurai's Blade"; - - // Reset category if it exists - ModConfigMenu?.RemoveCategory(modCategoryName); - ModConfigMenu?.UpdateCategory(modCategoryName, { - IsOld: false, - Name: modCategoryName, - Info: "Samurai-Blade settings.", - }); - - ModConfigMenu?.AddText(modCategoryName, "Settings", () => "General Settings"); - ModConfigMenu?.AddSpace(modCategoryName, "Settings"); - - setupConfigSpawnItemInFirstRoom(modCategoryName); - setupConfigPrintDebugInfo(modCategoryName); - setupConfigParticleMultiplier(modCategoryName); - setupConfigTearFiringBehaviour(modCategoryName); - setupConfigLineOfSightCheck(modCategoryName); - setupConfigBladePicksUpItems(modCategoryName); - setupConfigHudPosition(modCategoryName); - - ModConfigMenu?.AddText(modCategoryName, "Tuning", () => "Change item stats"); - ModConfigMenu?.AddSpace(modCategoryName, "Tuning"); - setupConfigDamageMultiplier(modCategoryName); - - setupConfigRangeMultiplier(modCategoryName); - - ModConfigMenu?.AddSpace(modCategoryName, "Tuning"); - ModConfigMenu?.AddText(modCategoryName, "Tuning", () => "More settings might be added later on."); + flog("Setting up MCM for samurai blade!", LOG_ID); + const modCategoryName = "Samurai's Blade"; + + // Reset category if it exists + ModConfigMenu?.RemoveCategory(modCategoryName); + ModConfigMenu?.UpdateCategory(modCategoryName, { + IsOld: false, + Name: modCategoryName, + Info: "Samurai-Blade settings.", + }); + + ModConfigMenu?.AddText(modCategoryName, "Settings", () => "General Settings"); + ModConfigMenu?.AddSpace(modCategoryName, "Settings"); + + setupConfigSpawnItemInFirstRoom(modCategoryName); + setupConfigPrintDebugInfo(modCategoryName); + setupConfigParticleMultiplier(modCategoryName); + setupConfigTearFiringBehaviour(modCategoryName); + setupConfigLineOfSightCheck(modCategoryName); + setupConfigBladePicksUpItems(modCategoryName); + setupConfigHudPosition(modCategoryName); + + ModConfigMenu?.AddText(modCategoryName, "Tuning", () => "Change item stats"); + ModConfigMenu?.AddSpace(modCategoryName, "Tuning"); + setupConfigDamageMultiplier(modCategoryName); + + setupConfigRangeMultiplier(modCategoryName); + + ModConfigMenu?.AddSpace(modCategoryName, "Tuning"); + ModConfigMenu?.AddText(modCategoryName, "Tuning", () => "More settings might be added later on."); } function setupConfigHudPosition(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configHudPosition; - }, - Display(): string { - return `Hud Position: ${HudPositionOptionsAsString(configDataObject.persistent.configHudPosition)}`; - }, - Info: ["Change where the hud is located"], - Maximum: 3, - Minimum: 0, - ModifyBy: 1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configHudPosition = newValue; - } - infoLog(`Hud Position Changed: ${configDataObject.persistent.configHudPosition}}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configHudPosition; + }, + Display(): string { + return `Hud Position: ${HudPositionOptionsAsString(configDataObject.persistent.configHudPosition)}`; + }, + Info: ["Change where the hud is located"], + Maximum: 3, + Minimum: 0, + ModifyBy: 1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configHudPosition = newValue; + } + infoLog(`Hud Position Changed: ${configDataObject.persistent.configHudPosition}}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } function setupConfigSpawnItemInFirstRoom(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configSpawnItemInFirstRoom; - }, - Display(): string { - return "Spawn in the starting room :" + configDataObject.persistent.configSpawnItemInFirstRoom; - }, - Info: ["Should The Samurai Blade spawn in the first room?"], - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "boolean") { - configDataObject.persistent.configSpawnItemInFirstRoom = newValue; - } - }, - Type: ModConfigMenuOptionType.BOOLEAN, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configSpawnItemInFirstRoom; + }, + Display(): string { + return "Spawn in the starting room :" + configDataObject.persistent.configSpawnItemInFirstRoom; + }, + Info: ["Should The Samurai Blade spawn in the first room?"], + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "boolean") { + configDataObject.persistent.configSpawnItemInFirstRoom = newValue; + } + }, + Type: ModConfigMenuOptionType.BOOLEAN, + }); } + function setupConfigPrintDebugInfo(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configPrintDebugInfo; - }, - Display(): string { - return "Print (crude) debug info :" + configDataObject.persistent.configPrintDebugInfo; - }, - Info: ["Display debug info on screen and log to console."], - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "boolean") { - configDataObject.persistent.configPrintDebugInfo = newValue; - } - infoLog(`Display debug info: ${configDataObject.persistent.configPrintDebugInfo}`, LOG_ID); - }, - Type: ModConfigMenuOptionType.BOOLEAN, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configPrintDebugInfo; + }, + Display(): string { + return "Print (crude) debug info :" + configDataObject.persistent.configPrintDebugInfo; + }, + Info: ["Display debug info on screen and log to console."], + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "boolean") { + configDataObject.persistent.configPrintDebugInfo = newValue; + } + infoLog(`Display debug info: ${configDataObject.persistent.configPrintDebugInfo}`, LOG_ID); + }, + Type: ModConfigMenuOptionType.BOOLEAN, + }); } function setupConfigParticleMultiplier(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configParticleMultiplier; - }, - Display(): string { - return `Current Particle Multiplier: ${configDataObject.persistent.configParticleMultiplier}`; - }, - Info: ["Change the intensity of particle effects."], - Maximum: 5.0, - Minimum: 0.1, - ModifyBy: 0.1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configParticleMultiplier = newValue; - } - infoLog(`Particles value changed: ${configDataObject.persistent.configParticleMultiplier}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configParticleMultiplier; + }, + Display(): string { + return `Current Particle Multiplier: ${configDataObject.persistent.configParticleMultiplier}`; + }, + Info: ["Change the intensity of particle effects."], + Maximum: 5.0, + Minimum: 0.1, + ModifyBy: 0.1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configParticleMultiplier = newValue; + } + infoLog(`Particles value changed: ${configDataObject.persistent.configParticleMultiplier}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } function setupConfigTearFiringBehaviour(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configTearFiringBehaviour; - }, - Display(): string { - return `Tear behaviour: ${TearFiringBehaviourAsString(configDataObject.persistent.configTearFiringBehaviour)}`; - }, - Info: ["Change how the tear firing behaves", "Fire Delay Hack is the default"], - Maximum: 1, - Minimum: 0, - ModifyBy: 1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configTearFiringBehaviour = newValue; - } - infoLog(`Tear Firing Behaviour Changed: ${configDataObject.persistent.configTearFiringBehaviour}}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configTearFiringBehaviour; + }, + Display(): string { + return `Tear behaviour: ${TearFiringBehaviourAsString(configDataObject.persistent.configTearFiringBehaviour)}`; + }, + Info: ["Change how the tear firing behaves", "Fire Delay Hack is the default"], + Maximum: 1, + Minimum: 0, + ModifyBy: 1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configTearFiringBehaviour = newValue; + } + infoLog(`Tear Firing Behaviour Changed: ${configDataObject.persistent.configTearFiringBehaviour}}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } function setupConfigLineOfSightCheck(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configLineOfSightCheck; - }, - Display(): string { - return `Line-of-sight Check: ${LOSCheckBehaviourAsString(configDataObject.persistent.configLineOfSightCheck)}`; - }, - Info: ["Change how the Line of Sight check behaves", "Soft is the default", "Soft is more resource intensive and more accurate"], - Maximum: 2, - Minimum: 0, - ModifyBy: 1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configLineOfSightCheck = newValue; - } - infoLog(`LOS Check Behaviour Changed: ${configDataObject.persistent.configLineOfSightCheck}}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configLineOfSightCheck; + }, + Display(): string { + return `Line-of-sight Check: ${LOSCheckBehaviourAsString(configDataObject.persistent.configLineOfSightCheck)}`; + }, + Info: ["Change how the Line of Sight check behaves", "Soft is the default", "Soft is more resource intensive and more accurate"], + Maximum: 2, + Minimum: 0, + ModifyBy: 1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configLineOfSightCheck = newValue; + } + infoLog(`LOS Check Behaviour Changed: ${configDataObject.persistent.configLineOfSightCheck}}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } function setupConfigBladePicksUpItems(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Settings", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configBladePicksUpItems; - }, - Display(): string { - return `Attacks collects items: ${configDataObject.persistent.configBladePicksUpItems}`; - }, - Info: ["Should attacking collect items on the ground similarly to the spirit sword"], - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "boolean") { - configDataObject.persistent.configBladePicksUpItems = newValue; - } - infoLog(`Pickup Item Behaviour Changed: ${configDataObject.persistent.configBladePicksUpItems}}`); - }, - Type: ModConfigMenuOptionType.BOOLEAN, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Settings", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configBladePicksUpItems; + }, + Display(): string { + return `Attacks collects items: ${configDataObject.persistent.configBladePicksUpItems}`; + }, + Info: ["Should attacking collect items on the ground similarly to the spirit sword"], + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "boolean") { + configDataObject.persistent.configBladePicksUpItems = newValue; + } + infoLog(`Pickup Item Behaviour Changed: ${configDataObject.persistent.configBladePicksUpItems}}`); + }, + Type: ModConfigMenuOptionType.BOOLEAN, + }); } function setupConfigDamageMultiplier(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Tuning", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configAdjustmentDamageMultiplier; - }, - Display(): string { - return `Current Damage Multiplier: ${configDataObject.persistent.configAdjustmentDamageMultiplier}`; - }, - Info: ["Damage multiplier for the combined contact damage of the blade."], - Maximum: 10.0, - Minimum: 0.1, - ModifyBy: 0.1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configAdjustmentDamageMultiplier = newValue; - } - infoLog(`Damage value changed: ${configDataObject.persistent.configAdjustmentDamageMultiplier}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Tuning", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configAdjustmentDamageMultiplier; + }, + Display(): string { + return `Current Damage Multiplier: ${configDataObject.persistent.configAdjustmentDamageMultiplier}`; + }, + Info: ["Damage multiplier for the combined contact damage of the blade."], + Maximum: 10.0, + Minimum: 0.1, + ModifyBy: 0.1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configAdjustmentDamageMultiplier = newValue; + } + infoLog(`Damage value changed: ${configDataObject.persistent.configAdjustmentDamageMultiplier}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } function setupConfigRangeMultiplier(modCategoryName: string) { - ModConfigMenu?.AddSetting(modCategoryName, "Tuning", { - CurrentSetting(): number | boolean { - return configDataObject.persistent.configAdjustmentRangeMultiplier; - }, - Display(): string { - return `Current Range Multiplier: ${configDataObject.persistent.configAdjustmentRangeMultiplier}`; - }, - Info: ["Range multiplier for the arc size."], - Maximum: 10.0, - Minimum: 0.5, - ModifyBy: 0.1, - OnChange(newValue: number | boolean | undefined): void { - if (typeof newValue === "number") { - configDataObject.persistent.configAdjustmentRangeMultiplier = newValue; - } - infoLog(`Range value changed: ${configDataObject.persistent.configAdjustmentRangeMultiplier}`); - }, - PopupWidth: 0, - Type: ModConfigMenuOptionType.NUMBER, - }); + ModConfigMenu?.AddSetting(modCategoryName, "Tuning", { + CurrentSetting(): number | boolean { + return configDataObject.persistent.configAdjustmentRangeMultiplier; + }, + Display(): string { + return `Current Range Multiplier: ${configDataObject.persistent.configAdjustmentRangeMultiplier}`; + }, + Info: ["Range multiplier for the arc size."], + Maximum: 10.0, + Minimum: 0.5, + ModifyBy: 0.1, + OnChange(newValue: number | boolean | undefined): void { + if (typeof newValue === "number") { + configDataObject.persistent.configAdjustmentRangeMultiplier = newValue; + } + infoLog(`Range value changed: ${configDataObject.persistent.configAdjustmentRangeMultiplier}`); + }, + PopupWidth: 0, + Type: ModConfigMenuOptionType.NUMBER, + }); } diff --git a/src/data/StateData.ts b/src/data/StateData.ts index 11548f3..85f22ab 100644 --- a/src/data/StateData.ts +++ b/src/data/StateData.ts @@ -1,51 +1,51 @@ interface PlayerState { - bladeSprite: Sprite; - holsterSprite: Sprite; - lastFireTime: float; - hitChainProgression: int; - activeAimDirection: Vector; - charged: boolean; - - hitStateEntities: number[]; // Entity indexes. + bladeSprite: Sprite; + holsterSprite: Sprite; + lastFireTime: float; + hitChainProgression: int; + activeAimDirection: Vector; + charged: boolean; + + hitStateEntities: number[]; // Entity indexes. } const stateData = new Map(); export function getStateData(): Map { - return stateData; + return stateData; } export function flushAllStateData(): void { - stateData.clear(); + stateData.clear(); } export function getPlayerStateData(player: EntityPlayer): PlayerState { - let playerData = getStateData().get(player.Index); - - // Data doesn't exist, add it. - if (playerData === undefined) { - playerData = { - bladeSprite: Sprite(), - holsterSprite: Sprite(), - lastFireTime: -1, - hitChainProgression: 1, - activeAimDirection: Vector(0, 0), - charged: false, - hitStateEntities: [], - }; - - // Load sprite data. - playerData.bladeSprite.Load("gfx/animation/BladeAnim.anm2", true); - playerData.holsterSprite.Load("gfx/animation/BladeAnim.anm2", true); - - getStateData().set(player.Index, playerData); - } - - return playerData; + let playerData = getStateData().get(player.Index); + + // Data doesn't exist, add it. + if (playerData === undefined) { + playerData = { + bladeSprite: Sprite(), + holsterSprite: Sprite(), + lastFireTime: -1, + hitChainProgression: 1, + activeAimDirection: Vector(0, 0), + charged: false, + hitStateEntities: [], + }; + + // Load sprite data. + playerData.bladeSprite.Load("gfx/animation/BladeAnim.anm2", true); + playerData.holsterSprite.Load("gfx/animation/BladeAnim.anm2", true); + + getStateData().set(player.Index, playerData); + } + + return playerData; } export function getPlayerStateDataNoCreate( - player: EntityPlayer, + player: EntityPlayer, ): PlayerState | undefined { - return getStateData().get(player.Index); + return getStateData().get(player.Index); } diff --git a/src/data/Tuneable.ts b/src/data/Tuneable.ts index e8e6e60..7e35abb 100644 --- a/src/data/Tuneable.ts +++ b/src/data/Tuneable.ts @@ -1,69 +1,69 @@ interface ITuneable { - HitChainRanges: Map; - FireDelayByProgressionStage: Map; - Damage: Map; - TearDamageMult: Map; - BaseRange: number; - PushMultiplier: number; - TimeToGoIdleFrames: number; - DamageModifierForHittingSameEnemy: number; - StatRange: float; - StatRangePhysical: float; - StatRangeVisual: float; - StatDamage: float; - StatFireRate: float; - StatShotSpeed: float; - IdleSize: Vector; - hitStateFrames: Map; // Hits all entities after given number of frames have passed since player started attacking in the int array, for all elements. Can't hit same entity twice. - maxNumberOfHitsInOneSwingToSameEntity: number; - baseCriticalChance: float; - luckCriticalChanceEffect: float; - baseCriticalDamageMultiplier: float; - LOSCheckRadiusSoftness: float; + HitChainRanges: Map; + FireDelayByProgressionStage: Map; + Damage: Map; + TearDamageMult: Map; + BaseRange: number; + PushMultiplier: number; + TimeToGoIdleFrames: number; + DamageModifierForHittingSameEnemy: number; + StatRange: float; + StatRangePhysical: float; + StatRangeVisual: float; + StatDamage: float; + StatFireRate: float; + StatShotSpeed: float; + IdleSize: Vector; + hitStateFrames: Map; // Hits all entities after given number of frames have passed since player started attacking in the int array, for all elements. Can't hit same entity twice. + maxNumberOfHitsInOneSwingToSameEntity: number; + baseCriticalChance: float; + luckCriticalChanceEffect: float; + baseCriticalDamageMultiplier: float; + LOSCheckRadiusSoftness: float; } export const Tuneable: ITuneable = { - HitChainRanges: new Map([ - [1, [-0.7, 1]], - [2, [-0.62, 1]], - [3, [-1, 1]], - ["charged", [-1, 1]], - ]), + HitChainRanges: new Map([ + [1, [-0.7, 1]], + [2, [-0.62, 1]], + [3, [-1, 1]], + ["charged", [-1, 1]], + ]), - FireDelayByProgressionStage: new Map([ - [1, 20], - [2, 10], - [3, 15], - ]), - Damage: new Map([ - [1, 0.25], - [2, 0.15], - [3, 0.4], - ]), - TearDamageMult: new Map([ - [1, 0.15], - [2, 0.1], - [3, 0.2], - ]), - BaseRange: 100, - PushMultiplier: 10, - TimeToGoIdleFrames: 32, - DamageModifierForHittingSameEnemy: 0.55, - StatRange: 2.1, - StatRangePhysical: 1.02, - StatRangeVisual: 0.9, - StatDamage: 0.6, - StatFireRate: 1, - StatShotSpeed: 0.5, - IdleSize: Vector(0.6, 0.6), - hitStateFrames: new Map([ - [1, [2, 3, 4, 5, 6, 7, 8]], - [2, [1, 2, 3, 4, 5, 6, 7]], - [3, [4, 5, 6, 7, 8, 9, 10]], - ]), - maxNumberOfHitsInOneSwingToSameEntity: 3, - baseCriticalChance: 5, - luckCriticalChanceEffect: 5, - baseCriticalDamageMultiplier: 1.5, - LOSCheckRadiusSoftness: 1.1, + FireDelayByProgressionStage: new Map([ + [1, 20], + [2, 10], + [3, 15], + ]), + Damage: new Map([ + [1, 0.25], + [2, 0.15], + [3, 0.4], + ]), + TearDamageMult: new Map([ + [1, 0.15], + [2, 0.1], + [3, 0.2], + ]), + BaseRange: 100, + PushMultiplier: 10, + TimeToGoIdleFrames: 32, + DamageModifierForHittingSameEnemy: 0.55, + StatRange: 2.1, + StatRangePhysical: 1.02, + StatRangeVisual: 0.9, + StatDamage: 0.6, + StatFireRate: 1, + StatShotSpeed: 0.5, + IdleSize: Vector(0.6, 0.6), + hitStateFrames: new Map([ + [1, [2, 3, 4, 5, 6, 7, 8]], + [2, [1, 2, 3, 4, 5, 6, 7]], + [3, [4, 5, 6, 7, 8, 9, 10]], + ]), + maxNumberOfHitsInOneSwingToSameEntity: 3, + baseCriticalChance: 5, + luckCriticalChanceEffect: 5, + baseCriticalDamageMultiplier: 1.5, + LOSCheckRadiusSoftness: 1.1, } as const; diff --git a/src/data/saveFile/SaveDataHandler.ts b/src/data/saveFile/SaveDataHandler.ts index 2f804ee..4158700 100644 --- a/src/data/saveFile/SaveDataHandler.ts +++ b/src/data/saveFile/SaveDataHandler.ts @@ -5,8 +5,6 @@ import {SaveDataSource} from "./SaveDataSource"; import {AnyClass} from "isaacscript-common/src/types/AnyClass"; - - const saveDataObject = { persistent: {}, run: { diff --git a/src/data/saveFile/SaveDataManager.ts b/src/data/saveFile/SaveDataManager.ts index c11626f..7bd1b50 100644 --- a/src/data/saveFile/SaveDataManager.ts +++ b/src/data/saveFile/SaveDataManager.ts @@ -12,7 +12,8 @@ export class SaveDataManager { static #instance: SaveDataManager; - private constructor() {} + private constructor() { + } public static get instance(): SaveDataManager { if (!SaveDataManager.#instance) { diff --git a/src/data/saveFile/SaveDataSource.ts b/src/data/saveFile/SaveDataSource.ts index 04a09aa..7b000bc 100644 --- a/src/data/saveFile/SaveDataSource.ts +++ b/src/data/saveFile/SaveDataSource.ts @@ -2,6 +2,8 @@ import {AnyClass} from "isaacscript-common/src/types/AnyClass"; export interface SaveDataSource { getNamespace(): string; + getSaveData(): object; + getCustomClasses(): AnyClass[]; } \ No newline at end of file