yea honestly JaN0h4ck's advice by moving the input check into is probably what you'd want to have a crack into trying otherwise for cleaning up code I would recommend 100% using Godot's actions so instead of doing an if statement for checking InputEventMouseButton and if its pressed or not and then checking the button index, just use an event.is_action_[pressed/released], or you check if the event is an action type and then call a separate function passing the event in to check the action just to make your _input function a little cleaner by only having the logic for the non button events happening in there
also considering how much youre calling camera.get_global_mouse_position() and whatnot, I feel like you may as well just set a variable at the top of the func for it, having the space for that would also help if you were to look into any other "mouse" position stuff such as touch screen inputs or virtual pointers from a controller
ive sunk almost 100 hours into Inscryption (deck building roguelike)