--- Отвечает за размещение на уровне
--- @class PositionedBehavior : Behavior
--- @field position Vec3
local behavior = {}
behavior.__index = behavior
behavior.id = "positioned"

--- @param position? Vec3
function behavior.new(position)
    return setmetatable({
        position = position or Vec3({}),
    }, behavior)
end

--- @param position Vec3
function behavior:lookAt(position)
    self.owner:try(Tree.behaviors.sprite,
        function(sprite)
            if position.x > self.position.x then sprite.side = sprite.RIGHT end
            if position.x < self.position.x then sprite.side = sprite.LEFT end
        end
    )
end

return behavior
