mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Merge branch 'presets' into commission
This commit is contained in:
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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user