Hex Terrains Framework
Search Results for

    Show / Hide Table of Contents

    Class CreateNewTerrainUserToolStateBase<TScreen, TViewData>

    Provides a base state for user tools that create new hex terrain, managing the associated UI screen and view data for terrain creation workflows.

    Inheritance
    object
    SmState
    UserToolStateBase
    HexTerrainUserToolStateBase
    CreateNewTerrainUserToolStateBase<TScreen, TViewData>
    CreateNewTerrainUserToolState
    Implements
    ISmState
    Inherited Members
    HexTerrainUserToolStateBase.TerrainAPI
    HexTerrainUserToolStateBase.HexTerrainUserToolSettings
    HexTerrainUserToolStateBase.PreviousViewMode
    HexTerrainUserToolStateBase.Init(HexTerrainUserToolStateSettings)
    HexTerrainUserToolStateBase.Init(IHexTerrainAPI)
    HexTerrainUserToolStateBase.Init<TInitArgs>(IHexTerrainAPI, TInitArgs)
    HexTerrainUserToolStateBase.ShowSettingsScreen<TViewData, TScreen>(TViewData)
    HexTerrainUserToolStateBase.GetUIScreen<TScreen>()
    HexTerrainUserToolStateBase.HideSettingsScreen<TScreen>()
    HexTerrainUserToolStateBase.SetupTerrainCursor(bool, int)
    HexTerrainUserToolStateBase.SetupTerrainCursor(bool, int, Color32)
    HexTerrainUserToolStateBase.SetupTerrainCursor(bool, int, Color32, bool)
    HexTerrainUserToolStateBase.SetupTerrainCursor(bool)
    HexTerrainUserToolStateBase.GetTerrainLayer<TLayerGroup, TLayer>(HexTerrainLayerReference)
    HexTerrainUserToolStateBase.TrySetViewMode()
    HexTerrainUserToolStateBase.SetViewMode(SetViewModeRequest)
    HexTerrainUserToolStateBase.TryRestoreViewMode()
    UserToolStateBase.Settings
    UserToolStateBase.Parent
    UserToolStateBase.ParentStateMachine
    UserToolStateBase.Init(UserToolStateSettings)
    UserToolStateBase.Tick()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Fwt.HexTerrains.UserTools.SM.States
    Assembly: fwt.hexterrains.dll
    Syntax
    public abstract class CreateNewTerrainUserToolStateBase<TScreen, TViewData> : HexTerrainUserToolStateBase, ISmState where TScreen : UIScreen, IViewDataReceiver<TViewData> where TViewData : class, ICreateNewTerrainStateViewData, new()
    Type Parameters
    Name Description
    TScreen

    The type of UI screen used to display terrain creation controls. Must implement UIScreen and receive view data of type TViewData.

    TViewData

    The type of view data provided to the UI screen, containing terrain creation settings and callbacks. Must implement ICreateNewTerrainStateViewData and have a parameterless constructor.

    Remarks

    This abstract base class coordinates the UI and data required for creating new terrain in a hex-based environment. It handles showing and hiding the terrain creation screen, preparing view data, and managing user actions such as creating terrain or cancelling the operation. Derived classes can override virtual members to customize UI behavior or data preparation. The state transitions back to the pointer tool after terrain creation or cancellation.

    Constructors

    CreateNewTerrainUserToolStateBase(ISmState)

    Declaration
    protected CreateNewTerrainUserToolStateBase(ISmState parent)
    Parameters
    Type Name Description
    ISmState parent

    Fields

    DefaultHexTerrainSettings

    The default settings to be displayed on the Create New Terrain screen when no existing terrain settings are available. This serves as a fallback configuration to ensure that the UI has valid settings to work with, even if the user has not previously created terrain or if there is an issue retrieving existing settings.

    Declaration
    public HexTerrainSettings DefaultHexTerrainSettings
    Field Value
    Type Description
    HexTerrainSettings

    Properties

    Screen

    Gets or sets the current screen instance associated with the create new terrain user tool state.

    Declaration
    protected virtual TScreen Screen { get; set; }
    Property Value
    Type Description
    TScreen
    Remarks

    Derived classes can override this property to provide custom screen management behavior. The value may be null if no screen is currently assigned.

    UserToolType

    Type identifier for the user tool. Allows state machine to change states based on tool type instead of state index.

    Declaration
    public override int UserToolType { get; }
    Property Value
    Type Description
    int
    Overrides
    UserToolStateBase.UserToolType

    ViewData

    Gets or sets the view-specific data associated with the current context.

    Declaration
    protected virtual TViewData ViewData { get; set; }
    Property Value
    Type Description
    TViewData
    Remarks

    Derived classes can override this property to provide custom view data handling or to supply additional context-specific information to views.

    Methods

    CancelResizing()

    Cancels the current resizing operation and resets the tool to the default pointer mode.

    Declaration
    public virtual void CancelResizing()
    Remarks

    Use this method to abort an active resize action and return the state machine to its default selection tool. This is typically called in response to user actions such as pressing the Escape key or clicking outside the resizable area.

    CreateTerrain(IHexTerrainPrefabConfig, HexTerrainSettings)

    Creates a new terrain instance using the specified prefab configuration and terrain settings.

    Declaration
    public virtual void CreateTerrain(IHexTerrainPrefabConfig terrainPrefabConfig, HexTerrainSettings terrainSettings)
    Parameters
    Type Name Description
    IHexTerrainPrefabConfig terrainPrefabConfig

    The configuration object that defines the terrain prefab to use for creation. Cannot be null.

    HexTerrainSettings terrainSettings

    The settings that specify parameters for the new terrain, such as size, shape, or other terrain properties. Cannot be null.

    Remarks

    After creating the terrain, the state machine is switched to the pointer tool. This method does not return a value and does not provide direct access to the created terrain instance.

    CreateViewData()

    Creates and initializes a new instance of TViewData with default terrain settings, prefab configurations, and associated callbacks.

    Declaration
    protected virtual TViewData CreateViewData()
    Returns
    Type Description
    TViewData

    A new TViewData instance populated with terrain prefab configurations, default settings, and callback delegates. The TerrainPrefab property is set to the first available prefab, or null if none are available.

    GetExistingTerrainSettings()

    Retrieves the current terrain settings if available.

    Declaration
    protected virtual HexTerrainSettings? GetExistingTerrainSettings()
    Returns
    Type Description
    HexTerrainSettings?

    A HexTerrainSettings object representing the existing terrain settings, or null if no settings are available.

    GetUIScreen()

    Retrieves the current UI screen instance of type TScreen. If the screen does not exist, a new instance is created and returned.

    Declaration
    protected virtual TScreen GetUIScreen()
    Returns
    Type Description
    TScreen

    The UI screen instance of type TScreen. If no instance exists, a new one is created and returned.

    Remarks

    This method caches the screen instance after creation. Subsequent calls return the same instance unless it is reset externally.

    GetViewData(TScreen)

    Retrieves the view data associated with the specified screen.

    Declaration
    protected virtual TViewData GetViewData(TScreen screen)
    Parameters
    Type Name Description
    TScreen screen

    The screen for which to obtain the corresponding view data.

    Returns
    Type Description
    TViewData

    The view data instance associated with the specified screen.

    HideUIScreen()

    Hides the associated UI screen if it is currently visible.

    Declaration
    protected virtual void HideUIScreen()
    Remarks

    Derived classes can override this method to customize the behavior when hiding the UI screen. This method does nothing if the screen is null.

    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
    HexTerrainUserToolStateBase.Init<TInitArgs>(TInitArgs)

    PrepareToRun()

    Prepares the component for execution by initializing required UI elements and terrain cursor state.

    Declaration
    public override void PrepareToRun()
    Overrides
    HexTerrainUserToolStateBase.PrepareToRun()
    Remarks

    Call this method before starting operations that depend on the UI or terrain cursor being initialized. Overrides the base implementation to perform additional setup specific to this component.

    PrepareToStop()

    Prepares the component for stopping by performing necessary cleanup and UI state changes.

    Declaration
    public override void PrepareToStop()
    Overrides
    HexTerrainUserToolStateBase.PrepareToStop()
    Remarks

    This method should be called before stopping the component to ensure that any active UI screens are hidden and the component is left in a consistent state. Overrides the base implementation to include additional UI handling.

    ShowUIScreen()

    Displays the associated UI screen and initializes it with the relevant view data.

    Declaration
    protected virtual void ShowUIScreen()
    Remarks

    Override this method to customize how the UI screen is shown or how view data is assigned. This method retrieves the UI screen instance, displays it, and sets its view data if available.

    Implements

    ISmState

    Extension Methods

    HashExtensions.GetHashCode_RefType<TValue>(TValue, int)
    Extensions_UnityObject.SmartDestroy(object)
    Extensions_UnityObject.SmartGetComponent<TComponent>(object)
    Extensions_UnityObject.SmartGetGameGameObject(object)
    In this article
    Back to top Generated by DocFX