public static void Log <T1, T2, T3, T4, T5, T6, T7>(ConfigVar configVar, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) { if (configVar != null && configVar.IntValue == 0) { return; } Log(string.Format(format.ToString(), arg1, arg2, arg3, arg4, arg5, arg6, arg7)); }
public static void Log <T1, T2, T3>(ConfigVar configVar, string format, T1 arg1, T2 arg2, T3 arg3) { if (configVar != null && configVar.IntValue == 0) { return; } Log(string.Format(format.ToString(), arg1, arg2, arg3)); }
public static void Log <T>(ConfigVar configVar, string format, T arg1) { if (configVar != null && configVar.IntValue == 0) { return; } Log(string.Format(format.ToString(), arg1)); }
public static void Log(ConfigVar configVar, string message) { if (configVar.IntValue == 0) { return; } Log(message.ToString()); }
public static void Log <T1, T2, T3, T4, T5>(WorldId worldId, ConfigVar configVar, string format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { if (configVar != null && configVar.IntValue == 0) { return; } var f = format.ToString(); InternalLog(worldId, configVar, string.Format(format.ToString(), arg1, arg2, arg3, arg4, arg5)); }
static void InjectAttributeConfigVars() { GameDebug.Log("count:" + AppDomain.CurrentDomain.GetAssemblies().Length); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { try { foreach (var _class in assembly.GetTypes()) { if (!_class.IsClass) { continue; } foreach (var field in _class.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)) { if (!field.IsDefined(typeof(ConfigVarAttribute), false)) { continue; } if (!field.IsStatic) { GameDebug.LogError("Cannot use ConfigVar attribute on non-static fields"); continue; } if (field.FieldType != typeof(ConfigVar)) { GameDebug.LogError("Cannot use ConfigVar attribute on fields not of type ConfigVar"); continue; } var attr = field.GetCustomAttributes(typeof(ConfigVarAttribute), false)[0] as ConfigVarAttribute; var name = attr.Name != null ? attr.Name : _class.Name.ToLower() + "." + field.Name.ToLower(); var cvar = field.GetValue(null) as ConfigVar; if (cvar != null) { GameDebug.LogError("ConfigVars (" + name + ") should not be initialized from code; just marked with attribute"); continue; } cvar = new ConfigVar(name, attr.Description, attr.DefaultValue, attr.Flags); cvar.ResetToDefault(); RegisterConfigVar(cvar); field.SetValue(null, cvar); } } } catch (System.Reflection.ReflectionTypeLoadException) { Debug.LogWarning("Unable to load types for assembly " + assembly.FullName); } } // Clear dirty flags as default values shouldn't count as dirtying DirtyFlags = Flags.None; }
public static void RegisterConfigVar(ConfigVar cvar) { if (ConfigVars.ContainsKey(cvar.name)) { GameDebug.LogError("Trying to register cvar " + cvar.name + " twice"); return; } if (!validateNameRe.IsMatch(cvar.name)) { GameDebug.LogError("Trying to register cvar with invalid name: " + cvar.name); return; } ConfigVars.Add(cvar.name, cvar); }