//-----------------------------------------------------------------------------
// Game_Temp
//
// The game object class for temporary data that is not included in save data.
/**
* The game object class for temporary data that is not included in save data.
*
* @class
*/
function Game_Temp() {
this.initialize(...arguments);
}
/**
* Initialize the object
*/
Game_Temp.prototype.initialize = function() {
this._isPlaytest = Utils.isOptionValid("test");
this._destinationX = null;
this._destinationY = null;
this._touchTarget = null;
this._touchState = "";
this._needsBattleRefresh = false;
this._commonEventQueue = [];
this._animationQueue = [];
this._balloonQueue = [];
this._lastActionData = [0, 0, 0, 0, 0, 0];
};
/**
* Check if the game is in playtest mode
*
* @return {boolean} True if playtesting
*/
Game_Temp.prototype.isPlaytest = function() {
return this._isPlaytest;
};
/**
* Set the destination x/y coordinates
*
* @param {number} x - The x coordinate for the destination
* @param {number} y - The y coordinate for the destination
*/
Game_Temp.prototype.setDestination = function(x, y) {
this._destinationX = x;
this._destinationY = y;
};
/**
* Clears the destination
*/
Game_Temp.prototype.clearDestination = function() {
this._destinationX = null;
this._destinationY = null;
};
/**
* Check if the destination is valid
*
* @return {boolean} True if valid
*/
Game_Temp.prototype.isDestinationValid = function() {
return this._destinationX !== null;
};
/**
* Get the x coordinate for the destination
*
* @return {number} Destination x coordinate
*/
Game_Temp.prototype.destinationX = function() {
return this._destinationX;
};
/**
* Get the y coordinate for the destination
*
* @return {number} Destination y coordinate
*/
Game_Temp.prototype.destinationY = function() {
return this._destinationY;
};
/**
* Sets the touch state
*
* @param {Game_Battler} target - The target
* @param {string} state - The touch state
*/
Game_Temp.prototype.setTouchState = function(target, state) {
this._touchTarget = target;
this._touchState = state;
};
/**
* Clear the touch state
*/
Game_Temp.prototype.clearTouchState = function() {
this._touchTarget = null;
this._touchState = "";
};
/**
* Get the touch target
*
* @return {Game_Battler} The target
*/
Game_Temp.prototype.touchTarget = function() {
return this._touchTarget;
};
/**
* Get the touch state
*
* @return {string} The touch state
*/
Game_Temp.prototype.touchState = function() {
return this._touchState;
};
/**
* Requests a battle refresh
*/
Game_Temp.prototype.requestBattleRefresh = function() {
if ($gameParty.inBattle()) {
this._needsBattleRefresh = true;
}
};
/**
* Clears battle refresh requests
*/
Game_Temp.prototype.clearBattleRefreshRequest = function() {
this._needsBattleRefresh = false;
};
/**
* Check if battle refresh is requested
*
* @return {boolean} True if battle refresh is requested
*/
Game_Temp.prototype.isBattleRefreshRequested = function() {
return this._needsBattleRefresh;
};
/**
* Reserves a common event by id
*
* @param {number} commonEventId - The common event id to reserve
*/
Game_Temp.prototype.reserveCommonEvent = function(commonEventId) {
this._commonEventQueue.push(commonEventId);
};
/**
* Retrieves a common event from the reserved common events
*
* @return {Object} The common event data object
*/
Game_Temp.prototype.retrieveCommonEvent = function() {
return $dataCommonEvents[this._commonEventQueue.shift()];
};
/**
* Clears reserved common events
* @since Version 1.4.0
*/
Game_Temp.prototype.clearCommonEventReservation = function() {
this._commonEventQueue.length = 0;
};
/**
* Check if there are any common events reserved
*
* @return {boolean} True if any common events are reserved
*/
Game_Temp.prototype.isCommonEventReserved = function() {
return this._commonEventQueue.length > 0;
};
// prettier-ignore
/**
* Requests an animation
*
* @param {Array} targets - The targets of the animation
* @param {number} animationId - The id of the animation to play
* @param {boolean} [mirror=false] - If the animation request is mirror type
*/
Game_Temp.prototype.requestAnimation = function(
targets, animationId, mirror = false
) {
if ($dataAnimations[animationId]) {
const request = {
targets: targets,
animationId: animationId,
mirror: mirror
};
this._animationQueue.push(request);
for (const target of targets) {
if (target.startAnimation) {
target.startAnimation();
}
}
}
};
/**
* Gets a requested animation
*
* @return {Object} A requested animation
*/
Game_Temp.prototype.retrieveAnimation = function() {
return this._animationQueue.shift();
};
/**
* Requests a balloon
*
* @param {Game_Character} target - The targets of the balloon
* @param {number} balloonId - The id of the balloon
*/
Game_Temp.prototype.requestBalloon = function(target, balloonId) {
const request = { target: target, balloonId: balloonId };
this._balloonQueue.push(request);
if (target.startBalloon) {
target.startBalloon();
}
};
/**
* Gets a requested balloon
*
* @return {Object} A requested balloon
*/
Game_Temp.prototype.retrieveBalloon = function() {
return this._balloonQueue.shift();
};
/**
* Get the last action data
*
* @param {number} type - The type of data
* @return {number} Last action data
*/
Game_Temp.prototype.lastActionData = function(type) {
return this._lastActionData[type] || 0;
};
/**
* Set the last action data
*
* @param {number} type - The type of data to set
* @param {number} value - The value to set
*/
Game_Temp.prototype.setLastActionData = function(type, value) {
this._lastActionData[type] = value;
};
/**
* Set the last skill data
*
* @param {number} skillID - The skill id
*/
Game_Temp.prototype.setLastUsedSkillId = function(skillID) {
this.setLastActionData(0, skillID);
};
/**
* Set the last item data
*
* @param {number} itemID - The item id
*/
Game_Temp.prototype.setLastUsedItemId = function(itemID) {
this.setLastActionData(1, itemID);
};
/**
* Set the last subject actor data
*
* @param {number} actorID - The actor id
*/
Game_Temp.prototype.setLastSubjectActorId = function(actorID) {
this.setLastActionData(2, actorID);
};
/**
* Set the last subject enemy index data
*
* @param {number} enemyIndex - The enemy index
*/
Game_Temp.prototype.setLastSubjectEnemyIndex = function(enemyIndex) {
this.setLastActionData(3, enemyIndex);
};
/**
* Set the last target actor data
*
* @param {number} actorID - The actor id
*/
Game_Temp.prototype.setLastTargetActorId = function(actorID) {
this.setLastActionData(4, actorID);
};
/**
* Set the last target enemy index data
*
* @param {number} enemyIndex - The enemy index
*/
Game_Temp.prototype.setLastTargetEnemyIndex = function(enemyIndex) {
this.setLastActionData(5, enemyIndex);
};