-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmanager.lua
56 lines (48 loc) · 1.41 KB
/
manager.lua
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
if not RUBATO_DIR then RUBATO_DIR = (...):match("(.-)[^%.]+$") end
local easing = require(RUBATO_DIR.."easing")
local function make_props_immutable(table)
setmetatable(table, {
__index = function(self, key)
if self._props[key] then return self._props[key]
else return rawget(self, key) end
end,
__newindex = function(self, key, value)
if self._props[key] then return
else self._props[key] = value end
end,
})
end
local function manager()
local obj = {_props = {}}
make_props_immutable(obj)
obj._props.timeds = {}
obj._props.timed = {_props = {}}
obj._props.timed._props.defaults = {
duration = 1,
pos = 0,
prop_intro = false,
intro = 0.2,
easing = easing.linear,
awestore_compat = false,
log = function() end,
override_simulate = false,
override_dt = false,
clamp_position = false,
rate = 60,
}
make_props_immutable(obj.timed)
obj._props.timed._props.override = {_props = {
clear = function() for _, timed in pairs(obj.timeds) do timed:reset_values() end end,
forall = function(func) for _, timed in pairs(obj.timeds) do func(timed) end end,
}}
setmetatable(obj.timed.override, {
__index = function(self, key) return self._props[key] end,
__newindex = function(self, key, value)
for _, timed in pairs(obj.timeds) do timed[key] = value end
self._props[key] = value
end
})
return obj
end
if not RUBATO_MANAGER then RUBATO_MANAGER = manager() end
return RUBATO_MANAGER