Ejemplo n.º 1
0
        protected override void MakeConfig()
        {
            TweakLogger.LogInfo("AContentModuleExample", "make config");

            //use AddConfig(...) here.
            //Not all tweaks will have config, but all must implement this method.
        }
Ejemplo n.º 2
0
 private void Enabled_SettingChanged(object sender, EventArgs e)
 {
     if (Enabled.Value)
     {
         TweakLogger.LogInfo("AContentModuleBase", $"Enabled AContentModule: {Name}.");
     }
     else
     {
         TweakLogger.LogInfo("AContentModuleBase", $"Disabled AContentModule: {Name}.");
     }
 }
Ejemplo n.º 3
0
 /// <summary>Use Reflection to set the name from the HarbTweak attribute to prevent having to declare it twice</summary>
 /// <param name="config">A reference to the Config of the calling plugin</param>
 /// <param name="name">The name of this tweak, should be identical to the HarbTweak attribute name.</param>
 /// <param name="defaultEnabled">If this tweak is enabled by default.</param>
 /// <param name="description">If this tweak is enabled by default.</param>
 public AContentModule(ConfigFile config, string name, bool defaultEnabled, string description)
 {
     Config  = config;
     Name    = name;
     Enabled = AddConfig("Enabled", defaultEnabled, description);
     Enabled.SettingChanged += Enabled_SettingChanged;
     MakeConfig();
     if (Enabled.Value)
     {
         TweakLogger.Log($"Loaded AContentModule: {Name}.");
     }
     else
     {
         TweakLogger.Log($"Prepared AContentModule: {Name}.");
     }
 }
Ejemplo n.º 4
0
 private void EnableAContentModule(Type type, AContentModuleAttribute customAttr)
 {
     //constuctorArgumentArray[0] is set in the constructor of this class.
     constuctorArgumentArray[1] = customAttr.Name;
     constuctorArgumentArray[2] = customAttr.DefaultEnabled;
     constuctorArgumentArray[3] = customAttr.Description;
     try
     {
         var            ctor           = type.GetConstructor(constructorParameters);
         AContentModule aContentModule = (AContentModule)ctor.Invoke(constuctorArgumentArray);
         aContentModule.ReloadContent();
     }
     catch
     {
         TweakLogger.Log($"Couldn't load AContentModule: {constuctorArgumentArray[1]}", 0);
     }
 }
Ejemplo n.º 5
0
 protected override void RemoveContent()
 {
     //This should return the game to the original state after Hook has been called.
     //AKA: after Unhook() has been called, the game continues in a vanilla behaviour.
     TweakLogger.LogInfo("AContentModuleExample", "remove content");
 }
Ejemplo n.º 6
0
 protected override void AddContent()
 {
     //This is where you set your hooks, subscribe to events, apply variable changes.
     TweakLogger.LogInfo("AContentModuleExample ", "add content");
 }
Ejemplo n.º 7
0
 private void LogLevel_SettingChanged(object _, EventArgs __)
 {
     TweakLogger.SetLogLevel(LogLevel.Value);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// This will only be logged to the console if the loglevel is set to 3 or higher.
 /// </summary>
 /// <param name="text">The message to display in the bepinex console</param>
 protected void LogInfo(string text)
 {
     TweakLogger.LogInfo(Name, text);
 }