/// <summary> /// Attempts to retrieve a (local) path of the currently assigned avatar texture for a character with the provided ID. /// Will return null when character is not found or doesn't have an avatar texture assigned. /// </summary> public string GetAvatarTexturePathFor(string characterId) { if (!charIdToAvatarPathMap.TryGetValue(characterId ?? string.Empty, out var avatarTexturePath)) { return(null); } if (!AvatarTextureExists(avatarTexturePath)) { return(null); } return(avatarTexturePath); }
public virtual string GetAvatarTexturePathFor(string characterId) { if (!charIdToAvatarPathMap.TryGetValue(characterId ?? string.Empty, out var avatarTexturePath)) { var defaultPath = $"{characterId}/Default"; // Attempt default path. return(AvatarTextureExists(defaultPath) ? defaultPath : null); } if (!AvatarTextureExists(avatarTexturePath)) { return(null); } return(avatarTexturePath); }
public virtual void SetVariableValue(string name, string value) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Variable name cannot be null or empty.", nameof(name)); } var isGlobal = CustomVariablesConfiguration.IsGlobalVariable(name); var initialValue = default(string); if (isGlobal) { globalVariableMap.TryGetValue(name, out initialValue); globalVariableMap[name] = value; } else { localVariableMap.TryGetValue(name, out initialValue); localVariableMap[name] = value; } if (initialValue != value) { OnVariableUpdated?.Invoke(new CustomVariableUpdatedArgs(name, value, initialValue)); } }
/// <summary> /// Sets value of a variable with the provided name. Variable names are case-insensitive. /// When no variables of the provided name are found, will add a new one and assign the value. /// In case the name is starting with <see cref="GlobalPrefix"/>, the variable will be added to the global scope. /// </summary> public void SetVariableValue(string name, string value) { var isGlobal = IsGlobalVariable(name); var initialValue = default(string); if (isGlobal) { globalVariableMap.TryGetValue(name, out initialValue); globalVariableMap[name] = value; } else { localVariableMap.TryGetValue(name, out initialValue); localVariableMap[name] = value; } if (initialValue != value) { OnVariableUpdated?.Invoke(new CustomVariableUpdatedArgs(name, value, initialValue)); } }