Refactor actor state and buff icons in battle status window

未测试
main
xian18 12 months ago
parent 689a9c5f52
commit 8a7729367b
Signed by: SaltedFish
GPG Key ID: B0C26448E9EF40CA

@ -468,10 +468,10 @@ Yanfly.BSW.Window_BattleStatus_initialize = Window_BattleStatus.prototype.initia
Window_BattleStatus.prototype.initialize = function () { Window_BattleStatus.prototype.initialize = function () {
this._guageHeight = Imported.YEP_CoreEngine ? this.gaugeHeight() : 6; this._guageHeight = Imported.YEP_CoreEngine ? this.gaugeHeight() : 6;
this._guageHeight = Math.max(16, this._guageHeight); this._guageHeight = Math.max(16, this._guageHeight);
this._actorsStateIcon = []; // [index] = [nextRenderStartIndex ,icons] this._actorsStateBuff = []; // [index] = [nextRenderStartIndex ,icons]
this._actorsStateIconMaxTick = 90; this._actorsStateBuffMaxTick = 90;
this._actorsStateIconCurrentTick = 0; this._actorsStateBuffCurrentTick = 0;
this._actorsStateIconNum = 4; this._actorsStateBuffNum = 4;
Yanfly.BSW.Window_BattleStatus_initialize.call(this); Yanfly.BSW.Window_BattleStatus_initialize.call(this);
}; };
@ -544,7 +544,19 @@ Window_BattleStatus.prototype.drawItem = function (index) {
this.drawGuages(index, actor); this.drawGuages(index, actor);
// this.drawActorActionIcon(actor, rect.x + rect.width - Window_Base._iconWidth, rect.y); // this.drawActorActionIcon(actor, rect.x + rect.width - Window_Base._iconWidth, rect.y);
this._actorsStateIcon[index] = [0, actor.allIcons()]; this._actorsStateBuff[index] = {
startIndex: 0,
states: actor.states().filter(function (state) {
return state.iconIndex > 0;
}),
buffs: actor._buffs
.map(function (_, index) {
return index;
})
.filter(function (index) {
return actor.isBuffOrDebuffAffected(index);
}),
};
this.drawActorIcons(index); this.drawActorIcons(index);
}; };
@ -738,38 +750,55 @@ Window_BattleStatus.prototype.update = function () {
}; };
Window_BattleStatus.prototype.updateStateIcons = function () { Window_BattleStatus.prototype.updateStateIcons = function () {
this._actorsStateIconCurrentTick++; this._actorsStateBuffCurrentTick++;
if (this._actorsStateIconCurrentTick < this._actorsStateIconMaxTick) return; if (this._actorsStateBuffCurrentTick < this._actorsStateBuffMaxTick) return;
this._actorsStateIconCurrentTick = 0; this._actorsStateBuffCurrentTick = 0;
for (var index = 0; index < $gameParty.battleMembers().length; index++) { for (var index = 0; index < $gameParty.battleMembers().length; index++) {
this.drawActorIcons(index); this.drawActorIcons(index);
} }
}; };
Window_BattleStatus.prototype.drawActorIcons = function (index) { Window_BattleStatus.prototype.drawActorIcons = function (index) {
var startIcons = this._actorsStateIcon[index][0];
var icons = this._actorsStateIcon[index][1];
var rect = this.stateAreaRect(index); var rect = this.stateAreaRect(index);
var actor = $gameParty.battleMembers()[index];
this.contents.clearRect(rect.x, rect.y, rect.width, rect.height); var states = this._actorsStateBuff[index]["states"];
if (icons.length <= 0) { var buffs = this._actorsStateBuff[index]["buffs"];
return; var startIndex = this._actorsStateBuff[index]["startIndex"];
} var endIndex = startIndex + this._actorsStateBuffNum;
var iconWidth = Window_Base._iconWidth; var iconWidth = Window_Base._iconWidth;
var x = rect.x + 2; var x = rect.x + 2;
var y = rect.y; var y = rect.y;
for (var i = 0; i < this._actorsStateIconNum; i++) {
if (icons[i + startIcons] === undefined) continue;
var icon = icons[i + startIcons];
this.drawIcon(icon, x, y);
x += iconWidth;
}
this._actorsStateIcon[index][0] += this._actorsStateIconNum; this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
if (this._actorsStateIcon[index][0] >= icons.length) {
this._actorsStateIcon[index][0] = 0; states.slice(startIndex, endIndex).forEach(function (state, i) {
var wx = x + iconWidth * i;
var wy = y;
this.drawIcon(state.iconIndex, wx, wy);
this.drawStateTurns(actor, state, wx, wy);
this.drawStateCounter(actor, state, wx, wy);
}, this);
x = x + iconWidth * states.slice(startIndex, endIndex).length;
startIndex = startIndex < states.length ? 0 : startIndex - states.length;
endIndex = endIndex < states.length ? 0 : endIndex - states.length;
buffs.slice(startIndex, endIndex).forEach(function (buff, i) {
var wx = x + iconWidth * i;
var wy = y;
this.drawIcon(actor.buffIconIndex(actor.buff(buff), buff), wx, wy);
this.drawBuffTurns(actor, buff, wx, wy);
this.drawBuffRate(actor, buff, wx, wy);
}, this);
this._actorsStateBuff[index]["startIndex"] += this._actorsStateBuffNum;
if (this._actorsStateBuff[index]["startIndex"] >= states.length + buffs.length) {
this._actorsStateBuff[index]["startIndex"] = 0;
} }
}; };

Loading…
Cancel
Save