Class StampUserToolStateBase<TBrushTarget, TCellData>
Provides a base class for user tool states that support stamping operations on terrain or grid-based targets, allowing users to read and apply cell data using configurable origin coordinates and input keys. Stamping means copying data from a specified origin cell to other cells based on brush operations.
Inheritance
Implements
Inherited Members
Namespace: Fwt.HexTerrains.UserTools.SM.States
Assembly: fwt.hexterrains.dll
Syntax
public abstract class StampUserToolStateBase<TBrushTarget, TCellData> : BrushUserToolState<TBrushTarget, UserToolSettingsDataSource, UniversalToolSettingsScreen>, ISmState where TBrushTarget : class
Type Parameters
| Name | Description |
|---|---|
| TBrushTarget | The type of the brush target that the stamping operations will be applied to. Must be a reference type. |
| TCellData | The type of cell data that is read from the origin cell and applied to the target. |
Remarks
This class manages the origin coordinates for stamping operations and supports reading cell data from a specified origin cell using a configurable key. It is intended to be subclassed to implement specific logic for reading and applying cell data. The origin coordinates are clamped between 0 and 255 by default. The class integrates with terrain APIs to determine cell indices and coordinates, and provides overridable methods for customizing cell data handling.
Constructors
StampUserToolStateBase(ISmState)
Declaration
protected StampUserToolStateBase(ISmState parent)
Parameters
| Type | Name | Description |
|---|---|---|
| ISmState | parent |
Properties
OriginCellIndex
The index of the origin cell based on the origin coordinates.
Declaration
public virtual int? OriginCellIndex { get; }
Property Value
| Type | Description |
|---|---|
| int? |
OriginCoordinate
The origin coordinate as an int2 structure.
Declaration
public virtual int2 OriginCoordinate { get; set; }
Property Value
| Type | Description |
|---|---|
| int2 |
OriginXCoord
The X-coordinate of the origin point.
Declaration
public virtual int OriginXCoord { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
OriginYCoord
The Y-coordinate of the origin point in the data source.
Declaration
public virtual int OriginYCoord { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
ReadCellKey
When this key is pressed, the tool changes the origin cell to the cell under the cursor.
Declaration
public virtual KeyCode ReadCellKey { get; set; }
Property Value
| Type | Description |
|---|---|
| KeyCode |
StartPaintCellCoord
The starting cell coordinate when painting begins.
Declaration
protected virtual int2? StartPaintCellCoord { get; set; }
Property Value
| Type | Description |
|---|---|
| int2? |
Methods
ApplyBrush(int, int2, int, TBrushTarget, int)
Applies brush to the brushView. Returns true if changes were applied
Declaration
public override bool ApplyBrush(int brushMode, int2 cellCoord, int cellIndex, TBrushTarget brushTarget, int mouseButton)
Parameters
| Type | Name | Description |
|---|---|---|
| int | brushMode | |
| int2 | cellCoord | |
| int | cellIndex | |
| TBrushTarget | brushTarget | |
| int | mouseButton |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
Init(UserToolStateSettings)
Initializes the tool state with the specified settings.
Declaration
public override void Init(UserToolStateSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| UserToolStateSettings | settings | The settings to apply to the tool state. Cannot be null. |
Overrides
InitDefaultSettings()
Initializes the default settings for the current instance. This method is intended to be overridden in derived classes to configure initial values or options as needed.
Declaration
protected override void InitDefaultSettings()
Overrides
Remarks
Override this method in a subclass to provide custom initialization logic for default settings. The base implementation does not perform any actions.
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
PrepareToRun()
Performs any necessary initialization or setup required before executing the main operation. Called by state machine once when state becomes active. If state is disabled and then enabled again, this method will be called again.
Declaration
public override void PrepareToRun()
Overrides
Remarks
Override this method to implement preparation logic specific to the derived class. This method should be called prior to running the core functionality to ensure all prerequisites are met.
ReadOriginCellData(int, out TCellData)
Attempts to read the original data for the specified cell index.
Declaration
public abstract bool ReadOriginCellData(int cellIndex, out TCellData cellData)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | The zero-based index of the cell whose data is to be read. Must be within the valid range of available cells. |
| TCellData | cellData | When this method returns, contains the data of the cell at the specified index if the read operation
succeeds; otherwise, contains the default value for |
Returns
| Type | Description |
|---|---|
| bool | true if the cell data was successfully read; otherwise, false. |
SetCellDataToTarget(int, TCellData)
Sets the data for the specified cell in the target object.
Declaration
public abstract bool SetCellDataToTarget(int cellIndex, TCellData cellData)
Parameters
| Type | Name | Description |
|---|---|---|
| int | cellIndex | The zero-based index of the cell to update. Must be within the valid range of cell indices for the target. |
| TCellData | cellData | The data to assign to the specified cell. The type and constraints of this value depend on the implementation. |
Returns
| Type | Description |
|---|---|
| bool | true if the cell data was successfully set; otherwise, false. |
UpdateBrush()
Updates the terrain brush's appearance and behavior based on the current input state and configuration. This includes setting brush visibility, color, size, and opacity according to user interactions and allowed changes.
Declaration
protected override void UpdateBrush()
Overrides
Remarks
This method responds to user input to adjust the brush size or opacity, depending on the active mode and configuration flags. It is typically called to synchronize the brush's properties with the user's actions in real time. Override this method to customize how brush updates are handled in derived classes.