sonic-radiance/sonic-radiance.love/scenes/battlesystem/choregraphy/mixins/wrappers.lua

68 lines
1.8 KiB
Lua
Raw Normal View History

2021-08-08 09:49:43 +02:00
local InfosMixin = Object:extend()
2021-08-08 13:11:36 +02:00
function InfosMixin:initWrappers(action, target)
2021-08-08 09:49:43 +02:00
self.action = action
self.fighter = action.fighter
self.actor = self.fighter.actor
self.assets = self.fighter.actor.assets
self.world = self.actor.world
2021-08-08 13:11:36 +02:00
self:initTargets(target or action.target)
2021-08-08 09:49:43 +02:00
end
function InfosMixin:initTargets(target)
self.target = target
self.haveSentDamage = false
if (self.target == nil) then
local _, targetEnnemies = self.action:needTarget()
self.targetList = self.fighter:getTargets(targetEnnemies == false)
end
2021-08-08 09:49:43 +02:00
end
function InfosMixin:getActor(name)
if (name == "actor") then
return self.actor
elseif (name == "target") then
return self:getTargetActor()
else
return self.fighter.world:getActorByName(name)
end
end
function InfosMixin:getTargetActor()
return self.target.actor
end
function InfosMixin:sendDamage(power, type, element, isSpecial)
if (self.fighter.isAlive) then
if (self.target ~= nil) then
2021-08-08 09:49:43 +02:00
self.haveSentDamage = self.fighter:sendDamage(self.target, power, type, element, isSpecial)
else
self.haveSentDamage = self.fighter:sendDamageToAll(self.targetList, power, type, element, isSpecial)
2021-08-08 09:49:43 +02:00
end
else
self.haveSentDamage = false
2021-08-08 09:49:43 +02:00
end
end
2021-08-08 16:00:45 +02:00
function InfosMixin:sendStatus(status, duration, force)
if (self.fighter.isAlive) then
if (self.target ~= nil) then
self.fighter:sendStatus(self.target, status, duration, force)
else
self.fighter:sendStatus(self.targetList, status, duration, force)
end
end
end
2021-08-08 09:49:43 +02:00
function InfosMixin:haveFrameSignal(signal)
return self.actor:haveFrameSignal(signal)
end
function InfosMixin:useItemEffect()
self.action:useItemEffect()
end
return InfosMixin