Class BrushUserToolState<TBrushTarget, TSettings, TSettingsScreen, TTerrainLayer>
base clas for UserTool state that works with brush and TerrainLayersList component on the terrain entity. Provides an API for getting terrain layer by index or name or index and name combined.
Inheritance
Implements
Inherited Members
Namespace: Fwt.HexTerrains.UserTools.SM
Assembly: fwt.hexterrains.dll
Syntax
public abstract class BrushUserToolState<TBrushTarget, TSettings, TSettingsScreen, TTerrainLayer> : BrushUserToolState<TBrushTarget, TSettings, TSettingsScreen>, ISmState where TBrushTarget : HexTerrainLayerGroup where TSettingsScreen : ToolSettingsScreen<TSettings> where TTerrainLayer : HexTerrainLayer
Type Parameters
| Name | Description |
|---|---|
| TBrushTarget | Terrain layer component (from terrain entity) this user tool works with |
| TSettings | Type of user tool settings (values that user can change like CellItemIndex, RegionIndex, etc.) |
| TSettingsScreen | Type of the UI screen used to display the settings for user, so user can change settings |
| TTerrainLayer | Type of the terrain layer to get from the terrain layer component (which is terrain layers list). Set this param to HexTerrainLayerBase if you don't want to filter the terrain layers. |
Constructors
BrushUserToolState(ISmState)
Declaration
protected BrushUserToolState(ISmState parent)
Parameters
| Type | Name | Description |
|---|---|---|
| ISmState | parent |
Properties
IsGetLayerByIndex
If true, gets terrain layer by index specified in TerrainLayerIndex property.
Declaration
public virtual bool IsGetLayerByIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsGetLayerByName
If true, gets terrain layer by name specified in TerrainLayerName property.
Declaration
public virtual bool IsGetLayerByName { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
TerrainLayerIndex
If IsGetLayerByIndex is true, this index is used to get terrain layer from terrain layers list."/>
Declaration
public virtual int TerrainLayerIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TerrainLayerName
If IsGetLayerByName is true, this name is used to get terrain layer from terrain layers list."/>
Declaration
public virtual string TerrainLayerName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
ViewModeByLayerIndex
List of view modes for each layer index. Index = layer index, value = view mode for that layer active.
Declaration
public virtual List<SetViewModeRequest> ViewModeByLayerIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| List<SetViewModeRequest> |
Methods
GetTerrainLayer()
Retrieves the terrain layer associated with the current brush target.
Declaration
public virtual TTerrainLayer GetTerrainLayer()
Returns
| Type | Description |
|---|---|
| TTerrainLayer | The terrain layer of type |
GetTerrainLayer(TBrushTarget)
Retrieves the terrain layer of type TTerrainLayer from the specified brush target
Declaration
public virtual TTerrainLayer GetTerrainLayer(TBrushTarget brushTarget)
Parameters
| Type | Name | Description |
|---|---|---|
| TBrushTarget | brushTarget | HexTerrainLayerGroup that contains the requested layer |
Returns
| Type | Description |
|---|---|
| TTerrainLayer |
GetTerrainLayer(TBrushTarget, int)
Retrieves the terrain layer of type TTerrainLayer at the specified index from the
given brush target.
Declaration
public virtual TTerrainLayer GetTerrainLayer(TBrushTarget brushTarget, int layerIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| TBrushTarget | brushTarget | The brush target from which to retrieve the terrain layer. Cannot be null. |
| int | layerIndex | The zero-based index of the terrain layer to retrieve. |
Returns
| Type | Description |
|---|---|
| TTerrainLayer | The terrain layer of type |
GetTerrainLayer(TBrushTarget, int, string)
Retrieves a terrain layer from the specified brush target by index and name.
Declaration
public virtual TTerrainLayer GetTerrainLayer(TBrushTarget brushTarget, int layerIndex, string layerName)
Parameters
| Type | Name | Description |
|---|---|---|
| TBrushTarget | brushTarget | The brush target from which to retrieve the terrain layer. If null, the method returns the default value for
|
| int | layerIndex | The zero-based index of the terrain layer to retrieve. |
| string | layerName | The name of the terrain layer to retrieve. Used to identify the layer within the brush target. |
Returns
| Type | Description |
|---|---|
| TTerrainLayer | The terrain layer of type |
GetTerrainLayer(TBrushTarget, string)
Retrieves the terrain layer with the specified name from the given brush target.
Declaration
public virtual TTerrainLayer GetTerrainLayer(TBrushTarget brushTarget, string layerName)
Parameters
| Type | Name | Description |
|---|---|---|
| TBrushTarget | brushTarget | The brush target from which to retrieve the terrain layer. If null, the method returns the default value for the terrain layer type. |
| string | layerName | The name of the terrain layer to retrieve. This value is case-sensitive. |
Returns
| Type | Description |
|---|---|
| TTerrainLayer | The terrain layer of type TTerrainLayer with the specified name, or the default value for TTerrainLayer if the brush target is null or the layer does not exist. |
GetViewModeByLayerIndex(int)
Retrieves the view mode associated with the specified terrain layer index.
Declaration
protected virtual SetViewModeRequest GetViewModeByLayerIndex(int terrainLayerIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | terrainLayerIndex | The zero-based index of the terrain layer for which to obtain the view mode. Must be within the bounds of the available terrain layers. |
Returns
| Type | Description |
|---|---|
| SetViewModeRequest | An integer representing the view mode for the specified terrain layer index. Returns the default view mode if the index is out of range or if no view modes are defined. |
Init<TInitArgs>(TInitArgs)
Initializes the tool using the specified initialization arguments.
Declaration
public override void Init<TInitArgs>(TInitArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| TInitArgs | args | The initialization arguments used to configure the tool. If the argument implements IUserToolStateConfig, its ToolSettings are used; otherwise, default settings are applied. |
Type Parameters
| Name | Description |
|---|---|
| TInitArgs | The type of the initialization arguments used to configure the tool. If the type implements IUserToolStateConfig, its ToolSettings will be used; otherwise, default settings are applied. |
Overrides
OnTerrainLayerChanged()
Invoked when the terrain layer changes to update the view mode accordingly.
Declaration
protected virtual void OnTerrainLayerChanged()
Remarks
Derived classes can override this method to implement custom behavior when the terrain layer changes. This method is called automatically and should not be invoked directly.
TrySetViewMode()
Attempts to update the view mode based on the current terrain layer index if a view mode change is requested.
Declaration
protected override void TrySetViewMode()
Overrides
Remarks
This method checks whether a view mode change is enabled in the user tool settings before updating the view mode. Override this method to customize how view mode changes are handled in derived classes.
UpdateDescriptionAndErrorMessageOnDataSource()
Updates the description and error message properties on the associated data source to reflect the current terrain layer state.
Declaration
protected virtual void UpdateDescriptionAndErrorMessageOnDataSource()
Remarks
If the data source implements IErrorAndDescriptionUserToolSettingsDataSource, this method sets the error message to indicate when no terrain layer is found at the specified index, or updates the description with the terrain layer's name when available. If the data source also implements ICommitChanges, changes are committed after updating the properties. Override this method to customize how description and error message updates are handled for different data source types.
UpdateSettingsScreen()
Refreshes the settings screen to reflect the current state of the data source.
Declaration
public override void UpdateSettingsScreen()
Overrides
Remarks
If the data source implements ICommitChanges, any pending changes are committed before the settings screen is updated. This ensures that the settings screen displays the most up-to-date information.