Open 80O opened 1 year ago
Currently all features for rooms are hardcoded and instantiated in the constructor. This makes it difficult for plugins to add a new service to rooms.
IRoomComponent
[Scoped] public interface IRoomComponent { void Initiate(Room room); void Initiated(); }
IRoomFactory
IServiceProvider
IEnumerable<IRoomComponent>
Room
RoomData
public RoomData Data{get; set;}
Initiate()
Room.Initiate()
IRoomComponent.Initiate(this)
IRoomComponent.Initiated()
Currently all features for rooms are hardcoded and instantiated in the constructor. This makes it difficult for plugins to add a new service to rooms.
IRoomComponent
IRoomFactory
which receives anIServiceProvider
IEnumerable<IRoomComponent>
in the Rooms constructorRoom
no longer extendsRoomData
public RoomData Data{get; set;}
toRoom
Initiate()
toRoom
. Can only be called once. Throw exception if called twice.Room.Initiate()
call eachIRoomComponent.Initiate(this)
then call eachIRoomComponent.Initiated()
so components can be able to be used by others.IRoomFactory
should create a new dependency scope for each room. Scopes must be cached so they can be properly disposed.