From 52de9a22debbd1db1f0babefc441f577f6b44559 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Thu, 19 Jun 2025 23:24:02 -0400 Subject: [PATCH] fix preset loading networking --- MiraAPI/GameOptions/OptionTypes/ModdedOption.cs | 9 +++++---- MiraAPI/Presets/OptionPreset.cs | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs index 94f6f3d..3c98d24 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs @@ -27,7 +27,7 @@ public abstract class ModdedOption : IModdedOption public StringNames StringName { get; } /// - public BaseGameSetting Data { get; protected init; } = null!; + public BaseGameSetting Data { get; protected set; } = null!; /// public IMiraPlugin? ParentMod @@ -95,7 +95,8 @@ public abstract class ModdedOption : IModdedOption /// Sets the value of the option. /// /// The new value. - public void SetValue(T newValue) + /// Whether to send the value to other players. + public void SetValue(T newValue, bool sendRpc = true) { var oldVal = Value; Value = newValue; @@ -105,7 +106,7 @@ public abstract class ModdedOption : IModdedOption ChangedEvent?.Invoke(Value); } - if (AmongUsClient.Instance.AmHost) + if (sendRpc && AmongUsClient.Instance.AmHost) { if (ParentMod?.GetConfigFile().TryGetEntry(ConfigDefinition, out var entry) == true) { @@ -141,7 +142,7 @@ public abstract class ModdedOption : IModdedOption { if (presetConfig.TryGetEntry(ConfigDefinition, out ConfigEntry entry)) { - SetValue(entry.Value); + SetValue(entry.Value, false); } else { diff --git a/MiraAPI/Presets/OptionPreset.cs b/MiraAPI/Presets/OptionPreset.cs index 7e07df5..06e3f8a 100644 --- a/MiraAPI/Presets/OptionPreset.cs +++ b/MiraAPI/Presets/OptionPreset.cs @@ -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()) { role.LoadFromPreset(PresetConfig); } + + CustomRoleManager.SyncAllRoleSettings(); } }