예제 #1
0
        private bool InternalTryGetTable(object inContext, StringHash32 inTableId, out VariantTable outTable, bool inbCheckBase)
        {
            if (inTableId.IsEmpty)
            {
                if (m_DefaultTable != null && m_DefaultTable.IsActive())
                {
                    outTable = m_DefaultTable.Resolve(inContext);
                    return(true);
                }
            }
            else
            {
                if (m_TableLookup != null)
                {
                    TableRule tableRule;
                    if (m_TableLookup.TryGetValue(inTableId, out tableRule))
                    {
                        outTable = tableRule.Resolve(inContext);
                        return(true);
                    }
                }

                if (m_GetTableWithContextFallback != null)
                {
                    outTable = m_GetTableWithContextFallback(inTableId, inContext);
                    if (outTable != null)
                    {
                        return(true);
                    }
                }

                if (m_GetTableFallback != null)
                {
                    outTable = m_GetTableFallback(inTableId);
                    if (outTable != null)
                    {
                        return(true);
                    }
                }
            }

            if (inbCheckBase)
            {
                if (m_Base != null)
                {
                    return(m_Base.TryGetTable(inContext, inTableId, out outTable));
                }
            }

            outTable = null;
            return(false);
        }
예제 #2
0
        /// <summary>
        /// Attempts to apply a modification.
        /// </summary>
        static public bool TryModify(this IVariantResolver inResolver, object inContext, TableKeyPair inKey, VariantModifyOperator inOperator, Variant inVariant)
        {
            inResolver.RemapKey(ref inKey);

            VariantTable table;
            bool         bRetrieved = inResolver.TryGetTable(inContext, inKey.TableId, out table);

            if (!bRetrieved || table == null)
            {
                UnityEngine.Debug.LogErrorFormat("[IVariantResolver] Unable to retrieve table with id '{0}'", inKey.TableId.ToDebugString());
                return(false);
            }

            table.Modify(inKey.VariableId, inOperator, inVariant);
            return(true);
        }
예제 #3
0
        /// <summary>
        /// Attempts to resolve a variable.
        /// </summary>
        static public bool TryResolve(this IVariantResolver inResolver, object inContext, TableKeyPair inKey, out Variant outVariant)
        {
            inResolver.RemapKey(ref inKey);

            bool bRetrieved = inResolver.TryGetVariant(inContext, inKey, out outVariant);

            if (bRetrieved)
            {
                return(true);
            }

            VariantTable table;
            bool         bFoundTable = inResolver.TryGetTable(inContext, inKey.TableId, out table);

            if (!bFoundTable || table == null)
            {
                UnityEngine.Debug.LogErrorFormat("[IVariantResolver] Unable to retrieve table with id '{0}'", inKey.TableId.ToDebugString());
                outVariant = Variant.Null;
                return(false);
            }

            return(table.TryLookup(inKey.VariableId, out outVariant));
        }