I believe I have gotten region-based lighting working with one big caveat: I had to turn off shadows for all region-based light, because it was displaying wonky and I couldn't for the life of me figure out how to correct it (it is something to do with the displayX and displayY upon entering a map affecting how the shadow geometry gets applied to the light).
So, first, I re-enabled all of the static light code in the plugin. I also had to modify
LightingLayer.addStaticLight a bit, because I wanted to pass in tile coords rather than screen coords:
JavaScript:addStaticLight(options) {
const tileWidth = $gameMap.tileWidth();
const tileHeight = $gameMap.tileHeight();
const displayX = $gameMap.displayX();
const displayY = $gameMap.displayY();
options.x = (options.x * tileWidth) + (tileWidth / 2) + displayX;
options.y = (options.y * tileHeight) + (tileHeight / 2) + displayY;
options.shadow = false;
const light = new LightingSprite(options);
light.renderable = true;
light.texture.baseTexture.premultipliedAlpha = false;
if (Shora.EngineVersion === 'MV') {
light.blendMode = PIXI.BLEND_MODES.NORMAL; // TODO
}
Graphics.app.renderer.render(light, this._staticLighting, this._clearStaticLayer);
this._clearStaticLayer = false;
// lights will get automatically destroyed by texture collector
light.destroy();
}
After that, it was a simple matter of making my own plugin to walk a map searching for a particular region ID and add static light to all matching tiles:
JavaScript:PluginManager.registerCommand("RegionLighting", "activate", args => {
const regionId = Number(args.regionId);
const lightRef = String(args.lightRef);
const mapWidth = $gameMap.width();
const mapHeight = $gameMap.height();
for (let x = 0; x < mapWidth; x++) {
for (let y = 0; y < mapHeight; y++) {
if ($gameMap.regionId(x, y) === regionId) {
$gameLighting.addStaticLight(x, y, lightRef);
}
}
}
});
This seems to work correctly. It's a bummer that I can't get shadows against this light, but since I'm using this for more of ambient glow on certain tiles, it's not the end of the world. It certainly beats having to switch everything back to Community Lighting to get this feature.
It would be great to get a plugin update that adds static light properly with shadows enabled!