Beispiel #1
0
 private PawnType(string id, string label, string labelPlural, OptionTarget target = default(OptionTarget))
 {
     Id          = id;
     Label       = label;
     LabelPlural = labelPlural;
     AsTarget    = target;
 }
Beispiel #2
0
        public static T GetAddonDefaultValue <T>(OptionTarget target, AddonOption addon, T invalidValue = default(T))
        {
            var rules = GetDefaultRules(PawnType.FromTarget(target));

            if ((rules == null) || !addon.AllowedInPreset)
            {
                return(invalidValue);
            }
            return(rules.GetAddonValue(addon, invalidValue));
        }
Beispiel #3
0
        internal static OptionHandle <T> Add <T>(PawnRulesLink link, string key, OptionTarget target, OptionWidget widget, string label, string tooltip, T defaultValue, bool allowedInPreset = true)
        {
            var option = new AddonOption(link, link.ModContentPack.PackageId + "_" + key, target, widget, label, tooltip, typeof(T), defaultValue, allowedInPreset);

            AddonManager.Add(option);

            var handle = new OptionHandle <T>(option);

            option.Handle = handle;

            return(handle);
        }
Beispiel #4
0
 private AddonOption(PawnRulesLink link, string key, OptionTarget target, OptionWidget widget, string label, string tooltip, Type type, object defaultValue, bool allowedInPreset)
 {
     Link            = link;
     Key             = key;
     Target          = target;
     Widget          = widget;
     Label           = label;
     Tooltip         = tooltip;
     Type            = type;
     DefaultValue    = defaultValue;
     AllowedInPreset = allowedInPreset;
 }
Beispiel #5
0
 public static PawnType FromTarget(OptionTarget target) => List.FirstOrDefault(type => type.AsTarget == target);
Beispiel #6
0
 public bool IsTargetted(OptionTarget target) => (AsTarget != default(OptionTarget)) && ((AsTarget & target) == AsTarget);
Beispiel #7
0
 /// <summary>
 ///     Adds a new Button to the Rules dialog that sets a <see cref="string" /> value. Buttons require <see cref="OptionHandle.OnButtonClick" /> to be used to set the value.
 /// </summary>
 /// <param name="key">The key used in the save file. Will be automatically prefixed with your Mod Identifier.</param>
 /// <param name="target">The type(s) of pawns this option will apply to.</param>
 /// <param name="label">The label of the widget displayed.</param>
 /// <param name="tooltip">The tooltip displayed for the widget.</param>
 /// <param name="defaultValue">This is the default value if <see paramref="allowedInPreset" /> is false or no default rules exist when a pawn is first given rules.</param>
 /// <param name="allowedInPreset">If set to false it cannot be used in a preset.</param>
 /// <returns>Returns a handle for this option.</returns>
 public OptionHandle <string> AddButton(string key, OptionTarget target, string label, string tooltip, string defaultValue, bool allowedInPreset = true) => AddonOption.Add(this, key, target, OptionWidget.Button, label, tooltip, defaultValue, allowedInPreset);
Beispiel #8
0
 /// <summary>
 ///     Adds a new Entry to the Rules dialog that sets a <see cref="float" /> value.
 /// </summary>
 /// <param name="key">The key used in the save file. Will be automatically prefixed with your Mod Identifier.</param>
 /// <param name="target">The type(s) of pawns this option will apply to.</param>
 /// <param name="label">The label of the widget displayed.</param>
 /// <param name="tooltip">The tooltip displayed for the widget.</param>
 /// <param name="defaultValue">This is the default value if <see paramref="allowedInPreset" /> is false or no default rules exist when a pawn is first given rules.</param>
 /// <param name="allowedInPreset">If set to false it cannot be used in a preset.</param>
 /// <returns>Returns a handle for this option.</returns>
 public OptionHandle <float> AddEntry(string key, OptionTarget target, string label, string tooltip, float defaultValue, bool allowedInPreset = true) => AddonOption.Add(this, key, target, OptionWidget.TextEntry, label, tooltip, defaultValue, allowedInPreset);
Beispiel #9
0
 /// <summary>
 ///     Adds a new Toggle to the Rules dialog that sets a <see cref="bool" />.
 /// </summary>
 /// <param name="key">The key used in the save file. Will be automatically prefixed with your Mod Identifier.</param>
 /// <param name="target">The type(s) of pawns this option will apply to.</param>
 /// <param name="label">The label of the widget displayed.</param>
 /// <param name="tooltip">The tooltip displayed for the widget.</param>
 /// <param name="defaultValue">This is the default value if <see paramref="allowedInPreset" /> is false or no default rules exist when a pawn is first given rules.</param>
 /// <param name="allowedInPreset">If set to false it cannot be used in a preset.</param>
 /// <returns>Returns a handle for this option.</returns>
 public OptionHandle <bool> AddToggle(string key, OptionTarget target, string label, string tooltip, bool defaultValue, bool allowedInPreset = true) => AddonOption.Add(this, key, target, OptionWidget.Checkbox, label, tooltip, defaultValue, allowedInPreset);