Class LayoutFactory
[Priority(-2147483648)]
public class LayoutFactory : IHostedService, IEventListener<PlayerJoined>
- Inheritance
-
LayoutFactory
- Implements
- Inherited Members
Constructors
LayoutFactory(WarfareModule, ILogger<LayoutFactory>, IGameDataDbContext, MapScheduler, IConfiguration, IPlayerService, SessionManager)
public LayoutFactory(WarfareModule warfare, ILogger<LayoutFactory> logger, IGameDataDbContext dbContext, MapScheduler mapScheduler, IConfiguration systemConfig, IPlayerService playerService, SessionManager sessionService)
Parameters
warfareWarfareModuleloggerILogger<LayoutFactory>dbContextIGameDataDbContextmapSchedulerMapSchedulersystemConfigIConfigurationplayerServiceIPlayerServicesessionServiceSessionManager
Properties
IsLoading
public bool IsLoading { get; }
Property Value
NextLayout
public FileInfo? NextLayout { get; set; }
Property Value
Methods
ApplyVariation(ref IConfiguration, string, string)
Apply variations read from a specific configuration section.
public void ApplyVariation(ref IConfiguration configuration, string context, string baseFilePath)
Parameters
configurationIConfigurationcontextstringbaseFilePathstring
GetBaseLayoutFiles()
Get all base config files in the layout folder.
public List<FileInfo> GetBaseLayoutFiles()
Returns
ReadLayoutInfo(string, bool, bool?, bool)
Read a LayoutInfo from the given file and open a configuration root for the file.
public LayoutInfo? ReadLayoutInfo(string file, bool variations, bool? expectedSeedingState = null, bool reloadOnChange = false)
Parameters
Returns
ReadVariations(string, string, IConfiguration)
Read a list of variations from a configuration section.
public List<LayoutVariationInfo>? ReadVariations(string context, string baseFilePath, IConfiguration configSection)
Parameters
contextstringbaseFilePathstringconfigSectionIConfiguration
Returns
SelectLayoutByName(string)
public LayoutInfo? SelectLayoutByName(string layoutName)
Parameters
layoutNamestring
Returns
SelectRandomLayout(bool)
Read all layouts and select a random one.
public LayoutInfo SelectRandomLayout(bool seeding = false)
Parameters
seedingbool
Returns
Remarks
Reading them each time keeps us from having to reload config.
Exceptions
- InvalidOperationException
No layouts are configured.
StartAsync(CancellationToken)
Executes at module startup.
public UniTask StartAsync(CancellationToken token)
Parameters
tokenCancellationToken
Returns
- UniTask
StartNextLayout(CancellationToken)
Forcibly end the current layout and create a new random layout from the config files.
public UniTask StartNextLayout(CancellationToken token = default)
Parameters
tokenCancellationToken
Returns
- UniTask
StopAsync(CancellationToken)
Executes at module shutdown.
public UniTask StopAsync(CancellationToken token)
Parameters
tokenCancellationToken
Returns
- UniTask
Events
LoadingStateUpdated
public event Action<bool>? LoadingStateUpdated