Beispiel #1
0
        private LoggingConfiguration GetDefaultConfig()
        {
            LoggingConfiguration config = new LoggingConfiguration();

            config.Variables["nwn_home"] = UtilPlugin.GetUserDirectory();

            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget("console");

            consoleTarget.Layout = DefaultLayout;

            FileTarget fileTarget = new FileTarget("nwm.log");

            fileTarget.Layout               = DefaultLayout;
            fileTarget.FileName             = new SimpleLayout("${var:nwn_home}/logs.0/nwm.log");
            fileTarget.CreateDirs           = false;
            fileTarget.KeepFileOpen         = true;
            fileTarget.OpenFileCacheTimeout = 30;
            fileTarget.ConcurrentWrites     = false;

            config.AddTarget(consoleTarget);
            config.AddTarget(fileTarget);
            config.AddRule(LogLevel.Info, LogLevel.Fatal, consoleTarget);
            config.AddRule(LogLevel.Info, LogLevel.Fatal, fileTarget);

            return(config);
        }
Beispiel #2
0
        private LoggingConfiguration GetConfigFromFile(string path)
        {
            LoggingConfiguration config = new XmlLoggingConfiguration(path);

            config.Variables["nwn_home"] = UtilPlugin.GetUserDirectory();

            return(config);
        }
        private T Load2DAToCache <T>(string name) where T : ITwoDimArray, new()
        {
            T new2da = new T();

            for (int i = 0; i < UtilPlugin.Get2DARowCount(name); i++)
            {
                int rowIndex = i;
                new2da.DeserializeRow(rowIndex, (column) => NWScript.Get2DAString(name, column, rowIndex));
            }

            cache[name] = new2da;
            return(new2da);
        }
Beispiel #4
0
 /// <summary>
 /// Determines if the supplied resref exists and is of the specified type.
 /// </summary>
 /// <param name="resRef">The resref to check.</param>
 /// <param name="type">The type of this resref.</param>
 /// <returns>true if the supplied resref exists and is of the specified type, otherwise false.</returns>
 public static int IsValidResRef(this string resRef, ResRefType type = ResRefType.Creature) => UtilPlugin.IsValidResRef(resRef);
Beispiel #5
0
 /// <summary>
 /// Retrieves an environment variable.
 /// </summary>
 /// <param name="sVarname">The environment variable to query.The environment variable to query.</param>
 /// <returns>The value of the environment variable.</returns>
 public static string GetEnvironmentVariable(string sVarname) => UtilPlugin.GetEnvironmentVariable(sVarname);
Beispiel #6
0
 /// <summary>
 /// Convert an itemproperty type to an effect type.
 /// </summary>
 /// <param name="ip">ip The itemproperty to convert to an effect.</param>
 /// <returns>The converted effect.</returns>
 public static NWN.API.Effect AsEffect(this NWN.API.ItemProperty ip) => UtilPlugin.ItemPropertyToEffect(ip);
Beispiel #7
0
 /// <summary>
 /// Strip any color codes from a string.
 /// </summary>
 /// <param name="str">The string to strip of color.</param>
 /// <returns>The new string without any color codes.</returns>
 public static string StripColors(this string str) => UtilPlugin.StripColors(str);
Beispiel #8
0
 /// <summary>
 /// Convert an effect type to an itemproperty type.
 /// </summary>
 /// <param name="effect">The effect to convert to an itemproperty.</param>
 /// <returns>The converted itemproperty.</returns>
 public static NWN.API.ItemProperty AsItemProperty(this NWN.API.Effect effect) => UtilPlugin.EffectToItemProperty(effect);
Beispiel #9
0
 /// <summary>
 /// Gets the vaulte of customTokenNumber.
 /// </summary>
 /// <param name="customTokenNumber">The token number to query.</param>
 /// <returns>The string representation of the token value.</returns>
 public static string GetCustomToken(int customTokenNumber) => UtilPlugin.GetCustomToken(customTokenNumber);
Beispiel #10
0
 /// <summary>
 /// Gets an integer hash of a string.
 /// </summary>
 /// <param name="str">The string to hash.</param>
 /// <returns>The hashed string as an integer.</returns>
 public static int Hash(string str) => UtilPlugin.Hash(str);
Beispiel #11
0
 /// <summary>
 /// Gets the name of the currently executing script.<br/>
 /// If depth is > 0, it will return the name of the script that called this one via ExecuteScript().
 /// </summary>
 /// <param name="depth">depth to seek the executing script.</param>
 /// <returns>The name of the currently executing script.</returns>
 public static string GetCurrentScriptName(int depth = 0) => UtilPlugin.GetCurrentScriptName();
Beispiel #12
0
 private static bool PluginAvailable(NWNXPluginAttribute plugin)
 {
     return(UtilPlugin.PluginExists(plugin.PluginName).ToBool());
 }