There isn't really any reason to keep MainCharacter in its own repository. It's convenient, but leads to a lot of code such as
if (id == _characterProvider.MainCharacter.ID)
{
...
}
else if (_currentMapStateProvider.Characters.Contains(id))
{
...
}
else
{
...
}
Which is pretty bloated when the operations are usually the same thing.
Instead, it would be better to store the ID of the main player in the PlayerInfoProvider and put all characters and their renderers in the same collection, without differentiating between "main player" and other logged-in players. Packets that are handled specifically for the main player can use the property in PlayerInfoProvider to find the right character.
There isn't really any reason to keep
MainCharacter
in its own repository. It's convenient, but leads to a lot of code such asWhich is pretty bloated when the operations are usually the same thing.
Instead, it would be better to store the ID of the main player in the
PlayerInfoProvider
and put all characters and their renderers in the same collection, without differentiating between "main player" and other logged-in players. Packets that are handled specifically for the main player can use the property inPlayerInfoProvider
to find the right character.