public bool TryGetVariant(object inContext, TableKeyPair inKey, out Variant outVariant) { if (m_HasSpecialVariantLookups) { if (m_FullPathVarLookup != null) { FullPathVarRule rule; if (m_FullPathVarLookup.TryGetValue(inKey, out rule)) { outVariant = rule.Resolve(inContext); return(true); } } if (m_TableVarLookup != null) { TableVarRule rule; if (m_TableVarLookup.TryGetValue(inKey.TableId, out rule)) { outVariant = rule.Resolve(inKey.VariableId, inContext); return(true); } } if (m_GetVarWithContextFallback != null) { outVariant = m_GetVarWithContextFallback(inKey, inContext); return(true); } if (m_GetVarFallback != null) { outVariant = m_GetVarFallback(inKey); return(true); } } VariantTable table; if (InternalTryGetTable(inContext, inKey.TableId, out table, false)) { return(table.TryLookup(inKey.VariableId, out outVariant)); } if (m_Base != null) { return(m_Base.TryGetVariant(inContext, inKey, out outVariant)); } outVariant = Variant.Null; return(false); }
/// <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)); }