Table of Contents

Class LayoutFactory

Namespace
Uncreated.Warfare.Layouts
Assembly
Uncreated.Warfare.dll
[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

warfare WarfareModule
logger ILogger<LayoutFactory>
dbContext IGameDataDbContext
mapScheduler MapScheduler
systemConfig IConfiguration
playerService IPlayerService
sessionService SessionManager

Properties

IsLoading

public bool IsLoading { get; }

Property Value

bool

NextLayout

public FileInfo? NextLayout { get; set; }

Property Value

FileInfo

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

configuration IConfiguration
context string
baseFilePath string

GetBaseLayoutFiles()

Get all base config files in the layout folder.

public List<FileInfo> GetBaseLayoutFiles()

Returns

List<FileInfo>

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

file string
variations bool
expectedSeedingState bool?
reloadOnChange bool

Returns

LayoutInfo

ReadVariations(string, string, IConfiguration)

Read a list of variations from a configuration section.

public List<LayoutVariationInfo>? ReadVariations(string context, string baseFilePath, IConfiguration configSection)

Parameters

context string
baseFilePath string
configSection IConfiguration

Returns

List<LayoutVariationInfo>

SelectLayoutByName(string)

public LayoutInfo? SelectLayoutByName(string layoutName)

Parameters

layoutName string

Returns

LayoutInfo

SelectRandomLayout(bool)

Read all layouts and select a random one.

public LayoutInfo SelectRandomLayout(bool seeding = false)

Parameters

seeding bool

Returns

LayoutInfo

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

token CancellationToken

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

token CancellationToken

Returns

UniTask

StopAsync(CancellationToken)

Executes at module shutdown.

public UniTask StopAsync(CancellationToken token)

Parameters

token CancellationToken

Returns

UniTask

Events

LoadingStateUpdated

public event Action<bool>? LoadingStateUpdated

Event Type

Action<bool>