public class Player : Mono
{
public Weapon gun;

InputListener inputListener;

void Start()
{
inputListener = new(this);
}

void Update()
{
inputListener.OnUpdate();
}

public void OnInputAttack()
{
gun?.Shoot(); //the ? is a null check, its the same thing as if(gun != null) {gun.Shoot();}, if gun is null then Shoot wont be called and a error wont be thrown
}
}

public class InputListener
{
Player player;

public InputListener(Player owner) {player = owner;}

public void OnUpdate()
{
if (Input.GetButton(...)) {owner.OnInputAttack();}
}
}