feature/shadows #25
@ -2,6 +2,9 @@
|
||||
--- @field intensity number
|
||||
--- @field color Vec3
|
||||
--- @field seed integer
|
||||
--- @field colorAnimationNode? AnimationNode
|
||||
--- @field targetColor? Vec3
|
||||
--- @field sourceColor? Vec3
|
||||
local behavior = {}
|
||||
behavior.__index = behavior
|
||||
behavior.id = "light"
|
||||
@ -16,7 +19,18 @@ function behavior.new(values)
|
||||
}, behavior)
|
||||
end
|
||||
|
||||
function behavior:update()
|
||||
function behavior:update(dt)
|
||||
if not self.colorAnimationNode then return end
|
||||
local delta = self.targetColor - self.sourceColor
|
||||
self.color = self.sourceColor + delta * self.colorAnimationNode:getValue()
|
||||
self.colorAnimationNode:update(dt)
|
||||
end
|
||||
|
||||
function behavior:animateColor(targetColor, animationNode)
|
||||
if self.colorAnimationNode then self.colorAnimationNode:finish() end
|
||||
self.colorAnimationNode = animationNode
|
||||
self.sourceColor = self.color
|
||||
self.targetColor = targetColor
|
||||
end
|
||||
|
||||
function behavior:draw()
|
||||
|
||||
@ -107,9 +107,10 @@ function regenerateMana:cast(caster, target)
|
||||
|
||||
AnimationNode {
|
||||
function(node)
|
||||
light:has(Tree.behaviors.residentsleeper):sleep(node)
|
||||
light:has(Tree.behaviors.light):animateColor(Vec3 {}, node)
|
||||
end,
|
||||
duration = 400,
|
||||
easing = easing.easeInQuad,
|
||||
duration = 800,
|
||||
onEnd = function() light:die() end
|
||||
}:run()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user