-
Notifications
You must be signed in to change notification settings - Fork 9
/
TrustReactions.lua
43 lines (33 loc) · 1.35 KB
/
TrustReactions.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
local DisposeBag = require('cylibs/events/dispose_bag')
local Event = require('cylibs/events/Luvent')
require('logger')
local TrustReactions = {}
TrustReactions.__index = TrustReactions
TrustReactions.__type = "TrustReactions"
--state.TrustReactionsMode = M{['description'] = 'Trust Reactions Mode', 'Auto', 'Off'}
--state.TrustReactionsMode:set_description('Auto', "Okay, I'll react in real time to changing battle conditions.")
function TrustReactions.new(jobNameShort)
local self = setmetatable({}, TrustReactions)
self.jobNameShort = jobNameShort
self.disposeBag = DisposeBag.new()
self.reactions = require('data/reactions/'..jobNameShort)
if not self.reactions then
addon_message(207, 'Unable to load reactions for '..self.jobNameShort)
end
return self
end
function TrustReactions:loadReactions()
local settings = self.reactions:getSettings()
for modeName, reactions in pairs(settings.OnModeChange) do
local stateVar = get_state(modeName)
if stateVar then
self.disposeBag:add(stateVar:on_state_change():addAction(function(s, newValue)
local onModeValueChange = reactions[newValue]
if onModeValueChange ~= nil then
onModeValueChange()
end
end), stateVar:on_state_change())
end
end
end
return TrustReactions