As the title says, is it reasonable for an object to subscribe to its own events?
public class Player
{
private int team;
public Action<int> TeamChanged { get; set; }
public Player(int startingTeam)
{
team = startingTeam;
TeamChanged += OnTeamChanged; // subscribe to my own event
}
private void OnTeamChanged(int newTeam)
{
team = newTeam;
}
}
// later during the match:
public void ShuffleTeam()
{
player.TeamChanged(GetRandomTeam());
}
It seems a lot more succinct than having an extra ChangeTeam() function, which invokes the event itself. But also feels wrong for some reason.