Deltarune (Chapter 5) script viewer

← back to main script listing

gml_Object_obj_anim_custom_Create_0

(view raw script w/o annotations or w/e)
1
target_obj = -4;
2
event_handler = -4;
3
anim_active = false;
4
anim_timestamps = [];
5
anim_modifier = 30;
6
anim_index = 0;
7
anim_timer = 0;
8
anim_events = [];
9
10
init = function(arg0, arg1, arg2, arg3 = 30)
11
{
12
    target_obj = arg0;
13
    target_obj.sprite_index = arg1;
14
    target_obj.image_index = 0;
15
    target_obj.image_speed = 0;
16
    anim_timestamps = arg2;
17
    anim_modifier = arg3;
18
    anim_timer = anim_timestamps[anim_index] / anim_modifier;
19
};
20
21
start = function()
22
{
23
    anim_active = true;
24
};
25
26
stop = function()
27
{
28
    anim_active = false;
29
    trigger_event("anim_end");
30
};
31
32
pause = function()
33
{
34
    anim_active = false;
35
};
36
37
trigger_event = function(arg0, arg1 = -1)
38
{
39
    for (var i = 0; i < array_length(anim_events); i++)
40
    {
41
        var _event = anim_events[i][0];
42
        var _callback = anim_events[i][1];
43
        var _condition = anim_events[i][2];
44
        var _args = anim_events[i][3];
45
        if (_event == arg0)
46
        {
47
            if (_condition == arg1)
48
            {
49
                if (array_length(_args) == 0)
50
                    _callback();
51
                else if (array_length(_args) == 1)
52
                    _callback(_args[0]);
53
                else if (array_length(_args) == 2)
54
                    _callback(_args[0], _args[1]);
55
                else if (array_length(_args) == 3)
56
                    _callback(_args[0], _args[1], _args[2]);
57
            }
58
        }
59
    }
60
};
61
62
reset = function()
63
{
64
    target_obj = -4;
65
    anim_active = false;
66
    anim_timestamps = [];
67
    anim_modifier = 30;
68
    anim_index = 0;
69
    anim_timer = 0;
70
    anim_events = [];
71
};
72
73
is_playing = function()
74
{
75
    return anim_active;
76
};
77
78
anim_event = function(arg0, arg1, arg2, arg3)
79
{
80
    var event = [];
81
    event[0] = arg0;
82
    event[1] = arg1;
83
    event[2] = arg2;
84
    event[3] = arg3;
85
    return event;
86
};
87
88
event_connect = function(arg0, arg1, arg2 = -1, arg3 = [])
89
{
90
    var _event = anim_event(arg0, arg1, arg2, arg3);
91
    anim_events[array_length(anim_events)] = _event;
92
};