-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
RS_AnimataionVisibility.js
108 lines (98 loc) · 4.2 KB
/
RS_AnimataionVisibility.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//================================================================
// 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.
*/
/*:ko
* @plugindesc 애니메이션을 바로 정지시킵니다. <RS_AnimataionVisibility>
* @author biud436
* @help
* ================================================================
* 소개
* ================================================================
* RPG Maker MV의 경우, 캐릭터가 화면에서 보이지 않아도 애니메이션이 끝까지 재생됩니다.
* 이 플러그인은 캐릭터가 화면에서 보이지 않으면 애니메이션을 바로 정지시킵니다.
*
* ◆ 정지 조건
* - 이벤트 일시 삭제
* - 이벤트 실행 조건이 충족하지 않을 때 (변수, 스위치, 셀프 스위치)
* - 캐릭터 그래픽이 비어있을 때
*
* ================================================================
* Version Log
* ================================================================
* 2019.03.24 (v1.0.0) - First Release.
* 2020.09.13 (v1.0.1) :
* - 플레이어에 애니메이션 재생 시 오류가 나는 문제를 수정하였습니다.
* 2020.09.14 (v1.0.2) :
* - 애니메이션이 재생되지 않는 문제를 수정하였습니다.
* 2020.09.17 (v1.0.3) :
* - 타일 이벤트에서 애니메이션이 동작하지 않는 문제를 수정하였습니다.
*/
(() => {
'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);
};
})();