Hex Terrains Framework
Search Results for

    Show / Hide Table of Contents

    Class CellEntityLayer

    Represents a terrain layer that manages cell entities, providing functionality for initializing, updating, and cleaning up entity data associated with each cell. Supports asynchronous operations and integrates with Unity's Entity Component System (ECS) for efficient entity lifecycle management.

    Inheritance
    object
    HexTerrainLayer
    CellItemLayer
    CellEntityLayer
    Implements
    IDisposable
    ISerializableTerrainLayer
    Inherited Members
    CellItemLayer.ItemIndexMap
    CellItemLayer.ItemStateMap
    CellItemLayer.ItemPositionMap
    CellItemLayer.ItemRotationMap
    CellItemLayer.ItemScaleMap
    CellItemLayer.ItemTransformMap
    CellItemLayer.SurfaceLayerReference
    CellItemLayer.OverlapSurfaceLayerReference
    CellItemLayer.ItemTransformSettings
    CellItemLayer.Init<TInitArgs>(HexTerrainSettings, TInitArgs)
    CellItemLayer.UpdateCellItems(JobHandle)
    CellItemLayer.CalculateColorMap(JobHandle)
    CellItemLayer.UpdateLocalTransforms(JobHandle)
    CellItemLayer.GetCellItemIndex(int)
    CellItemLayer.GetCellItemState(int)
    CellItemLayer.GetCellItemLocalPosition(int)
    CellItemLayer.GetCellItemLocalRotation(int)
    CellItemLayer.GetCellItemLocalScale(int)
    CellItemLayer.GetCellItemLocalTransform(int)
    CellItemLayer.SetCellItemIndex(int, int)
    CellItemLayer.SetCellItemState(int, int)
    CellItemLayer.SetCellItemLocalPosition(int, float3)
    CellItemLayer.SetCellItemLocalRotation(int, quaternion)
    CellItemLayer.SetCellItemLocalScale(int, float3)
    CellItemLayer.SetCellItemLocalTransform(int, Matrix4x4)
    CellItemLayer.SetAllCellsItemIndex(int)
    CellItemLayer.SetAllCellsItemState(int)
    CellItemLayer.SetAllCellsLocalPosition(float3)
    CellItemLayer.SetAllCellsLocalRotation(quaternion)
    CellItemLayer.SetAllCellsLocalScale(float3)
    CellItemLayer.SetAllCellsLocalTransform(Matrix4x4)
    CellItemLayer.SerializeLayer(BinaryWriter)
    CellItemLayer.DeserializeLayer(BinaryReader, HexTerrainSettings)
    CellItemLayer.CompleteAllJobs()
    HexTerrainLayer.Name
    HexTerrainLayer.Settings
    HexTerrainLayer.ParentLayer
    HexTerrainLayer.Resize(int2)
    HexTerrainLayer.InitColoredDataLayer<TValue>(ColorMapCellValueDataLayer<TValue>, IInitColorMapCellValueDataLayerArgs<TValue>)
    HexTerrainLayer.InitDataLayer<TValue>(CellValueDataLayer<TValue>, IInitCellValueDataLayerArgs<TValue>)
    HexTerrainLayer.GetTerrainLayerFromParent<TLayer>(int)
    HexTerrainLayer.GetTerrainLayerFromParent<TLayer>(string)
    HexTerrainLayer.GetTerrainLayerFromParent<TLayer>(int, string)
    HexTerrainLayer.GetTerrainLayerFromParent<TLayer>(HexTerrainLayerReference)
    HexTerrainLayer.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Fwt.HexTerrains.CellEntities.Data
    Assembly: fwt.hexterrains.dll
    Syntax
    public class CellEntityLayer : CellItemLayer, IDisposable, ISerializableTerrainLayer
    Remarks

    CellEntityLayer is responsible for the creation, destruction, and state management of cell entities within a terrain layer. It utilizes an EntityManager to handle entity instances and supports job-based operations for performance optimization. This layer is typically used in scenarios where each terrain cell requires an associated entity, such as for gameplay logic, rendering, or interaction. Thread safety and job dependencies are managed internally to ensure correct operation when used in multithreaded environments.

    Fields

    CellEntityConfigs

    List of configs for every possible CellEntity index

    Declaration
    public NativeList<CellEntityStateConfig> CellEntityConfigs
    Field Value
    Type Description
    NativeList<CellEntityStateConfig>

    CellEntityViews

    Data layer for storing a CellEntityView (Entity instances) per cell

    Declaration
    public CellEntityViewDataLayer CellEntityViews
    Field Value
    Type Description
    CellEntityViewDataLayer

    EntityManager

    Cached EntityManager used to destroy CellEntity instances when the terrain is destroyed or resized

    Declaration
    public EntityManager EntityManager
    Field Value
    Type Description
    EntityManager

    SetChunkIndexCommandBuffer

    CommandBuffer that holds commands for updating the CellEntity instances (entities)

    Declaration
    public EntityCommandBuffer? SetChunkIndexCommandBuffer
    Field Value
    Type Description
    EntityCommandBuffer?

    SetChunkIndexCommandBufferDependency

    Job handle for the job that updates chunk index of every CellEntity instance

    Declaration
    public JobHandle SetChunkIndexCommandBufferDependency
    Field Value
    Type Description
    JobHandle

    Properties

    ColorMapTextureIndex

    Index of the texture in the list of ColorMapTextures. Used externally in systems. Systems read this value to know which texture to fill with colors from EntitiesColorMap data layer EntitiesColorMap. That texture is expected to be used in materials or/and UI like minimap.

    Declaration
    public int ColorMapTextureIndex { get; set; }
    Property Value
    Type Description
    int

    StatesCountPerEntityIndex

    Declaration
    public int StatesCountPerEntityIndex { get; set; }
    Property Value
    Type Description
    int

    Methods

    CalculateEntities(JobHandle)

    Calculates which cell should contain an Entity and from which prefab should that Entity be instantiated. Caches changes in the CellEntityViews data layer.

    Declaration
    public virtual JobHandle CalculateEntities(JobHandle dependency)
    Parameters
    Type Name Description
    JobHandle dependency
    Returns
    Type Description
    JobHandle

    Cleanup()

    Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.

    Declaration
    public override void Cleanup()
    Overrides
    CellItemLayer.Cleanup()

    CleanupAsync(JobHandle)

    Async version of Cleanup() Cleanup() Difference between regular Cleanup() is that it schedules jobs that clean up data layers, so you don't have to wait for the results and can continue working. Every frame there is a cleanup stage. This function is called. Usually used to clean the dirty flags.

    Declaration
    public override JobHandle CleanupAsync(JobHandle dependency)
    Parameters
    Type Name Description
    JobHandle dependency
    Returns
    Type Description
    JobHandle
    Overrides
    CellItemLayer.CleanupAsync(JobHandle)

    Dispose()

    Disposes all allocated native memory.

    Declaration
    public override void Dispose()
    Overrides
    CellItemLayer.Dispose()

    Init(HexTerrainSettings)

    Initializes/Reinitializes the CellEntities data.

    Declaration
    public override void Init(HexTerrainSettings settings)
    Parameters
    Type Name Description
    HexTerrainSettings settings

    new terrain settings

    Overrides
    CellItemLayer.Init(HexTerrainSettings)

    Init(HexTerrainSettings, ICellEntityLayerConfig, NativeSlice<CellEntityStateConfig>)

    Declaration
    public virtual void Init(HexTerrainSettings settings, ICellEntityLayerConfig args, NativeSlice<CellEntityStateConfig> cellEntityConfigs)
    Parameters
    Type Name Description
    HexTerrainSettings settings
    ICellEntityLayerConfig args
    NativeSlice<CellEntityStateConfig> cellEntityConfigs

    InitCellEntitiesConfigs(NativeSlice<CellEntityStateConfig>)

    Copies an ItemConfigs from the given array. Does not change or cache the array, so it is safe to dispose it after this call. copyFrom array is expected to have the CellEntity indexes length, so there is one config per possible CellEntity index. CellEntity.Index == index in copyFrom array.

    Declaration
    public void InitCellEntitiesConfigs(NativeSlice<CellEntityStateConfig> copyFrom)
    Parameters
    Type Name Description
    NativeSlice<CellEntityStateConfig> copyFrom

    array of configs to copy into the ItemConfigs

    PlaybackSetChunkIndexCommandBuffer()

    Declaration
    public virtual void PlaybackSetChunkIndexCommandBuffer()

    SetAllDirty(bool)

    Sets the dirty flag for all the data layers. If isDirty is true, all data layers will be marked as dirty and will be recalculated. If isDirty is false, all data layers will be marked as clean and will not be recalculated.

    Declaration
    public override void SetAllDirty(bool isDirty)
    Parameters
    Type Name Description
    bool isDirty
    Overrides
    CellItemLayer.SetAllDirty(bool)

    UpdateEntities(Entity, int, JobHandle)

    Declaration
    public virtual JobHandle UpdateEntities(Entity layerEntity, int layerIndex, JobHandle dependency)
    Parameters
    Type Name Description
    Entity layerEntity
    int layerIndex
    JobHandle dependency
    Returns
    Type Description
    JobHandle

    Implements

    IDisposable
    ISerializableTerrainLayer

    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