--- Begins tracking scope and target changes.

function ScopeHUD:didMount()
    self:UpdateTargetingState()

    -- Set up targeting change listeners
    local Targeting = self.props.Core.Targeting
    self.Maid.ScopeChangeListener = Targeting.ScopeChanged:Connect(function (Scope)
        Targeting:UpdateTarget()
        self:setState({
            Scope = Scope or Roact.None;
        })
    end)
    self.Maid.ScopeTargetChangeListener = Targeting.ScopeTargetChanged:Connect(function (ScopeTarget)
        self:setState({
            ScopeTarget = ScopeTarget or Roact.None;
        })
    end)
    self.Maid.TargetChangeListener = Targeting.TargetChanged:Connect(function (DirectTarget)
        self:setState({
            DirectTarget = DirectTarget or Roact.None;
        })
    end)
    self.Maid.ScopeLockChangeListener = Targeting.ScopeLockChanged:Connect(function (IsScopeLocked)
        self:setState({
            IsScopeLocked = IsScopeLocked;
        })
    end)

    -- Set up alt key listeners
    local function AltKeyCallback(_, State, Input)
        if State.Name == 'Begin' then
            self:setState({
                IsAltDown = true;
            })
        elseif State.Name == 'End' then
            self:setState({
                IsAltDown = false;
            })
        end
        return Enum.ContextActionResult.Pass
    end
    ContextActionService:BindAction('BT/ScopeHUD: Scope', AltKeyCallback, false,
        Enum.KeyCode.LeftAlt,
        Enum.KeyCode.RightAlt
    )

    -- Set up content size listener
    if self.LayoutRef.current then
        local Layout = self.LayoutRef.current
        local LayoutChanged = Layout:GetPropertyChangedSignal('AbsoluteContentSize')
        self.UpdateContainerSize(UDim2.new(0, Layout.AbsoluteContentSize.X, 0, 38/2))
        self.Maid.LayoutListener = LayoutChanged:Connect(function ()
            self.UpdateContainerSize(UDim2.new(0, Layout.AbsoluteContentSize.X, 0, 38/2))
        end)
    end
end
