isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
166 lines (165 loc) • 6.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getElapsedGameFramesSince = getElapsedGameFramesSince;
exports.getElapsedRenderFramesSince = getElapsedRenderFramesSince;
exports.getElapsedRoomFramesSince = getElapsedRoomFramesSince;
exports.isAfterGameFrame = isAfterGameFrame;
exports.isAfterRenderFrame = isAfterRenderFrame;
exports.isAfterRoomFrame = isAfterRoomFrame;
exports.isBeforeGameFrame = isBeforeGameFrame;
exports.isBeforeRenderFrame = isBeforeRenderFrame;
exports.isBeforeRoomFrame = isBeforeRoomFrame;
exports.onGameFrame = onGameFrame;
exports.onOrAfterGameFrame = onOrAfterGameFrame;
exports.onOrAfterRenderFrame = onOrAfterRenderFrame;
exports.onOrAfterRoomFrame = onOrAfterRoomFrame;
exports.onOrBeforeGameFrame = onOrBeforeGameFrame;
exports.onOrBeforeRenderFrame = onOrBeforeRenderFrame;
exports.onOrBeforeRoomFrame = onOrBeforeRoomFrame;
exports.onRenderFrame = onRenderFrame;
exports.onRoomFrame = onRoomFrame;
const cachedClasses_1 = require("../core/cachedClasses");
function getElapsedGameFramesSince(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount - gameFrameCount;
}
function getElapsedRenderFramesSince(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount - renderFrameCount;
}
function getElapsedRoomFramesSince(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisRoomFrameCount = room.GetFrameCount();
return thisRoomFrameCount - roomFrameCount;
}
/**
* Helper function to check if the current game frame count is higher than a specific game frame
* count.
*/
function isAfterGameFrame(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount > gameFrameCount;
}
/**
* Helper function to check if the current render frame count is higher than a specific render frame
* count.
*/
function isAfterRenderFrame(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount > renderFrameCount;
}
/**
* Helper function to check if the current room frame count is higher than a specific room frame
* count.
*/
function isAfterRoomFrame(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisGameFrameCount = room.GetFrameCount();
return thisGameFrameCount > roomFrameCount;
}
/**
* Helper function to check if the current game frame count is lower than a specific game frame
* count.
*/
function isBeforeGameFrame(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount < gameFrameCount;
}
/**
* Helper function to check if the current render frame count is lower than a specific render frame
* count.
*/
function isBeforeRenderFrame(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount < renderFrameCount;
}
/**
* Helper function to check if the current room frame count is lower than a specific room frame
* count.
*/
function isBeforeRoomFrame(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisGameFrameCount = room.GetFrameCount();
return thisGameFrameCount < roomFrameCount;
}
/**
* Helper function to check if the current game frame count is exactly equal to a specific game
* frame count.
*
* This returns false if the submitted render frame count is null or undefined.
*/
function onGameFrame(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount === gameFrameCount;
}
/**
* Helper function to check if the current game frame count is equal to or higher than a specific
* game frame count.
*/
function onOrAfterGameFrame(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount >= gameFrameCount;
}
/**
* Helper function to check if the current render frame count is equal to or higher than a specific
* render frame count.
*/
function onOrAfterRenderFrame(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount >= renderFrameCount;
}
/**
* Helper function to check if the current room frame count is equal to or higher than a specific
* room frame count.
*/
function onOrAfterRoomFrame(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisGameFrameCount = room.GetFrameCount();
return thisGameFrameCount >= roomFrameCount;
}
/**
* Helper function to check if the current game frame count is equal to or lower than a specific
* game frame count.
*/
function onOrBeforeGameFrame(gameFrameCount) {
const thisGameFrameCount = cachedClasses_1.game.GetFrameCount();
return thisGameFrameCount <= gameFrameCount;
}
/**
* Helper function to check if the current render frame count is equal to or lower than a specific
* render frame count.
*/
function onOrBeforeRenderFrame(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount <= renderFrameCount;
}
/**
* Helper function to check if the current room frame count is equal to or lower than a specific
* room frame count.
*/
function onOrBeforeRoomFrame(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisGameFrameCount = room.GetFrameCount();
return thisGameFrameCount <= roomFrameCount;
}
/**
* Helper function to check if the current render frame count is exactly equal to a specific render
* frame count.
*
* This returns false if the submitted render frame count is null or undefined.
*/
function onRenderFrame(renderFrameCount) {
const thisRenderFrameCount = Isaac.GetFrameCount();
return thisRenderFrameCount === renderFrameCount;
}
/**
* Helper function to check if the current room frame count is exactly equal to a specific room
* frame count.
*
* This returns false if the submitted room frame count is null or undefined.
*/
function onRoomFrame(roomFrameCount) {
const room = cachedClasses_1.game.GetRoom();
const thisGameFrameCount = room.GetFrameCount();
return thisGameFrameCount === roomFrameCount;
}