Hex Terrains Framework
Search Results for

    Show / Hide Table of Contents

    Class EnvironmentAPI

    Provides an API for managing environment entities, terrain operations, and UI integration within the application. Exposes methods for creating, modifying, and querying terrain entities, as well as interacting with UI screens related to the environment.

    Inheritance
    object
    EnvironmentAPI
    Implements
    IEnvironmentAPI
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Fwt.HexTerrains
    Assembly: fwt.hexterrains.dll
    Syntax
    public class EnvironmentAPI : IEnvironmentAPI
    Remarks

    The EnvironmentAPI serves as a central point for environment-related functionality, including terrain creation, editing, serialization, and visibility management. It also facilitates communication with the UI system for displaying and managing environment-related screens. Thread safety is not guaranteed; callers should ensure appropriate synchronization if accessing from multiple threads.

    Fields

    _heightmapPalette

    Cached list of Heightmap textures retrieved from the EnvironmentAPIEntity.

    Declaration
    protected IList<Texture2D> _heightmapPalette
    Field Value
    Type Description
    IList<Texture2D>

    _terrainPrefabConfigs

    Cached list of terrain prefab configs attached to EnvironmentAPIEntity.

    Declaration
    protected IList<IHexTerrainPrefabConfig> _terrainPrefabConfigs
    Field Value
    Type Description
    IList<IHexTerrainPrefabConfig>

    Properties

    EntityManager

    Gets or sets the entity manager used to coordinate entity operations.

    Declaration
    public EntityManager EntityManager { get; set; }
    Property Value
    Type Description
    EntityManager

    EnvironmentAPIEntity

    Cached entity that holds the Environment API in it's component.

    Declaration
    public Entity EnvironmentAPIEntity { get; set; }
    Property Value
    Type Description
    Entity

    UISystemAPI

    Gets the interface for interacting with the UI system API.

    Declaration
    public IUISystemAPI UISystemAPI { get; set; }
    Property Value
    Type Description
    IUISystemAPI

    Methods

    CreateNewTerrain<TPrefabConfig>(TPrefabConfig, HexTerrainSettings)

    Creates a new terrain entity with the specified settings. Destroys existing terrain

    Declaration
    public virtual Entity CreateNewTerrain<TPrefabConfig>(TPrefabConfig terrainPrefabConfig, HexTerrainSettings terrainSettings) where TPrefabConfig : IHexTerrainPrefabConfig
    Parameters
    Type Name Description
    TPrefabConfig terrainPrefabConfig

    prefab config of the terrainEntity to create

    HexTerrainSettings terrainSettings

    terrain settings to overwrite

    Returns
    Type Description
    Entity

    instance of the created terrainEntity

    Type Parameters
    Name Description
    TPrefabConfig

    CreateNewterrainEntity(Entity)

    Creates a new terrain terrainEntity by instantiating provided prefab.

    Declaration
    public virtual Entity CreateNewterrainEntity(Entity terrainPrefab)
    Parameters
    Type Name Description
    Entity terrainPrefab

    prefab of the terrainEntity to create

    Returns
    Type Description
    Entity

    instance of the created terrainEntity

    CreateUIScreen<TScreen>()

    Creates a new screen of the specified type.

    Declaration
    public virtual TScreen CreateUIScreen<TScreen>() where TScreen : UIScreen
    Returns
    Type Description
    TScreen

    screen instance

    Type Parameters
    Name Description
    TScreen

    type of the screen to create

    DestroyTerrain(Entity)

    Destroys a terrain entity provided.

    Declaration
    public virtual bool DestroyTerrain(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity

    terrain entity to destroy

    Returns
    Type Description
    bool

    true if was destroyed, otherwise - false

    DestroyUIScreen(UIScreen)

    Destroys the specified screen instance.

    Declaration
    public virtual bool DestroyUIScreen(UIScreen screen)
    Parameters
    Type Name Description
    UIScreen screen

    screen instance to destroy

    Returns
    Type Description
    bool

    true if the screen was destroyed successfully; otherwise, false

    DestroyUIScreen<TScreen>()

    Destroys the specified screen.

    Declaration
    public virtual bool DestroyUIScreen<TScreen>() where TScreen : UIScreen
    Returns
    Type Description
    bool

    true if the screen was destroyed successfully; otherwise, false

    Type Parameters
    Name Description
    TScreen

    type of a screen to destroy

    GetBrushColor(Entity)

    Returns the brush color from the terrainEntity HexTerrainBrush.

    Declaration
    public virtual Color32? GetBrushColor(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    Color32?

    brush color if found, otherwise - false

    GetBrushOpacity(Entity)

    Returns the brush opacity from the terrainEntity HexTerrainBrush.

    Declaration
    public virtual float? GetBrushOpacity(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    float?

    brush opacity if brush is found, otherwise - null

    GetBrushSize(Entity)

    Returns the brush size from the terrainEntity HexTerrainBrush.

    Declaration
    public virtual int? GetBrushSize(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    int?

    brush size if found, otherwise - null

    GetBrushView(Entity)

    Returns the brush view from the terrainEntity HexTerrainBrushView.

    Declaration
    public virtual HexTerrainBrushView GetBrushView(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    HexTerrainBrushView

    brush view from the terrainEntity if found, otherwise - null

    GetCellCoordUnderCursor(Entity)

    Returns the cell coordinate under the cursor.

    Declaration
    public virtual int2? GetCellCoordUnderCursor(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    int2?

    cell coordinate if found and raycast hit the terrain, otherwise - false

    GetCellIndexUnderCursor(Entity)

    Returns the cell index under the cursor.

    Declaration
    public virtual int? GetCellIndexUnderCursor(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    int?

    cell index if found and raycast hit the terrain, otherwise - false

    GetHexTerrainPrefabConfigsBuffer<THexTerrainPrefabConfig>()

    Returns a list of available HexTerrainPrefabConfigs from the EnviromentAPI entity (if any)

    Declaration
    public virtual DynamicBuffer<THexTerrainPrefabConfig> GetHexTerrainPrefabConfigsBuffer<THexTerrainPrefabConfig>() where THexTerrainPrefabConfig : unmanaged, IBufferElementData, IHexTerrainPrefabConfig
    Returns
    Type Description
    DynamicBuffer<THexTerrainPrefabConfig>
    Type Parameters
    Name Description
    THexTerrainPrefabConfig

    type of HexTerrainPrefabConfig you have

    GetHexTerrainPrefabConfigsList()

    Returns a list of available HexTerrainPrefabConfigs from the EnviromentAPI entity (if any). This list can be sent to the UI to display available terrain prefabs for the user to select from.

    Declaration
    public virtual IList<IHexTerrainPrefabConfig> GetHexTerrainPrefabConfigsList()
    Returns
    Type Description
    IList<IHexTerrainPrefabConfig>

    collection of hex terrain prefab configs for user to select from

    GetIsResizableBrush(Entity)

    Returns true if the brush on terrainEntity is resizable.

    Declaration
    public virtual bool GetIsResizableBrush(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    bool

    is brush found and resizable

    GetIsTerrainVisible(Entity)

    Returns true if terrain is visible, false is invisible, null if no terrain with visibility foundHexTerrainVisibility.

    Declaration
    public bool? GetIsTerrainVisible(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    bool?

    true if terrain is visible, false is invisible, null if no terrain with visibility found

    GetIsVisibleBrush(Entity)

    Returns true if the brush on terrainEntity is visible.

    Declaration
    public virtual bool GetIsVisibleBrush(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    bool

    true if brush is found and is visible, otherwise - false

    GetMinimapScreen()

    Gets the Minimap UI Screen (if present).

    Declaration
    public virtual IMinimapScreen GetMinimapScreen()
    Returns
    Type Description
    IMinimapScreen

    An IMinimapScreen representing the minimap screen. Returns null if no minimap screen is available.

    GetOrCreateUIScreen<TScreen>()

    Gets an existing screen of the specified type, or creates a new one if it doesn't exist.

    Declaration
    public virtual TScreen GetOrCreateUIScreen<TScreen>() where TScreen : UIScreen
    Returns
    Type Description
    TScreen

    screen instance

    Type Parameters
    Name Description
    TScreen

    type of the screen to get or create

    GetRaycastData(Entity)

    Returns the Raycast data from the terrainEntity HexTerrainRaycastData. this data contains information about the raycast from mouse to terrain result.

    Declaration
    public virtual HexTerrainRaycastData? GetRaycastData(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    HexTerrainRaycastData?

    raycast data from the terrainEntity

    GetSimulationSpeedScreen()

    Retrieves the screen interface used to control or display the simulation speed settings.

    Declaration
    public virtual ISimulationSpeedScreen GetSimulationSpeedScreen()
    Returns
    Type Description
    ISimulationSpeedScreen

    An object that provides access to simulation speed controls and information. Returns an implementation of ISimulationSpeedScreen.

    GetTerrainLayer<TDataLayer>(Entity)

    returns a data layer from the TerrainEntity TerrainEntity

    Declaration
    public virtual TDataLayer GetTerrainLayer<TDataLayer>(Entity terrainEntity) where TDataLayer : class
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    TDataLayer
    Type Parameters
    Name Description
    TDataLayer

    GetTerrainSettings(Entity)

    Returns a Terrain Settings if found.

    Declaration
    public virtual HexTerrainSettings? GetTerrainSettings(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    HexTerrainSettings?

    terrain settings if found or null if not found

    GetUIScreen<TScreen>()

    Gets an existing screen of the specified type if found.

    Declaration
    public virtual TScreen GetUIScreen<TScreen>() where TScreen : UIScreen
    Returns
    Type Description
    TScreen
    Type Parameters
    Name Description
    TScreen

    type of the screen to get

    GetUserToolsScreen()

    Gets the User Tools UI Screen (if present).

    Declaration
    public virtual IUserToolsScreen GetUserToolsScreen()
    Returns
    Type Description
    IUserToolsScreen

    An IUserToolsScreen instance representing the user tools screen. Returns null if no user tools screen is available.

    GetViewMode(Entity)

    Returns the view mode of the terrainEntity HexTerrainViewMode.

    Declaration
    public virtual int GetViewMode(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    int

    view mode if found, otherwise - false

    Init(EntityManager, IUISystemAPI, Entity)

    Initializes with the specified environment entity, UI system API, and entity manager.

    Declaration
    public void Init(EntityManager entityManager, IUISystemAPI uiSystemApi, Entity environmentEntity)
    Parameters
    Type Name Description
    EntityManager entityManager

    The entity manager responsible for managing entities within the environment.

    IUISystemAPI uiSystemApi

    The UI system API used to interact with user interface components.

    Entity environmentEntity

    The entity that holds this API instance.

    IsTerrainLayerSupported<TDataLayer>(Entity)

    Checks if the data layer is supported by the terrain. Meaning if terrain has this data layer.

    Declaration
    public virtual bool IsTerrainLayerSupported<TDataLayer>(Entity terrainEntity) where TDataLayer : class
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    bool

    true if supports, otherwise - false

    Type Parameters
    Name Description
    TDataLayer

    type of the TerrainLayer to check

    LoadTerrain(Entity, string)

    Loads the terrainEntity from a file.

    Declaration
    public virtual bool LoadTerrain(Entity terrainEntity, string filePath)
    Parameters
    Type Name Description
    Entity terrainEntity
    string filePath

    file path to load a terrain from

    Returns
    Type Description
    bool

    true if loaded, otherwise - false

    ResizeTerrain(Entity, int2)

    Resizes the terrainEntity TerrainSize.

    Declaration
    public virtual bool ResizeTerrain(Entity terrainEntity, int2 terrainSize)
    Parameters
    Type Name Description
    Entity terrainEntity
    int2 terrainSize

    new terrain size

    Returns
    Type Description
    bool

    true if was resized, otherwise - false

    SaveTerrain(Entity, string)

    Saves the terrainEntity to a file.

    Declaration
    public virtual bool SaveTerrain(Entity terrainEntity, string filePath)
    Parameters
    Type Name Description
    Entity terrainEntity
    string filePath

    file path to save a terrain into

    Returns
    Type Description
    bool

    true if terrain has been saved, otherwise - false

    SetBrushColor(Entity, Color32)

    Sets the brush color on the terrainEntity HexTerrainBrush.

    Declaration
    public virtual bool SetBrushColor(Entity terrainEntity, Color32 color)
    Parameters
    Type Name Description
    Entity terrainEntity
    Color32 color

    new brush color

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetBrushOpacity(Entity, float)

    Sets the brush opacity on the terrainEntity HexTerrainBrush.

    Declaration
    public virtual bool SetBrushOpacity(Entity terrainEntity, float opacity)
    Parameters
    Type Name Description
    Entity terrainEntity
    float opacity

    new opacity value (0..1)

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetBrushSize(Entity, int)

    Sets the brush size on the terrainEntity HexTerrainBrush.

    Declaration
    public virtual bool SetBrushSize(Entity terrainEntity, int brushSize)
    Parameters
    Type Name Description
    Entity terrainEntity
    int brushSize

    new brush size

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetIsResizableBrush(Entity, bool)

    Sets the IsResizable value of the brush on terrainEntity HexTerrainBrush.

    Declaration
    public virtual bool SetIsResizableBrush(Entity terrainEntity, bool isResizableBrush)
    Parameters
    Type Name Description
    Entity terrainEntity
    bool isResizableBrush

    new value for IsResizable

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetIsTerrainVisible(Entity, bool)

    Sets terrain visibility. HexTerrainVisibility Returns true if value was set

    Declaration
    public bool SetIsTerrainVisible(Entity terrainEntity, bool isVisible)
    Parameters
    Type Name Description
    Entity terrainEntity
    bool isVisible

    New visibility value for terrain

    Returns
    Type Description
    bool

    True if value was set, otherwise - false

    SetIsVisibleBrush(Entity, bool)

    Sets the IsVisible value of the brush on terrainEntity HexTerrainBrush.

    Declaration
    public virtual bool SetIsVisibleBrush(Entity terrainEntity, bool isVisibleBrush)
    Parameters
    Type Name Description
    Entity terrainEntity
    bool isVisibleBrush

    new IsVisible value

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetViewMode(Entity, SetViewModeRequest)

    Sets the view mode based on the parameters specified in the request.

    Declaration
    public virtual bool SetViewMode(Entity terrainEntity, SetViewModeRequest request)
    Parameters
    Type Name Description
    Entity terrainEntity
    SetViewModeRequest request

    An object that specifies the view mode to set, either by index or by name. The request must indicate which method to use.

    Returns
    Type Description
    bool

    true if the view mode is successfully set; otherwise, false.

    Remarks

    If neither the view mode index nor the view mode name is specified in the request, the method returns false.

    SetViewMode(Entity, int)

    Sets the view mode on the terrainEntity HexTerrainViewMode.

    Declaration
    public virtual bool SetViewMode(Entity terrainEntity, int viewMode)
    Parameters
    Type Name Description
    Entity terrainEntity
    int viewMode

    new view mode

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    SetViewMode(Entity, string)

    Sets the view mode on the TerrainEntity HexTerrainViewMode by view mode name.

    Declaration
    public virtual bool SetViewMode(Entity terrainEntity, string viewModeName)
    Parameters
    Type Name Description
    Entity terrainEntity
    string viewModeName

    name of the new view mode

    Returns
    Type Description
    bool

    true if value has been set, otherwise - false

    ToggleIsTerrainVisible(Entity)

    Destroys the specified screen instance.

    Declaration
    public bool? ToggleIsTerrainVisible(Entity terrainEntity)
    Parameters
    Type Name Description
    Entity terrainEntity
    Returns
    Type Description
    bool?

    true if the screen was destroyed successfully; otherwise, false

    Implements

    IEnvironmentAPI

    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