Class LayoutController<TLayout, TNode, TConfiguration, TShapeContainer, TEnergyData>
Layout operations that compute energy based on given constraints.
Inheritance
System.Object
LayoutController<TLayout, TNode, TConfiguration, TShapeContainer, TEnergyData>
Assembly: Edgar.dll
Syntax
public class LayoutController<TLayout, TNode, TConfiguration, TShapeContainer, TEnergyData> : AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>, IChainBasedLayoutOperations<TLayout, TNode>, ILayoutOperations<TLayout, TNode>, IRandomInjectable where TLayout : ILayout<TNode, TConfiguration>, ISmartCloneable<TLayout> where TConfiguration : IConfiguration<TShapeContainer, Vector2Int, TNode>, ISmartCloneable<TConfiguration>, IEnergyConfiguration<TEnergyData>, new()
where TEnergyData : IEnergyData, new()
Type Parameters
Name |
Description |
TLayout |
|
TNode |
|
TConfiguration |
|
TShapeContainer |
|
TEnergyData |
|
Constructors
LayoutController(Int32, ILevelDescription<TNode>, ConstraintsEvaluator<TNode, TConfiguration, TEnergyData>, IRoomShapesHandler<TLayout, TNode, TShapeContainer>, Boolean, IConfigurationSpaces<TConfiguration, Vector2Int>, IRoomShapeGeometry<TConfiguration>)
Declaration
public LayoutController(int averageSize, ILevelDescription<TNode> levelDescription, ConstraintsEvaluator<TNode, TConfiguration, TEnergyData> constraintsEvaluator, IRoomShapesHandler<TLayout, TNode, TShapeContainer> roomShapesHandler, bool throwIfRepeatModeNotSatisfied, IConfigurationSpaces<TConfiguration, Vector2Int> simpleConfigurationSpaces, IRoomShapeGeometry<TConfiguration> roomShapeGeometry)
Parameters
Methods
AddChain(TLayout, IList<TNode>, Boolean, out Int32)
Greedily adds only non corridor nodes to the layout.
Declaration
public override void AddChain(TLayout layout, IList<TNode> chain, bool updateLayout, out int iterationsCount)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
System.Collections.Generic.IList<TNode> |
chain |
|
System.Boolean |
updateLayout |
|
System.Int32 |
iterationsCount |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.AddChain(TLayout, System.Collections.Generic.IList<TNode>, System.Boolean, System.Int32)
AddCorridorGreedily(TLayout, TNode)
Adds corridor node greedily.
Declaration
public bool AddCorridorGreedily(TLayout layout, TNode node)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
TNode |
node |
|
Returns
Type |
Description |
System.Boolean |
|
AddNodeGreedily(TLayout, TNode, out Int32)
Tries all shapes and positions from the maximum intersection to find a configuration
with the lowest energy.
Declaration
public override void AddNodeGreedily(TLayout layout, TNode node, out int iterationsCount)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
TNode |
node |
|
System.Int32 |
iterationsCount |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.AddNodeGreedily(TLayout, TNode, System.Int32)
CreateConfiguration(TShapeContainer, Vector2Int, TNode)
Creates a configuration with a given shape container and position.
Declaration
protected TConfiguration CreateConfiguration(TShapeContainer shapeContainer, Vector2Int position, TNode node)
Parameters
Type |
Name |
Description |
TShapeContainer |
shapeContainer |
|
Vector2Int |
position |
|
TNode |
node |
|
Returns
Type |
Description |
TConfiguration |
|
GetEnergy(TLayout)
Gets an energy of a given layout by summing energies of individual nodes.
Declaration
public override float GetEnergy(TLayout layout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
Returns
Type |
Description |
System.Single |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.GetEnergy(TLayout)
IsLayoutValid(TLayout)
Checks if a given layout is valid by first checking whether the layout itself is valid
and then checking whether all configurations of nodes are valid.
Declaration
public override bool IsLayoutValid(TLayout layout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.IsLayoutValid(TLayout)
IsLayoutValid(TLayout, IList<TNode>)
TODO: should it check if all nodes are laid out?
Checks if a given layout is valid by first checking whether the layout itself is valid
and then checking whether all configurations of nodes are valid.
Declaration
public override bool IsLayoutValid(TLayout layout, IList<TNode> chain)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
System.Collections.Generic.IList<TNode> |
chain |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.IsLayoutValid(TLayout, System.Collections.Generic.IList<TNode>)
PerturbLayout(TLayout, IList<TNode>, Boolean)
Perturbs non corridor rooms until a valid layout is found.
Then tries to use a greedy algorithm to lay out corridor rooms.
Declaration
public override void PerturbLayout(TLayout layout, IList<TNode> chain, bool updateLayout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
System.Collections.Generic.IList<TNode> |
chain |
|
System.Boolean |
updateLayout |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.PerturbLayout(TLayout, System.Collections.Generic.IList<TNode>, System.Boolean)
PerturbPosition(TLayout, TNode, Boolean)
Declaration
public override void PerturbPosition(TLayout layout, TNode node, bool updateLayout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
TNode |
node |
|
System.Boolean |
updateLayout |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.PerturbPosition(TLayout, TNode, System.Boolean)
PerturbShape(TLayout, TNode, Boolean)
Declaration
public override void PerturbShape(TLayout layout, TNode node, bool updateLayout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
TNode |
node |
|
System.Boolean |
updateLayout |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.PerturbShape(TLayout, TNode, System.Boolean)
PerturbShape(TLayout, IList<TNode>, Boolean)
Declaration
public override void PerturbShape(TLayout layout, IList<TNode> chain, bool updateLayout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
System.Collections.Generic.IList<TNode> |
chain |
|
System.Boolean |
updateLayout |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.PerturbShape(TLayout, System.Collections.Generic.IList<TNode>, System.Boolean)
TryCompleteChain(TLayout, IList<TNode>)
Declaration
public override bool TryCompleteChain(TLayout layout, IList<TNode> chain)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
System.Collections.Generic.IList<TNode> |
chain |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.TryCompleteChain(TLayout, System.Collections.Generic.IList<TNode>)
UpdateLayout(TLayout)
Updates a given layout by computing energies of all nodes.
Declaration
public override void UpdateLayout(TLayout layout)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.UpdateLayout(TLayout)
UpdateLayout(TLayout, TNode, TConfiguration)
Declaration
protected override void UpdateLayout(TLayout layout, TNode perturbedNode, TConfiguration configuration)
Parameters
Type |
Name |
Description |
TLayout |
layout |
|
TNode |
perturbedNode |
|
TConfiguration |
configuration |
|
Overrides
Edgar.GraphBasedGenerator.Common.AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>.UpdateLayout(TLayout, TNode, TConfiguration)
Implements