-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathRS_AnimataionVisibility.js
More file actions
82 lines (72 loc) · 2.86 KB
/
RS_AnimataionVisibility.js
File metadata and controls
82 lines (72 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//================================================================
// RS_AnimataionVisibility.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2019 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
* @target MV
* @plugindesc This plugin allows you to remove the animation on the screen when the character is deactivated. <RS_AnimataionVisibility>
* @author biud436
* @help
* ================================================================
* Introduction
* ================================================================
* In case of the RPG Maker MV,
* The Animation will be played until the last cell even if the character doesn't show up anymore on the screen.
* This plugin allows you to remove the animation on the screen when the character is deactivated.
*
* ◆ Animation Stop Condition
* - erased event.
* - if the event execution conditions are not met.
* - empty graphic.
*
* ================================================================
* Version Log
* ================================================================
* 2019.03.24 (v1.0.0) - First Release.
* 2020.09.13 (v1.0.1) :
* - Fixed the issue that is not working when playing a animation to player.
* 2020.09.14 (v1.0.2) :
* - Fixed the bug that is not playing the animation to object character.
* 2020.09.17 (v1.0.3) :
* - Fixed the issue that is not working an animation in tile event.
*/
(() => {
'use strict';
const aliasSpriteAnimationUpdate = Sprite_Animation.prototype.update;
Sprite_Animation.prototype.update = function () {
aliasSpriteAnimationUpdate.call(this);
this.updateVisibility();
};
Sprite_Animation.prototype.isTargetReady = function () {
if (!this._target) return false;
if (!(this._target instanceof Sprite_Character)) return false;
const target = this._target._character;
let isActivated = false;
if (target instanceof Game_Event) {
isActivated = target.findProperPageIndex() > -1;
} else if (target instanceof Game_CharacterBase) {
isActivated = true;
} else {
return false;
}
const isTransparent = target.isTransparent(); // 투명한가?
let isErased = target._erased;
if (!isErased) {
isErased = target.isTile() ? isErased : !target._characterName;
}
return isActivated && !isTransparent && !isErased;
};
Sprite_Animation.prototype.updateVisibility = function () {
this.visible = this.isTargetReady();
};
const aliasSpriteAnimationProcessTimingData =
Sprite_Animation.prototype.processTimingData;
Sprite_Animation.prototype.processTimingData = function (timing) {
if (!this.isTargetReady()) return;
aliasSpriteAnimationProcessTimingData.call(this, timing);
};
})();