Hex Terrains Framework
Search Results for

    Show / Hide Table of Contents

    Class ChunkedDataLayer

    Base class for all chunked data layers (DataLayer). Chunked data layer is a container for data that tracks changes per chunk. When intializing the data layer, it creates a grid of chunks. Each cell in this grid is a dirty flag for the chunk. When a cell is modified, the corresponding chunk is marked as dirty and also the whole layer is marked as dirty. The layer contains a dirty flags per chunk in ChunkDirtyGrid NativeList. The layer contains indexes of dirty chunks in DirtyChunks NativeParallelHashSet. To divide a layer into chunks, the layer must be initialized with a size of the layer (width and height) and a size of the chunks.

    Inheritance
    object
    DataLayer
    ChunkedDataLayer
    ArrayChunkedDataLayer<TItem>
    ListChunkedDataLayer<TItem>
    NativeArrayChunkedDataLayer<TItem>
    NativeListChunkedDataLayer<TItem>
    Implements
    IDisposable
    ICommitChanges
    Inherited Members
    DataLayer.IsDisposableItems
    DataLayer._readJobsDependency
    DataLayer.ReadDependency
    DataLayer._writeJobsDependency
    DataLayer.WriteDependency
    DataLayer.CombinedDependency
    DataLayer._isDirty
    DataLayer.IsDirty
    DataLayer._version
    DataLayer.Version
    DataLayer.Length
    DataLayer.AddReadDependency(JobHandle)
    DataLayer.AddWriteDependency(JobHandle)
    DataLayer.SetReadDependency(JobHandle)
    DataLayer.SetWriteDependency(JobHandle)
    DataLayer.PrepareToWrite()
    DataLayer.PrepareToRead()
    DataLayer.OpenToRead()
    DataLayer.OpenToWrite()
    DataLayer.CompleteReadJobs()
    DataLayer.CompleteWriteJobs()
    DataLayer.CompleteAllJobs()
    DataLayer.CommitChanges()
    DataLayer.SetDirty(bool)
    DataLayer.DisposeAllItems()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Fwt.Core.DataLayers
    Assembly: fwt.core.dll
    Syntax
    public abstract class ChunkedDataLayer : DataLayer, IDisposable, ICommitChanges

    Properties

    CellsGridSize

    Width and Height of the grid of cells.

    Declaration
    public abstract int2 CellsGridSize { get; }
    Property Value
    Type Description
    int2

    ChunkDirtyGrid

    The grid of dirty flags for the chunks. Index in this list = chunk index.

    Declaration
    public NativeList<bool> ChunkDirtyGrid { get; }
    Property Value
    Type Description
    NativeList<bool>

    ChunkGridSize

    Width and Height of the grid of chunks.

    Declaration
    public abstract int2 ChunkGridSize { get; }
    Property Value
    Type Description
    int2

    ChunkSize

    Width and Height of the chunk in cells.

    Declaration
    public abstract int2 ChunkSize { get; }
    Property Value
    Type Description
    int2

    ChunksCount

    Returns the number of chunks in the layer.

    Declaration
    public virtual int ChunksCount { get; }
    Property Value
    Type Description
    int

    DirtyChunks

    The hash set of dirty chunks. Value = chunk index.

    Declaration
    public NativeParallelHashSet<int> DirtyChunks { get; }
    Property Value
    Type Description
    NativeParallelHashSet<int>

    IsConnectedHorizontally

    True if left and right edges of the chunk are connected (like in civilization games). Needed for wrapping the grid. If SetCellDirty(cellIndex, checkEdges) is called with checkEdges == true, the chunk of the cell is marked dirty and also all adjacent chunks are also marked dirty. So if the left edge is dirty, the right edge is also dirty.

    Declaration
    public abstract bool IsConnectedHorizontally { get; }
    Property Value
    Type Description
    bool

    IsConnectedVertically

    True if top and bottom edges of the chunk are connected (like in civilization games). Needed for wrapping the grid. If SetCellDirty(cellIndex, checkEdges) is called with checkEdges == true, the chunk of the cell is marked dirty and also all adjacent chunks are also marked dirty. So if the top edge is dirty, the bottom edge is also dirty.

    Declaration
    public abstract bool IsConnectedVertically { get; }
    Property Value
    Type Description
    bool

    Methods

    ClearAllChunksDirty()

    Clears dirty flag for all chunks in the layer immediately.

    Declaration
    public virtual void ClearAllChunksDirty()

    Dispose()

    Disposes the layer and calls DisposeAllItems() under the hood

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

    GetCellCoord(int)

    Returns the cell coordinate (in a cells grid) for the provided cell index.

    Declaration
    protected virtual int2 GetCellCoord(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex

    Cell index to calculate a cell coordinate for

    Returns
    Type Description
    int2

    Coordinate of the cell with provided cell index (in a cells grid)

    GetCellIndex(int2)

    Returns the cell index for the provided cell coordinate.

    Declaration
    protected virtual int GetCellIndex(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    Coordinate of the cell to calculate a cell index for

    Returns
    Type Description
    int

    Cell index (in a cells grid) of the cell at provided coordinate

    GetChunkCoord(int)

    Returns the chunk coordinate (in a chunks grid) for the provided chunk index.

    Declaration
    protected virtual int2 GetChunkCoord(int chunkIndex)
    Parameters
    Type Name Description
    int chunkIndex

    Chunk index to calculate a chunk coordinate for

    Returns
    Type Description
    int2

    GetChunkCoord(int2)

    Returns the chunk coordinate (in a chunks grid) for the provided cell coordinate.

    Declaration
    protected virtual int2 GetChunkCoord(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    Cell coordinate to calculate a chunk coordinate for

    Returns
    Type Description
    int2

    Chunk coordinate of the cell with provided coordinate

    GetChunkIndex(int2)

    Returns the chunk index for the provided chunk coordinate.

    Declaration
    protected virtual int GetChunkIndex(int2 chunkCoord)
    Parameters
    Type Name Description
    int2 chunkCoord

    Chunk coordinate (in a chunks grid) to calculate a chunk index for

    Returns
    Type Description
    int

    Chunk index of the chunk at provided chunk coordinate (in a chunks grid)

    GetChunkIndexByCellIndex(int)

    Returns the chunk index for the cell index.

    Declaration
    protected virtual int GetChunkIndexByCellIndex(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex

    cell index to calculate a chunk index for

    Returns
    Type Description
    int

    chunk index of the cell with provided cell index

    GetIsChunkDirty(int)

    Returns true if the chunk with provided index is dirty.

    Declaration
    public virtual bool GetIsChunkDirty(int chunkIndex)
    Parameters
    Type Name Description
    int chunkIndex
    Returns
    Type Description
    bool

    Init(int)

    Initializes/Reinitializes the layer with a size of the layer (cells count) and a size of the chunks.

    Declaration
    public virtual void Init(int layerSize)
    Parameters
    Type Name Description
    int layerSize

    Amount of items (cells) in the data layer

    MergeChunkDirtyGrids(ChunkedDataLayer, ChunkedDataLayer, ChunkedDataLayer, ChunkedDataLayer, JobHandle)

    Merges dirty chunks data with respective dirty chunks data from other layers. other layers must be the same size as this layer.

    Declaration
    public virtual JobHandle MergeChunkDirtyGrids(ChunkedDataLayer other1, ChunkedDataLayer other2, ChunkedDataLayer other3, ChunkedDataLayer other4, JobHandle inputDeps)
    Parameters
    Type Name Description
    ChunkedDataLayer other1
    ChunkedDataLayer other2
    ChunkedDataLayer other3
    ChunkedDataLayer other4
    JobHandle inputDeps
    Returns
    Type Description
    JobHandle

    MergeChunkDirtyGrids(ChunkedDataLayer, ChunkedDataLayer, ChunkedDataLayer, JobHandle)

    Merges dirty chunks data with respective dirty chunks data from other layers. other layers must be the same size as this layer.

    Declaration
    public virtual JobHandle MergeChunkDirtyGrids(ChunkedDataLayer other1, ChunkedDataLayer other2, ChunkedDataLayer other3, JobHandle inputDeps)
    Parameters
    Type Name Description
    ChunkedDataLayer other1
    ChunkedDataLayer other2
    ChunkedDataLayer other3
    JobHandle inputDeps
    Returns
    Type Description
    JobHandle

    MergeChunkDirtyGrids(ChunkedDataLayer, ChunkedDataLayer, JobHandle)

    Merges dirty chunks data with respective dirty chunks data from other layers. other layers must be the same size as this layer.

    Declaration
    public virtual JobHandle MergeChunkDirtyGrids(ChunkedDataLayer other1, ChunkedDataLayer other2, JobHandle inputDeps)
    Parameters
    Type Name Description
    ChunkedDataLayer other1
    ChunkedDataLayer other2
    JobHandle inputDeps
    Returns
    Type Description
    JobHandle

    MergeChunkDirtyGrids(ChunkedDataLayer, JobHandle)

    Merges dirty chunks data with respective dirty chunks data from other layers. other layer must be the same size as this layer.

    Declaration
    public virtual JobHandle MergeChunkDirtyGrids(ChunkedDataLayer other1, JobHandle inputDeps)
    Parameters
    Type Name Description
    ChunkedDataLayer other1
    JobHandle inputDeps
    Returns
    Type Description
    JobHandle

    ResolveCellCoord(int2)

    Resolves the cell coordinate (in a cells grid) for the provided cell coordinate taking in account if the grid is connected horizontally and/or vertically. If the edges of the grid are not connected, returns the cell coordinate as is.

    Declaration
    protected virtual int2 ResolveCellCoord(int2 cellCoord)
    Parameters
    Type Name Description
    int2 cellCoord

    Raw cell coordinate (for grids with connected edges may be off bounds)

    Returns
    Type Description
    int2

    cell coordinate inside the cells grid bounds or raw cell coordinate if grid edges are not connected.

    ResolveChunkCoord(int2)

    Resolves the chunk coordinate (in a chunks grid) for the provided chunk coordinate taking in account if the grid is connected horizontally and/or vertically. If the edges of the grid are not connected, returns the chunk coordinate as is.

    Declaration
    protected virtual int2 ResolveChunkCoord(int2 chunkCoord)
    Parameters
    Type Name Description
    int2 chunkCoord

    Raw chunk coordinate (for grids with connected edges may be off bounds)

    Returns
    Type Description
    int2

    chunk coordinate inside the chunks grid bounds or raw chunk coordinate if grid edges are not connected

    SetAllChunksDirty()

    Sets dirty flag for all chunks in the layer immediately.

    Declaration
    public virtual void SetAllChunksDirty()

    SetAllChunksDirty(bool)

    Sets dirty flag for all chunks in the layer. If isDirty is true, all chunks are marked dirty and added to the DirtyChunks hash set. If isDirty is false, marks all chunks not dirty and clears the DirtyChunks hash set.

    Declaration
    public virtual void SetAllChunksDirty(bool isDirty)
    Parameters
    Type Name Description
    bool isDirty

    IsDirty value to set for all chunks

    SetAllChunksDirtyAsync(bool, JobHandle)

    Sets dirty flag for all chunks in the layer in a corresponding job. Returns a job handle that can be used to wait for the job to complete.

    Declaration
    public virtual JobHandle SetAllChunksDirtyAsync(bool isDirty, JobHandle jobHandle)
    Parameters
    Type Name Description
    bool isDirty

    dirty value to set for all chunks

    JobHandle jobHandle

    job handle to put as dependency to FillDirtyChunksJob

    Returns
    Type Description
    JobHandle

    SetCellDirty(int)

    Sets the cell dirty and marks the chunk as dirty. Does not mark adjucent chunks as dirty, only marks the affected chunk dirty.

    Declaration
    public virtual bool SetCellDirty(int cellIndex)
    Parameters
    Type Name Description
    int cellIndex
    Returns
    Type Description
    bool

    SetCellDirty(int, bool)

    Sets the cell dirty and marks the chunk as dirty. Allows to mark adjucent chunks dirty. If the cell is on the edge of the chunk, the chunks adjacent to the cell are also marked dirty. If IsConnectedHorizontally or IsConnectedVertically is true, the respective chunks on the opposite side of the grid are also marked dirty.

    Declaration
    public virtual bool SetCellDirty(int cellIndex, bool checkEdges)
    Parameters
    Type Name Description
    int cellIndex
    bool checkEdges
    Returns
    Type Description
    bool

    SetChunkDirty(int, bool)

    Sets the chunk dirty flag. Returns the result of operation, true if the value was set, false otherwise

    Declaration
    public virtual bool SetChunkDirty(int chunkIndex, bool isDirty)
    Parameters
    Type Name Description
    int chunkIndex

    Index of the chunk to set a dirty flag for

    bool isDirty

    If true, marks a chunk dirty, adds the chunk index to the DirtyChunks hash set. If false - clears the dirty flag and removes the chunk id from the DirtyChunks set

    Returns
    Type Description
    bool

    True if value was set.

    Implements

    IDisposable
    ICommitChanges

    Extension Methods

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