Merge branch 'presets' into commission

This commit is contained in:
XtraCube committed 2025-06-19 23:24:12 -04:00
commit ed0b4ebbc4
2 files changed
+9 -3

No files matched your search

@@ -95,7 +95,8 @@ public abstract class ModdedOption<T> : IModdedOption
/// Sets the value of the option.
/// </summary>
/// <param name="newValue">The new value.</param>
public void SetValue(T newValue)
/// <param name="sendRpc">Whether to send the value to other players.</param>
public void SetValue(T newValue, bool sendRpc = true)
{
var oldVal = Value;
Value = newValue;
@@ -105,7 +106,7 @@ public abstract class ModdedOption<T> : IModdedOption
ChangedEvent?.Invoke(Value);
}
if (AmongUsClient.Instance.AmHost)
if (sendRpc && AmongUsClient.Instance.AmHost)
{
if (ParentMod?.GetConfigFile().TryGetEntry<T>(ConfigDefinition, out var entry) == true)
{
@@ -141,7 +142,7 @@ public abstract class ModdedOption<T> : IModdedOption
{
if (presetConfig.TryGetEntry(ConfigDefinition, out ConfigEntry<T> entry))
{
SetValue(entry.Value);
SetValue(entry.Value, false);
}
else
{
+5
View File
@@ -1,5 +1,6 @@
using System.Linq;
using BepInEx.Configuration;
using MiraAPI.GameOptions;
using MiraAPI.PluginLoading;
using MiraAPI.Roles;
using UnityEngine;
@@ -61,9 +62,13 @@ public class OptionPreset
option.LoadFromPreset(PresetConfig);
}
ModdedOptionsManager.SyncAllOptions();
foreach (var role in Plugin.InternalRoles.Values.OfType<ICustomRole>())
{
role.LoadFromPreset(PresetConfig);
}
CustomRoleManager.SyncAllRoleSettings();
}
}