/// <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); }
public void RemapKey(ref TableKeyPair ioKey) { if (m_HasRemaps) { if (m_FullKeyRemap != null) { TableKeyPair fullRemap; if (m_FullKeyRemap.TryGetValue(ioKey, out fullRemap)) { ioKey = fullRemap; return; } } if (m_TableIdRemap != null) { StringHash32 tableRemap; if (m_TableIdRemap.TryGetValue(ioKey.TableId, out tableRemap)) { ioKey.TableId = tableRemap; } } if (m_VariableIdRemap != null) { StringHash32 varRemap; if (m_VariableIdRemap.TryGetValue(ioKey.TableId, out varRemap)) { ioKey.VariableId = varRemap; } } } if (m_Base != null) { m_Base.RemapKey(ref ioKey); } }
/// <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)); }