-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
149 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/isaacscript-common/src/features/customStage/exports.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { LevelStage } from "isaac-typescript-definitions"; | ||
import { CustomStageData } from "../../interfaces/CustomStageData"; | ||
import { JSONRoom } from "../../interfaces/JSONRoom"; | ||
import { customStages } from "./v"; | ||
|
||
/** | ||
* Helper function to register a new custom stage with the IsaacScript standard library stage | ||
* system. | ||
*/ | ||
export function registerCustomStage( | ||
name: string, | ||
baseStage: LevelStage, | ||
jsonRooms: JSONRoom[] | readonly JSONRoom[], | ||
): void { | ||
if (customStages.has(name)) { | ||
error( | ||
`Failed to register a custom stage of "${name}" since there is already a custom stage registered by that name.`, | ||
); | ||
} | ||
|
||
if (jsonRooms.length === 0) { | ||
error( | ||
`Failed to register a custom stage of "${name}" since the provided JSON room array was empty.`, | ||
); | ||
} | ||
|
||
const customStageData: CustomStageData = { | ||
name, | ||
baseStage, | ||
}; | ||
customStages.set(name, customStageData); | ||
} | ||
|
||
/** | ||
* Helper function to warp to a custom stage/level. | ||
* | ||
* Custom stages/levels must first be registered with the `registerCustomStage` function. | ||
*/ | ||
export function setCustomStage(_name: string): void {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { CustomStageData } from "../../interfaces/CustomStageData"; | ||
|
||
export const customStages = new Map<string, CustomStageData>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/isaacscript-common/src/interfaces/CustomStageData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LevelStage } from "isaac-typescript-definitions"; | ||
|
||
export interface CustomStageData { | ||
name: string; | ||
baseStage: LevelStage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters