Class Layout
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
serviceProviderILifetimeScopelayoutInfoLayoutInfodisposableConfigsList<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
Properties
ActivePhase
The currently active phase, or null if there are no active phases.
public ILayoutPhase? ActivePhase { get; }
Property Value
Data
Data that can be accessed and updated over the lifetime of the layout.
public IDictionary<string, object> Data { get; }
Property Value
Remarks
Known keys are stored in KnownLayoutDataKeys.
IsActive
If the layout is currently running.
public bool IsActive { get; }
Property Value
LayoutConfiguration
Configuration that defines how the layout of the game is loaded.
public IConfigurationRoot LayoutConfiguration { get; }
Property Value
LayoutId
A unique ID to this layout.
public ulong LayoutId { get; }
Property Value
LayoutInfo
Pre-determined settings for the layout.
public LayoutInfo LayoutInfo { get; }
Property Value
LayoutStats
Reference to a database entry for this layout.
public GameRecord LayoutStats { get; }
Property Value
NextPhase
The phase after the current phase, or null if we are on the last phase.
public ILayoutPhase? NextPhase { get; }
Property Value
PhaseList
Exposed to allow sub-classes to manually add phases if needed.
protected IList<ILayoutPhase> PhaseList { get; }
Property Value
Phases
The current phase rotation.
public IReadOnlyList<ILayoutPhase> Phases { get; }
Property Value
PreviousPhase
The phase before the current phase, or null if we are on the first phase.
public ILayoutPhase? PreviousPhase { get; }
Property Value
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
UnloadToken
Token that will cancel when the layout ends.
public CancellationToken UnloadToken { get; }
Property Value
WasStarted
Whether or not the layout was able to fully start.
public bool WasStarted { get; }
Property Value
Methods
ApplyLayoutConfigurationUpdateAsync(CancellationToken)
Invoked when a change is made to LayoutConfiguration.
protected virtual UniTask ApplyLayoutConfigurationUpdateAsync(CancellationToken token = default)
Parameters
tokenCancellationToken
Returns
- UniTask
BeginLayoutAsync(CancellationToken)
Invoked when the layout first begins.
protected virtual UniTask BeginLayoutAsync(CancellationToken token = default)
Parameters
tokenCancellationToken
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
tokenCancellationToken
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
statsGameRecordtokenCancellationToken
Returns
- UniTask
MoveToNextPhase(CancellationToken)
public virtual UniTask MoveToNextPhase(CancellationToken token = default)
Parameters
tokenCancellationToken
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
phaseTypeTypeconfigSectionIConfigurationSectiontokenCancellationToken
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
tokenCancellationToken
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
winnerTeam
Returns
- UniTask