Selaa lähdekoodia

Added intellisense documentation

Bepis 7 vuotta sitten
vanhempi
commit
24053b0a10
5 muutettua tiedostoa jossa 93 lisäystä ja 22 poistoa
  1. 20 4
      BepInEx.Common/Utility.cs
  2. 12 4
      BepInEx/BaseUnityPlugin.cs
  3. 21 5
      BepInEx/Chainloader.cs
  4. 23 2
      BepInEx/Config.cs
  5. 17 7
      BepInEx/Logger.cs

+ 20 - 4
BepInEx.Common/Utility.cs

@@ -1,20 +1,36 @@
 using System;
-using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Reflection;
-using System.Text;
 
 namespace BepInEx.Common
 {
+    /// <summary>
+    /// Generic helper properties and methods.
+    /// </summary>
     public static class Utility
     {
+        /// <summary>
+        /// The directory that the Koikatsu .exe is being run from.
+        /// </summary>
         public static string ExecutingDirectory => Path.GetDirectoryName(Environment.CommandLine);
+
+        /// <summary>
+        /// The path that the plugins folder is located.
+        /// </summary>
         public static string PluginsDirectory => Path.Combine(ExecutingDirectory, "BepInEx");
 
-        //shamelessly stolen from Rei
+        /// <summary>
+        /// Combines multiple paths together, as the specfic method is not availble in .NET 3.5.
+        /// </summary>
+        /// <param name="parts">The multiple paths to combine together.</param>
+        /// <returns>A combined path.</returns>
         public static string CombinePaths(params string[] parts) => parts.Aggregate(Path.Combine);
 
+        /// <summary>
+        /// Converts a file path into a UnityEngine.WWW format.
+        /// </summary>
+        /// <param name="path">The file path to convert.</param>
+        /// <returns>A converted file path.</returns>
         public static string ConvertToWWWFormat(string path)
         {
             return $"file://{path.Replace('\\', '/')}";

+ 12 - 4
BepInEx/BaseUnityPlugin.cs

@@ -1,18 +1,26 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using UnityEngine;
-using UnityEngine.SceneManagement;
 
 namespace BepInEx
 {
+    /// <summary>
+    /// The base plugin type, that is loaded into the game.
+    /// </summary>
     public abstract class BaseUnityPlugin : MonoBehaviour
     {
+        /// <summary>
+        /// The unique identifier of the plugin. Should not change between plugin versions.
+        /// </summary>
         public abstract string ID { get; }
 
+        /// <summary>
+        /// The user friendly name of the plugin. Is able to be changed between versions.
+        /// </summary>
         public abstract string Name { get; }
 
+        /// <summary>
+        /// The specfic version of the plugin.
+        /// </summary>
         public abstract Version Version { get; }
     }
 }

+ 21 - 5
BepInEx/Chainloader.cs

@@ -1,23 +1,33 @@
 using BepInEx.Common;
-using ChaCustom;
-using Harmony;
 using System;
 using System.Collections.Generic;
 using System.IO;
-using System.Linq;
 using System.Reflection;
-using System.Text;
 using UnityEngine;
 
 namespace BepInEx
 {
+    /// <summary>
+    /// The manager and loader for all plugins, and the entry point for BepInEx.
+    /// </summary>
     public class Chainloader
     {
-        static bool loaded = false;
+        /// <summary>
+        /// The loaded and initialized list of plugins.
+        /// </summary>
         public static List<BaseUnityPlugin> Plugins { get; protected set; } = new List<BaseUnityPlugin>();
+
+        /// <summary>
+        /// The GameObject that all plugins are attached to as components.
+        /// </summary>
         public static GameObject ManagerObject { get; protected set; } = new GameObject("BepInEx_Manager");
 
 
+        static bool loaded = false;
+
+        /// <summary>
+        /// The entry point for BepInEx, called on the very first LoadScene() from UnityEngine.
+        /// </summary>
         public static void Initialize()
         {
             if (loaded)
@@ -53,6 +63,12 @@ namespace BepInEx
             loaded = true;
         }
 
+        /// <summary>
+        /// Loads a list of types from a directory containing assemblies, that derive from a base type.
+        /// </summary>
+        /// <typeparam name="T">The specfiic base type to search for.</typeparam>
+        /// <param name="directory">The directory to search for assemblies.</param>
+        /// <returns>Returns a list of found derivative types.</returns>
         public static List<Type> LoadTypes<T>(string directory)
         {
             List<Type> types = new List<Type>();

+ 23 - 2
BepInEx/Config.cs

@@ -1,18 +1,22 @@
 using BepInEx.Common;
-using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Text;
 
 namespace BepInEx
 {
+    /// <summary>
+    /// A helper class to handle persistent data.
+    /// </summary>
     public static class Config
     {
         private static Dictionary<string, string> cache = new Dictionary<string, string>();
 
         private static string configPath => Path.Combine(Utility.PluginsDirectory, "config.ini");
 
+        /// <summary>
+        /// If enabled, writes the config to disk every time a value is set.
+        /// </summary>
         public static bool SaveOnConfigSet { get; set; } = true;
 
         static Config()
@@ -27,6 +31,9 @@ namespace BepInEx
             }
         }
 
+        /// <summary>
+        /// Reloads the config from disk. Unwritten changes are lost.
+        /// </summary>
         public static void ReloadConfig()
         {
             cache.Clear();
@@ -41,11 +48,20 @@ namespace BepInEx
             }
         }
 
+        /// <summary>
+        /// Writes the config to disk.
+        /// </summary>
         public static void SaveConfig()
         {
             File.WriteAllLines(configPath, cache.Select(x => $"{x.Key}={x.Value}").ToArray());
         }
 
+        /// <summary>
+        /// Returns the value of the key if found, otherwise returns the default value.
+        /// </summary>
+        /// <param name="key">The key to search for.</param>
+        /// <param name="defaultValue">The default value to return if the key is not found.</param>
+        /// <returns>The value of the key.</returns>
         public static string GetEntry(string key, string defaultValue)
         {
             if (cache.TryGetValue(key, out string value))
@@ -54,6 +70,11 @@ namespace BepInEx
                 return defaultValue;
         }
 
+        /// <summary>
+        /// Sets the value of the key in the config.
+        /// </summary>
+        /// <param name="key">The key to set the value to.</param>
+        /// <param name="value">The value to set.</param>
         public static void SetEntry(string key, string value)
         {
             cache[key] = value;

+ 17 - 7
BepInEx/Logger.cs

@@ -1,17 +1,27 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BepInEx
+namespace BepInEx
 {
+    /// <summary>
+    /// A helper class to use for logging.
+    /// </summary>
     public static class BepInLogger
     {
+        /// <summary>
+        /// The handler for a entry logged event.
+        /// </summary>
+        /// <param name="entry">The text element of the log itself.</param>
+        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
         public delegate void EntryLoggedEventHandler(string entry, bool show = false);
 
+        /// <summary>
+        /// The listener event for an entry being logged.
+        /// </summary>
         public static event EntryLoggedEventHandler EntryLogged;
 
-
+        /// <summary>
+        /// Logs an entry to the logger, and any listeners are notified of the entry.
+        /// </summary>
+        /// <param name="entry">The text element of the log itself.</param>
+        /// <param name="show">Whether or not it should be dislpayed to the user.</param>
         public static void Log(string entry, bool show = false)
         {
             EntryLogged?.Invoke(entry, show);