/*:
* @target MV MZ
* @plugindesc v4 - mirror actor battlers when they are in the left-hand half of the screen.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/threads/156765/
* @orderAfter YEP_BattleEngineCore
* @help If using YEP_BattleEngineCore, load this plugin after Yanfly's.
*
* Free to use and/or modify for any project, no credit required.
*/
void (function() {
'use strict';
/**
* @param {Sprite_Actor} sprite reference actor sprite.
* @returns {boolean} `true` iff this plugin should flip `sprite`.
*/
const shouldActorBeFlipped = function(sprite) {
const faceFront = !sprite._faceBack;
const isOnLeft = sprite._homeX < Graphics.boxWidth / 2;
return faceFront === isOnLeft;
};
// Flip sprites when appropriate.
void (function() {
const alias = Sprite_Actor.prototype.updateMain;
Sprite_Actor.prototype.updateMain = function() {
alias.apply(this, arguments);
if (shouldActorBeFlipped(this) === !this._flippedX) {
this.scale.x *= -1;
this._flippedX = !this._flippedX;
}
};
})();
// YEP Battle Engine Core compatibility.
void (function() { if (!Imported.YEP_BattleEngineCore) return;
const alias_f = Game_Battler.prototype.spriteFaceForward;
Game_Battler.prototype.spriteFaceForward = function() {
alias_f.apply(this, arguments);
delete this.battler()._faceBack;
};
const alias_b = Game_Battler.prototype.spriteFaceBackward;
Game_Battler.prototype.spriteFaceBackward = function() {
alias_b.apply(this, arguments);
this.battler()._faceBack = true;
};
})();
})();