Table of Contents

Class Layout

Namespace
Uncreated.Warfare.Layouts
Assembly
Uncreated.Warfare.dll

Lasts for one game. Responsible for loading layouts.

public class Layout : IDisposable
Inheritance
Layout
Implements
Inherited Members

Constructors

Layout(ILifetimeScope, LayoutInfo, List<IDisposable>)

Create a new Layout.

public Layout(ILifetimeScope serviceProvider, LayoutInfo layoutInfo, List<IDisposable> disposableConfigs)

Parameters

serviceProvider ILifetimeScope
layoutInfo LayoutInfo
disposableConfigs List<IDisposable>

Remarks

For any classes overriding this class, any services injecting the layout must be initialized using the IServiceProvider in the constructor.

Fields

Logger

protected ILogger<Layout> Logger

Field Value

ILogger<Layout>

Properties

ActivePhase

The currently active phase, or null if there are no active phases.

public ILayoutPhase? ActivePhase { get; }

Property Value

ILayoutPhase

Data

Data that can be accessed and updated over the lifetime of the layout.

public IDictionary<string, object> Data { get; }

Property Value

IDictionary<string, object>

Remarks

Known keys are stored in KnownLayoutDataKeys.

IsActive

If the layout is currently running.

public bool IsActive { get; }

Property Value

bool

LayoutConfiguration

Configuration that defines how the layout of the game is loaded.

public IConfigurationRoot LayoutConfiguration { get; }

Property Value

IConfigurationRoot

LayoutId

A unique ID to this layout.

public ulong LayoutId { get; }

Property Value

ulong

LayoutInfo

Pre-determined settings for the layout.

public LayoutInfo LayoutInfo { get; }

Property Value

LayoutInfo

LayoutStats

Reference to a database entry for this layout.

public GameRecord LayoutStats { get; }

Property Value

GameRecord

NextPhase

The phase after the current phase, or null if we are on the last phase.

public ILayoutPhase? NextPhase { get; }

Property Value

ILayoutPhase

PhaseList

Exposed to allow sub-classes to manually add phases if needed.

protected IList<ILayoutPhase> PhaseList { get; }

Property Value

IList<ILayoutPhase>

Phases

The current phase rotation.

public IReadOnlyList<ILayoutPhase> Phases { get; }

Property Value

IReadOnlyList<ILayoutPhase>

PreviousPhase

The phase before the current phase, or null if we are on the first phase.

public ILayoutPhase? PreviousPhase { get; }

Property Value

ILayoutPhase

ServiceProvider

Scoped service provider for this layout.

public ILifetimeScope ServiceProvider { get; }

Property Value

ILifetimeScope

TeamManager

Keeps track of all teams.

public ITeamManager<Team> TeamManager { get; protected set; }

Property Value

ITeamManager<Team>

UnloadToken

Token that will cancel when the layout ends.

public CancellationToken UnloadToken { get; }

Property Value

CancellationToken

WasStarted

Whether or not the layout was able to fully start.

public bool WasStarted { get; }

Property Value

bool

Methods

ApplyLayoutConfigurationUpdateAsync(CancellationToken)

Invoked when a change is made to LayoutConfiguration.

protected virtual UniTask ApplyLayoutConfigurationUpdateAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

UniTask

BeginLayoutAsync(CancellationToken)

Invoked when the layout first begins.

protected virtual UniTask BeginLayoutAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

UniTask

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EndLayoutAsync(CancellationToken)

Invoked when the layout ends. Try not to use SwitchToMainThread(CancellationToken) here.

protected virtual UniTask EndLayoutAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

UniTask

InitializeLayoutAsync(GameRecord, CancellationToken)

Invoked just before BeginLayoutAsync(CancellationToken) as a chance for values to be initialized from LayoutConfiguration.

protected virtual UniTask InitializeLayoutAsync(GameRecord stats, CancellationToken token = default)

Parameters

stats GameRecord
token CancellationToken

Returns

UniTask

MoveToNextPhase(CancellationToken)

public virtual UniTask MoveToNextPhase(CancellationToken token = default)

Parameters

token CancellationToken

Returns

UniTask

ReadPhaseAsync(Type, IConfigurationSection, CancellationToken)

Parse a phase from the phases section of the config file.

protected virtual UniTask<ILayoutPhase?> ReadPhaseAsync(Type phaseType, IConfigurationSection configSection, CancellationToken token = default)

Parameters

phaseType Type
configSection IConfigurationSection
token CancellationToken

Returns

UniTask<ILayoutPhase>

The new phase, or null to not use the phase. An error will be logged.

ReadTeamInfoAsync(CancellationToken)

Read information about which ITeamManager<TTeam> to use and create it.

protected virtual UniTask ReadTeamInfoAsync(CancellationToken token = default)

Parameters

token CancellationToken

Returns

UniTask

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TriggerVictoryAsync(Team)

Sets the winner of the game and moves to the next phase.

public UniTask TriggerVictoryAsync(Team winner)

Parameters

winner Team

Returns

UniTask