Esempio n. 1
0
 /// <summary>
 /// Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute.
 /// </summary>
 /// <param name="old">The other instance of ModConfig to compare against</param>
 /// <returns></returns>
 public virtual bool NeedsReload(ModConfig old)
 {
     foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(this))
     {
         ReloadRequiredAttribute reloadRequired = ConfigManager.GetCustomAttribute <ReloadRequiredAttribute>(variable, this, null);
         if (reloadRequired != null)
         {
             if (!variable.GetValue(this).Equals(variable.GetValue(old)))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
 /// <summary>
 /// Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute. Unlike the other ModConfig hooks, this method is called on a clone of the ModConfig that was saved during mod loading. The pendingConfig has values that are about to take effect. Neither of these instances necessarily match the instance used in OnLoaded.
 /// </summary>
 /// <param name="pendingConfig">The other instance of ModConfig to compare against, it contains the values that are pending to take effect</param>
 /// <returns></returns>
 public virtual bool NeedsReload(ModConfig pendingConfig)
 {
     foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(this))
     {
         ReloadRequiredAttribute reloadRequired = ConfigManager.GetCustomAttribute <ReloadRequiredAttribute>(variable, this, null);
         if (reloadRequired != null)
         {
             // Do we need to implement nested ReloadRequired? Right now only top level fields will trigger it.
             if (!ConfigManager.ObjectEquals(variable.GetValue(this), variable.GetValue(pendingConfig)))
             {
                 return(true);
             }
         }
     }
     return(false);
 }