Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AdvancedREPO Config v1.0.2
BepInEx/patchers/AdvancedREPO.Config.Patcher.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AdvancedREPO.Patcher; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AdvancedREPO.Config.Patcher")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Synchronizing configurations for REPO")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+22cfc0ebd567466d9763ccff40b33ff29a108b14")] [assembly: AssemblyProduct("AdvancedREPO.Config.Patcher")] [assembly: AssemblyTitle("AdvancedREPO.Config.Patcher")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AdvancedREPO.Config { public class Patcher : Patcher { public static IEnumerable<string> TargetDLLs => Patcher.TargetDLLs; public static void Patch(AssemblyDefinition assembly) { Patcher.Patch(assembly); } } } namespace AdvancedREPO.Config.Patches { public class PunManager { [Patch("PunManager")] public static void AddMethods(TypeDefinition type) { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Expected O, but got Unknown //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Expected O, but got Unknown //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) Patcher.Log.LogInfo((object)"Adding sync methods to PunManager..."); Dictionary<string, TypeReference> dictionary = new Dictionary<string, TypeReference> { { "String", ((MemberReference)type).Module.TypeSystem.String }, { "Byte", ((MemberReference)type).Module.TypeSystem.Byte }, { "SByte", ((MemberReference)type).Module.TypeSystem.SByte }, { "Short", ((MemberReference)type).Module.TypeSystem.Int16 }, { "UShort", ((MemberReference)type).Module.TypeSystem.UInt16 }, { "Int", ((MemberReference)type).Module.TypeSystem.Int32 }, { "UInt", ((MemberReference)type).Module.TypeSystem.UInt32 }, { "Long", ((MemberReference)type).Module.TypeSystem.Int64 }, { "ULong", ((MemberReference)type).Module.TypeSystem.UInt64 }, { "Float", ((MemberReference)type).Module.TypeSystem.Single }, { "Double", ((MemberReference)type).Module.TypeSystem.Double }, { "Bool", ((MemberReference)type).Module.TypeSystem.Boolean } }; CustomAttribute val = ((IEnumerable<MethodDefinition>)type.Methods).Where((MethodDefinition e) => ((MemberReference)e).Name == "CrownPlayerRPC").First().CustomAttributes[0]; foreach (KeyValuePair<string, TypeReference> item in dictionary) { MethodDefinition val2 = new MethodDefinition("SyncConfig" + item.Key, (MethodAttributes)6, ((MemberReference)type).Module.TypeSystem.Void); ((MethodReference)val2).Parameters.Add(new ParameterDefinition("propertyName", (ParameterAttributes)0, ((MemberReference)type).Module.TypeSystem.String)); ((MethodReference)val2).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, item.Value)); val2.Body = new MethodBody(val2); ILProcessor iLProcessor = val2.Body.GetILProcessor(); iLProcessor.Append(iLProcessor.Create(OpCodes.Ret)); type.Methods.Add(val2); MethodDefinition val3 = new MethodDefinition("SyncConfig" + item.Key + "RPC", (MethodAttributes)6, ((MemberReference)type).Module.TypeSystem.Void); ((MethodReference)val3).Parameters.Add(new ParameterDefinition("propertyName", (ParameterAttributes)0, ((MemberReference)type).Module.TypeSystem.String)); ((MethodReference)val3).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, item.Value)); val3.CustomAttributes.Add(new CustomAttribute(val.Constructor)); val3.Body = new MethodBody(val3); iLProcessor = val3.Body.GetILProcessor(); iLProcessor.Append(iLProcessor.Create(OpCodes.Ret)); type.Methods.Add(val3); } } } }
BepInEx/plugins/AdvancedREPO.Config.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AdvancedREPO.Config.Patches; using AdvancedREPO.Utils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AdvancedREPO.Config")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Synchronizing configurations for REPO")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+91089561413fedaed7f28d429c4a3c83beb72026")] [assembly: AssemblyProduct("AdvancedREPO.Config")] [assembly: AssemblyTitle("AdvancedREPO.Config")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AdvancedREPO.Config { public static class ConfigBuilderStatic { public static ConfigField<T> Sync<T>(this ConfigEntry<T> entry) { return ConfigBuilder<T>.Sync(entry, Assembly.GetCallingAssembly().GetName().Name); } } public class ConfigBuilder<T> { private static Dictionary<string, ConfigFile> AssignedFiles = new Dictionary<string, ConfigFile>(StringComparer.OrdinalIgnoreCase); private ConfigFile? _File; private bool _Sync = false; private string? _Description; private string? _Section; private string? _Key; private T[]? _Acceptable; private T? _Min; private T? _Max; private T? _Default; private ConfigEntry<T>? _Entry; private string _ModName; public ConfigBuilder() { _ModName = Assembly.GetCallingAssembly().GetName().Name; } public ConfigBuilder(string modName) { _ModName = modName; } public static ConfigField<T> Sync(ConfigEntry<T> entry, string modName = null) { return new ConfigBuilder<T>((modName != null) ? modName : Assembly.GetCallingAssembly().GetName().Name).Entry(entry).Sync().Build(); } public static ConfigBuilder<T> FromConfigEntry(ConfigEntry<T> entry) { return new ConfigBuilder<T>(Assembly.GetCallingAssembly().GetName().Name).Entry(entry); } public ConfigBuilder<T> Entry(ConfigEntry<T> entry) { _Entry = entry; return this; } private static ConfigFile FindFile(string modName, string fileName) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown string text = Path.Combine(Paths.ConfigPath, modName, fileName); if (!AssignedFiles.ContainsKey(text)) { AssignedFiles.Add(text, new ConfigFile(text, true)); } return AssignedFiles[text]; } public ConfigBuilder<T> Description(string description) { _Description = description; return this; } public ConfigBuilder<T> Section(string section) { _Section = section; return this; } public ConfigBuilder<T> Key(string key) { _Key = key; return this; } public ConfigBuilder<T> Range(T min, T max) { _Min = min; _Max = max; return this; } public ConfigBuilder<T> Default(T @default) { _Default = @default; return this; } public ConfigBuilder<T> Acceptable(T[] values) { _Acceptable = values; return this; } public ConfigBuilder<T> Sync(bool val = true) { _Sync = val; return this; } public ConfigBuilder<T> File(ConfigFile file) { _File = file; return this; } public ConfigBuilder<T> File(string fileName) { _File = FindFile(_ModName, fileName); return this; } public ConfigField<T> Build() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_0182: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown ConfigField<T> ret = new ConfigField<T>(); ret.Sync = _Sync; if (_Entry != null) { ret.Entry = _Entry; } else if (_File != null) { AcceptableValueBase val = null; if (_Min != null && _Max != null && default(T) is IComparable<T>) { val = (AcceptableValueBase)Activator.CreateInstance(typeof(AcceptableValueRange<>).MakeGenericType(typeof(T)), _Min, _Max); } else if (_Acceptable != null && default(T) is IEquatable<T>) { val = (AcceptableValueBase)Activator.CreateInstance(typeof(AcceptableValueList<>).MakeGenericType(typeof(T)), _Acceptable); } ret.Entry = _File.Bind<T>(new ConfigDefinition(_Section, _Key), _Default, new ConfigDescription(_Description, val, Array.Empty<object>())); } ret.Key = _ModName; if (((ConfigEntryBase)ret.Entry).Definition.Section != null) { ConfigField<T> configField = ret; configField.Key = configField.Key + ":" + ((ConfigEntryBase)ret.Entry).Definition.Section; } ConfigField<T> configField2 = ret; configField2.Key = configField2.Key + ":" + ((ConfigEntryBase)ret.Entry).Definition.Key; if (ret.Sync) { ret.Entry.SettingChanged += delegate { if (!ret.SyncedValue.Equals(ret.Entry.Value)) { ret.SyncWithClients(); } }; ret.AddToSync(); } return ret; } private void Entry_SettingChanged(object sender, EventArgs e) { throw new NotImplementedException(); } } public class ConfigField { internal bool Sync = false; internal string Key = null; public virtual void AddToSync() { AdvancedREPO.Config.Sync.Configs.Add(Key, this); } internal virtual void SyncWithClients() { } } public class ConfigField<T> : ConfigField { public delegate void SettingChangedHandler(object sender, EventArgs e); public delegate void ValueChangedHandler(object sender, EventArgs e); private bool ReceivedSynced = false; private ConfigEntry<T> _Entry; private T OldValue; private T? _SyncedValue; public ConfigEntry<T> Entry { get { return _Entry; } set { if (_Entry != null) { _Entry.SettingChanged -= SettingChangedListener; } _Entry = value; OldValue = _Entry.Value; _Entry.SettingChanged += SettingChangedListener; } } internal T? SyncedValue { get { return _SyncedValue; } set { ReceivedSynced = true; bool flag = false; if (value != null) { ref T reference = ref value; T val = default(T); if (val == null) { val = reference; reference = ref val; } if (!reference.Equals(Value)) { goto IL_0064; } } if (value == null && Value != null) { goto IL_0064; } goto IL_0068; IL_0068: _SyncedValue = value; if (flag) { this.ValueChanged?.Invoke(this, new EventArgs()); } return; IL_0064: flag = true; goto IL_0068; } } public T? Value { get { if (Sync && ReceivedSynced) { return SyncedValue; } if (_Entry != null) { return _Entry.Value; } return default(T); } set { if (_Entry != null) { _Entry.Value = value; } } } public event SettingChangedHandler SettingChanged; public event ValueChangedHandler ValueChanged; private void SettingChangedListener(object sender, EventArgs e) { T val; if (OldValue != null) { ref T reference = ref OldValue; val = default(T); if (val == null) { val = reference; reference = ref val; } if (!reference.Equals(Entry.Value)) { goto IL_0073; } } if (OldValue == null && Entry.Value != null) { goto IL_0073; } goto IL_00da; IL_00da: if (!Sync) { return; } if (SyncedValue != null) { val = SyncedValue; if (!val.Equals(Entry.Value)) { goto IL_0144; } } if (SyncedValue != null || Entry.Value == null) { return; } goto IL_0144; IL_0144: SyncWithClients(); return; IL_0073: OldValue = Entry.Value; T value = Value; this.SettingChanged?.Invoke(sender, e); val = Value; if (!val.Equals(value)) { this.ValueChanged?.Invoke(this, new EventArgs()); } goto IL_00da; } internal override void SyncWithClients() { PunManager instance = PunManager.instance; if ((Object)(object)instance != (Object)null && (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient)) { if (typeof(T) == typeof(bool)) { PunManagerPatches.SyncConfigBool(instance, Key, (bool)(object)Entry.Value); } else if (typeof(T) == typeof(byte)) { PunManagerPatches.SyncConfigByte(instance, Key, (byte)(object)Entry.Value); } else if (typeof(T) == typeof(sbyte)) { PunManagerPatches.SyncConfigSByte(instance, Key, (sbyte)(object)Entry.Value); } else if (typeof(T) == typeof(short)) { PunManagerPatches.SyncConfigShort(instance, Key, (short)(object)Entry.Value); } else if (typeof(T) == typeof(ushort)) { PunManagerPatches.SyncConfigUShort(instance, Key, (ushort)(object)Entry.Value); } else if (typeof(T) == typeof(int)) { PunManagerPatches.SyncConfigInt(instance, Key, (int)(object)Entry.Value); } else if (typeof(T) == typeof(uint)) { PunManagerPatches.SyncConfigUInt(instance, Key, (uint)(object)Entry.Value); } else if (typeof(T) == typeof(long)) { PunManagerPatches.SyncConfigLong(instance, Key, (long)(object)Entry.Value); } else if (typeof(T) == typeof(ulong)) { PunManagerPatches.SyncConfigULong(instance, Key, (ulong)(object)Entry.Value); } else if (typeof(T) == typeof(float)) { PunManagerPatches.SyncConfigFloat(instance, Key, (float)(object)Entry.Value); } else if (typeof(T) == typeof(double)) { PunManagerPatches.SyncConfigDouble(instance, Key, (double)(object)Entry.Value); } else if (typeof(T) == typeof(string)) { PunManagerPatches.SyncConfigString(instance, Key, (string)(object)Entry.Value); } } } } [BepInPlugin("potatoepet.advancedrepo.config", "AdvancedREPO.Config", "1.0.2")] public class Plugin : BaseUnityPlugin { public static ManualLogSource? Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Applying AdvancedREPO.Config..."); PunManagerPatches.ApplyPatches(); Log.LogInfo((object)"AdvancedREPO.Config applied!"); } } internal class Sync { public static Dictionary<string, ConfigField> Configs = new Dictionary<string, ConfigField>(); private static ConfigField<T>? GetConfig<T>(string propertyName) { if (Configs.ContainsKey(propertyName) && Configs[propertyName] is ConfigField<T> result) { return result; } return null; } internal static void ApplyLocal() { foreach (KeyValuePair<string, ConfigField> config in Configs) { if (config.Value is ConfigField<bool> field) { ApplyLocal(field); } else if (config.Value is ConfigField<byte> field2) { ApplyLocal(field2); } else if (config.Value is ConfigField<sbyte> field3) { ApplyLocal(field3); } else if (config.Value is ConfigField<short> field4) { ApplyLocal(field4); } else if (config.Value is ConfigField<ushort> field5) { ApplyLocal(field5); } else if (config.Value is ConfigField<int> field6) { ApplyLocal(field6); } else if (config.Value is ConfigField<uint> field7) { ApplyLocal(field7); } else if (config.Value is ConfigField<long> field8) { ApplyLocal(field8); } else if (config.Value is ConfigField<ulong> field9) { ApplyLocal(field9); } else if (config.Value is ConfigField<float> field10) { ApplyLocal(field10); } else if (config.Value is ConfigField<double> field11) { ApplyLocal(field11); } else if (config.Value is ConfigField<string> field12) { ApplyLocal(field12); } } } internal static void ApplyLocal<T>(ConfigField<T> field) { if (field.Entry != null) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogDebug((object)$"Applying local configuration for {field.Key}: {field.Entry.Value}"); } field.SyncedValue = field.Entry.Value; } } internal static void SyncSet<T>(string propertyName, T val) { ManualLogSource? log = Plugin.Log; if (log != null) { log.LogDebug((object)$"Received configuration for {propertyName}: {val}"); } ConfigField<T> config = GetConfig<T>(propertyName); if (config != null) { config.SyncedValue = val; } } } } namespace AdvancedREPO.Config.Patches { public class PunManagerPatches { private static PunManager _Instance; private static Field<PunManager, PhotonView>? PhotonViewField; public static PunManager Instance { get { if ((Object)(object)_Instance == (Object)null) { _Instance = Object.FindFirstObjectByType<PunManager>(); } return _Instance; } set { if ((Object)(object)value != (Object)null) { _Instance = value; } } } public static void ApplyPatches() { PhotonViewField = new Field<PunManager, PhotonView>((from e in typeof(PunManager).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) where e.Name == "photonView" select e).First()); ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)"Patching PunManager..."); } Harmony.CreateAndPatchAll(typeof(PunManagerPatches), (string)null); ManualLogSource? log2 = Plugin.Log; if (log2 != null) { log2.LogInfo((object)"PunManager patched!"); } } [HarmonyPatch(typeof(PunManager), "SyncConfigBool")] [HarmonyPrefix] public static void SyncConfigBool(PunManager __instance, string propertyName, bool value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigBoolRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigBoolRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigByte")] [HarmonyPrefix] public static void SyncConfigByte(PunManager __instance, string propertyName, byte value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigByteRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigByteRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigSByte")] [HarmonyPrefix] public static void SyncConfigSByte(PunManager __instance, string propertyName, sbyte value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigSByteRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigSByteRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigShort")] [HarmonyPrefix] public static void SyncConfigShort(PunManager __instance, string propertyName, short value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigShortRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigShortRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigUShort")] [HarmonyPrefix] public static void SyncConfigUShort(PunManager __instance, string propertyName, ushort value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigUShortRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigUShortRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigInt")] [HarmonyPrefix] public static void SyncConfigInt(PunManager __instance, string propertyName, int value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigIntRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigIntRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigUInt")] [HarmonyPrefix] public static void SyncConfigUInt(PunManager __instance, string propertyName, uint value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigUIntRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigUIntRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigLong")] [HarmonyPrefix] public static void SyncConfigLong(PunManager __instance, string propertyName, long value) { if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.IsMultiplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigLongRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigLongRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigULong")] [HarmonyPrefix] public static void SyncConfigULong(PunManager __instance, string propertyName, ulong value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigULongRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigULongRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigFloat")] [HarmonyPrefix] public static void SyncConfigFloat(PunManager __instance, string propertyName, float value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigFloatRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigFloatRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigDouble")] [HarmonyPrefix] public static void SyncConfigDouble(PunManager __instance, string propertyName, double value) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigDoubleRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigDoubleRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigString")] [HarmonyPrefix] public static void SyncConfigString(PunManager __instance, string propertyName, string value) { if (!SemiFunc.IsMasterClientOrSingleplayer() || !SemiFunc.IsMultiplayer()) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView val = PhotonViewField?.GetValue(__instance) ?? null; if (val != null) { val.RPC("SyncConfigStringRPC", (RpcTarget)0, new object[2] { propertyName, value }); } } else { SyncConfigStringRPC(__instance, propertyName, value); } } [HarmonyPatch(typeof(PunManager), "SyncConfigBoolRPC")] [HarmonyPrefix] public static void SyncConfigBoolRPC(PunManager __instance, string propertyName, bool value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigByteRPC")] [HarmonyPrefix] public static void SyncConfigByteRPC(PunManager __instance, string propertyName, byte value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigSByteRPC")] [HarmonyPrefix] public static void SyncConfigSByteRPC(PunManager __instance, string propertyName, sbyte value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigShortRPC")] [HarmonyPrefix] public static void SyncConfigShortRPC(PunManager __instance, string propertyName, short value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigUShortRPC")] [HarmonyPrefix] public static void SyncConfigUShortRPC(PunManager __instance, string propertyName, ushort value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigIntRPC")] [HarmonyPrefix] public static void SyncConfigIntRPC(PunManager __instance, string propertyName, int value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigUIntRPC")] [HarmonyPrefix] public static void SyncConfigUIntRPC(PunManager __instance, string propertyName, uint value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigLongRPC")] [HarmonyPrefix] public static void SyncConfigLongRPC(PunManager __instance, string propertyName, long value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigULongRPC")] [HarmonyPrefix] public static void SyncConfigULongRPC(PunManager __instance, string propertyName, ulong value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigFloatRPC")] [HarmonyPrefix] public static void SyncConfigFloatRPC(PunManager __instance, string propertyName, float value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigDoubleRPC")] [HarmonyPrefix] public static void SyncConfigDoubleRPC(PunManager __instance, string propertyName, double value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncConfigStringRPC")] [HarmonyPrefix] public static void SyncConfigStringRPC(PunManager __instance, string propertyName, string value) { Sync.SyncSet(propertyName, value); } [HarmonyPatch(typeof(PunManager), "SyncAllDictionaries")] [HarmonyPrefix] public static void InitiateSync(PunManager __instance) { if (SemiFunc.IsMultiplayer() && !PhotonNetwork.IsMasterClient) { return; } ManualLogSource? log = Plugin.Log; if (log != null) { log.LogInfo((object)"Synchronizing configuration with clients..."); } foreach (KeyValuePair<string, ConfigField> config in Sync.Configs) { config.Value.SyncWithClients(); } } } }