add velocity.js compatability and fix pause step bug

This commit is contained in:
redbirdly 2024-06-17 09:50:28 +08:00 committed by GitHub
parent b6a6af86e0
commit ac83be0c48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 4 deletions

View File

@ -336,6 +336,8 @@ elements.rad_steam.tick = function(pixel) {
lightmap[y][x] = { color: radColor };
};
// #keepTheGap
window.addEventListener('load', function() {
initializeLightmap(width, height);
});
@ -349,8 +351,25 @@ tick = function() {
// Even after updating tick(), setInterval still uses the old tick(), reset setInterval
resetInterval(tps);
let originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
// Add code to functions instead of replacing them
let originalDoFrame = doFrame;
doFrame = function() {
originalDoFrame();
propagateLightmap();
};
if (enabledMods.includes("mods/velocity.js")) {
runAfterAutogen(()=>{
let originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
});
} else {
let originalDrawPixels = drawPixels;
drawPixels = function(forceTick = false) {
originalDrawPixels(forceTick);
renderLightmap();
};
}