< Summary

Class:GDX.DataTables.CellValues.LayerMaskCellValue
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/DataTables/CellValues/LayerMaskCellValue.cs
Covered lines:0
Uncovered lines:32
Coverable lines:32
Total lines:126
Line coverage:0% (0 of 32)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:6
Method coverage:0% (0 of 6)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
LayerMaskCellValue(...)0%2100%
Get()0%6200%
GetDataVersion()0%2100%
GetUnsafe()0%2100%
Set(...)0%6200%
GetSupportedType()0%2100%

File(s)

./Packages/com.dotbunny.gdx/GDX/DataTables/CellValues/LayerMaskCellValue.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System;
 6using UnityEngine;
 7
 8namespace GDX.DataTables.CellValues
 9{
 10    /// <summary>
 11    ///     A <see cref="DataTableBase" /> <see cref="LayerMask" /> cell reference.
 12    /// </summary>
 13    [Serializable]
 14    public struct LayerMaskCellValue
 15    {
 16        /// <summary>
 17        ///     The cached struct of the referenced <see cref="DataTable" /> cell.
 18        /// </summary>
 19        LayerMask m_CachedValue;
 20
 21        /// <summary>
 22        ///     The cached <see cref="DataTable" /> version found when last updating <see cref="m_CachedValue" />.
 23        /// </summary>
 24        ulong m_TableVersion;
 25#pragma warning disable IDE1006
 26        // ReSharper disable InconsistentNaming
 27        /// <summary>
 28        ///     The <see cref="DataTableBase" /> polled for cell data.
 29        /// </summary>
 30        public DataTableBase DataTable;
 31
 32        /// <summary>
 33        ///     The unique column identifier used when accessing the <see cref="DataTable" />.
 34        /// </summary>
 35        public int ColumnIdentifier;
 36
 37        /// <summary>
 38        ///     The unique row identifier used when accessing the <see cref="DataTable" />.
 39        /// </summary>
 40        public int RowIdentifier;
 41        // ReSharper enable InconsistentNaming
 42#pragma warning restore IDE1006
 43
 44        /// <summary>
 45        ///     Creates a <see cref="LayerMaskCellValue" />.
 46        /// </summary>
 47        /// <param name="dataTable">The referenced <see cref="DataTableBase" />.</param>
 48        /// <param name="rowIdentifier">The unique row identifier to use when polling the <paramref name="dataTable" />.
 49        /// <param name="columnIdentifier">The unique column identifier to use when polling the <paramref name="dataTabl
 50        public LayerMaskCellValue(DataTableBase dataTable, int rowIdentifier, int columnIdentifier)
 051        {
 052            DataTable = dataTable;
 053            RowIdentifier = rowIdentifier;
 054            ColumnIdentifier = columnIdentifier;
 055            m_TableVersion = 0;
 056            m_CachedValue = default;
 057            Get();
 058        }
 59
 60        /// <summary>
 61        ///     Get the <see cref="LayerMask" /> value referenced from the <see cref="DataTableBase" />.
 62        /// </summary>
 63        /// <remarks>
 64        ///     This will evaluate if the version of the table matches the internally cached version, and will update
 65        ///     the cached reference if necessary.
 66        /// </remarks>
 67        /// <returns>A <see cref="LayerMask" /> struct.</returns>
 68        public LayerMask Get()
 069        {
 070            if (m_TableVersion == DataTable.GetDataVersion())
 071            {
 072                return m_CachedValue;
 73            }
 74
 075            m_CachedValue = DataTable.GetLayerMask(RowIdentifier, ColumnIdentifier);
 076            m_TableVersion = DataTable.GetDataVersion();
 077            return m_CachedValue;
 078        }
 79
 80        /// <summary>
 81        ///     Get the internally cached version of the <see cref="DataTableBase" />'s data version.
 82        /// </summary>
 83        /// <returns>A version number.</returns>
 84        public ulong GetDataVersion()
 085        {
 086            return m_TableVersion;
 087        }
 88
 89        /// <summary>
 90        ///     Get the cached value without a version check.
 91        /// </summary>
 92        /// <remarks>
 93        ///     This can respond with a default value if a <see cref="Get" /> call has not been made yet to populate the
 94        ///     internally cached value.
 95        /// </remarks>
 96        /// <returns>A <see cref="LayerMask" /> struct.</returns>
 97        public LayerMask GetUnsafe()
 098        {
 099            return m_CachedValue;
 0100        }
 101
 102        /// <summary>
 103        ///     Sets the cached value of the struct and by default, updates the associated <see cref="DataTableBase" />.
 104        /// </summary>
 105        /// <remarks>Updating the <see cref="DataTableBase" /> will update the cached table version.</remarks>
 106        /// <param name="newValue">A <see cref="LayerMask" /> struct.</param>
 107        /// <param name="updateTable">Should the value be pushed back to the referenced <see cref="DataTableBase" /> cel
 108        public void Set(LayerMask newValue, bool updateTable = true)
 0109        {
 0110            m_CachedValue = newValue;
 0111            if (updateTable)
 0112            {
 0113                m_TableVersion = DataTable.SetLayerMask(RowIdentifier, ColumnIdentifier, newValue);
 0114            }
 0115        }
 116
 117        /// <summary>
 118        ///     Get the <see cref="Serializable.SerializableTypes" /> which this struct supports.
 119        /// </summary>
 120        /// <returns>A <see cref="Serializable.SerializableTypes" />.</returns>
 121        public static Serializable.SerializableTypes GetSupportedType()
 0122        {
 0123            return Serializable.SerializableTypes.LayerMask;
 0124        }
 125    }
 126}