using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using Elements.Core; using FrooxEngine; using FrooxEngine.UIX; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")] [assembly: AssemblyCompany("Gyztor Mizirath")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+80b8f00e832bb50e2bd6eeae181f1b980c075c26")] [assembly: AssemblyProduct("BepisArrayEditor")] [assembly: AssemblyTitle("BepisArrayEditor")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Gyztor/BepisArrayEditor")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace BepisArrayEditor; [HarmonyPatch] [HarmonyPatchCategory("ListUIImprovements")] internal sealed class ListUIImprovements { [HarmonyPatch(typeof(ListEditor), "BuildListElement")] private static bool Prefix(UIBuilder ui) { if (BepisArrayEditor.ArrayEditorListUIImprovemts.Value) { ui.Style.MinHeight = 24f; } return true; } [HarmonyPatch(typeof(SyncMemberEditorBuilder), "GenerateMemberField")] private static bool Prefix(ISyncMember member, UIBuilder ui) { if (!BepisArrayEditor.ArrayEditorListUIImprovemts.Value || !(((IWorldElement)member).Parent is ISyncList) || !(member is SyncObject)) { return true; } ((ContainerWorker)(object)((Component)ui.CurrentRect).Slot).AttachComponent(true, (Action)null); LayoutElement component = ((ContainerWorker)(object)((Component)ui.CurrentRect).Slot).GetComponent((Predicate)null, false); if (component != null) { ((SyncField)(object)component.MinWidth).Value = 48f; ((SyncField)(object)component.FlexibleWidth).Value = -1f; } return true; } } [ResonitePlugin("xyz.gyztormizirath.BepisArrayEditor", "BepisArrayEditor", "1.0.2", "Gyztor Mizirath", "https://github.com/Gyztor/BepisArrayEditor")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BepisArrayEditor : BasePlugin { [HarmonyPatch(typeof(SyncMemberEditorBuilder), "BuildArray")] internal sealed class ArrayEditor { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func, TubePoint> <>9__14_2; public static Action <>9__20_4; public static Action <>9__24_0; public static Action <>9__24_1; public static Action <>9__24_2; internal TubePoint b__14_2(Point point) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) return new TubePoint(((SyncField)(object)point.Value).Value, ((SyncField)(object)point.Position).Value); } internal void b__20_4(Component c) { ((ComponentBase)(object)c).Destroy(); } internal void b__24_0() { _skipListChanges = false; } internal void b__24_1() { _skipListChanges = false; } internal void b__24_2() { _skipListChanges = false; } } private static readonly MethodInfo _addCurveValueProxying = AccessTools.Method(typeof(ArrayEditor), "AddCurveValueProxying", (global::System.Type[])null, (global::System.Type[])null); private static readonly MethodInfo _addLinearValueProxying = AccessTools.Method(typeof(ArrayEditor), "AddLinearValueProxying", (global::System.Type[])null, (global::System.Type[])null); private static readonly MethodInfo _addListReferenceProxying = AccessTools.Method(typeof(ArrayEditor), "AddListReferenceProxying", (global::System.Type[])null, (global::System.Type[])null); private static readonly MethodInfo _addListValueProxying = AccessTools.Method(typeof(ArrayEditor), "AddListValueProxying", (global::System.Type[])null, (global::System.Type[])null); private static readonly global::System.Type _iWorldElementType = typeof(IWorldElement); private static readonly MethodInfo _setLinearPoint = AccessTools.Method(typeof(ArrayEditor), "SetLinearPoint", (global::System.Type[])null, (global::System.Type[])null); private static readonly MethodInfo _setCurvePoint = AccessTools.Method(typeof(ArrayEditor), "SetCurvePoint", (global::System.Type[])null, (global::System.Type[])null); private static readonly MethodInfo _buildList = typeof(SyncMemberEditorBuilder).GetMethod("BuildList", (BindingFlags)40); private static readonly MethodInfo _generateMemberField = typeof(SyncMemberEditorBuilder).GetMethod("GenerateMemberField", (BindingFlags)40); private static bool _skipListChanges = false; private static void AddCurveValueProxying(SyncArray> array, SyncElementList> list) where T : IEquatable { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) global::System.Collections.Generic.IEnumerator> enumerator = array.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { CurveKey current = enumerator.Current; Point obj = list.Add(); ((SyncField)(object)obj.Position).Value = current.time; ((SyncField)(object)obj.Value).Value = current.value; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AddUpdateProxies(array, list, list.Elements); list.ElementsAdded += delegate(SyncElementList> val, int startIndex, int count) { Point[] array2 = Enumerable.ToArray>(Enumerable.Take>(Enumerable.Skip>(val.Elements, startIndex), count)); CurveKey[] array3 = Enumerable.ToArray>(Enumerable.Select, CurveKey>((global::System.Collections.Generic.IEnumerable>)array2, (Func, CurveKey>)((Point point) => new CurveKey(Sync.op_Implicit(point.Position), Sync.op_Implicit(point.Value))))); if (!_skipListChanges) { ((SyncElement)array).Changed -= ArrayChanged; array.Insert(array3, startIndex); ((SyncElement)array).Changed += ArrayChanged; } AddUpdateProxies(array, val, (global::System.Collections.Generic.IEnumerable>)array2); }; list.ElementsRemoved += delegate(SyncElementList> val, int startIndex, int count) { if (!_skipListChanges && array.Count >= startIndex + count) { ((SyncElement)array).Changed -= ArrayChanged; array.Remove(startIndex, count); ((SyncElement)array).Changed += ArrayChanged; } }; } private static void AddLinearValueProxying(SyncArray> array, SyncElementList> list) where T : IEquatable { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) global::System.Collections.Generic.IEnumerator> enumerator = array.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { LinearKey current = enumerator.Current; Point obj = list.Add(); ((SyncField)(object)obj.Position).Value = current.time; ((SyncField)(object)obj.Value).Value = current.value; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AddUpdateProxies(array, list, list.Elements); list.ElementsAdded += delegate(SyncElementList> val, int startIndex, int count) { Point[] array2 = Enumerable.ToArray>(Enumerable.Take>(Enumerable.Skip>(val.Elements, startIndex), count)); LinearKey[] array3 = Enumerable.ToArray>(Enumerable.Select, LinearKey>((global::System.Collections.Generic.IEnumerable>)array2, (Func, LinearKey>)((Point point) => new LinearKey(Sync.op_Implicit(point.Position), Sync.op_Implicit(point.Value))))); if (!_skipListChanges) { ((SyncElement)array).Changed -= ArrayChanged; array.Insert(array3, startIndex); ((SyncElement)array).Changed += ArrayChanged; } AddUpdateProxies(array, val, (global::System.Collections.Generic.IEnumerable>)array2); }; list.ElementsRemoved += delegate(SyncElementList> val, int startIndex, int count) { if (!_skipListChanges && array.Count >= startIndex + count) { ((SyncElement)array).Changed -= ArrayChanged; array.Remove(startIndex, count); ((SyncElement)array).Changed += ArrayChanged; } }; } private static void AddListReferenceProxying(SyncArray array, SyncElementList> list) where T : class, IEquatable, IWorldElement { global::System.Collections.Generic.IEnumerator enumerator = array.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { T current = enumerator.Current; list.Add().Target = current; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AddUpdateProxies(array, list, list.Elements); list.ElementsAdded += delegate(SyncElementList> val, int startIndex, int count) { SyncRef[] array2 = Enumerable.ToArray>(Enumerable.Take>(Enumerable.Skip>(val.Elements, startIndex), count)); T[] array3 = Enumerable.ToArray(Enumerable.Select, T>((global::System.Collections.Generic.IEnumerable>)array2, (Func, T>)((SyncRef syncRef) => syncRef.Target))); if (!_skipListChanges) { ((SyncElement)array).Changed -= ArrayChanged; array.Insert(array3, startIndex); ((SyncElement)array).Changed += ArrayChanged; } AddUpdateProxies(array, val, (global::System.Collections.Generic.IEnumerable>)array2); }; list.ElementsRemoved += delegate(SyncElementList> val, int startIndex, int count) { if (!_skipListChanges && array.Count >= startIndex + count) { ((SyncElement)array).Changed -= ArrayChanged; array.Remove(startIndex, count); ((SyncElement)array).Changed += ArrayChanged; } }; } private static void AddListValueProxying(SyncArray array, SyncElementList> list) where T : IEquatable { global::System.Collections.Generic.IEnumerator enumerator = array.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { T current = enumerator.Current; ((SyncField)(object)list.Add()).Value = current; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AddUpdateProxies(array, list, list.Elements); list.ElementsAdded += delegate(SyncElementList> val, int startIndex, int count) { Sync[] array2 = Enumerable.ToArray>(Enumerable.Take>(Enumerable.Skip>(val.Elements, startIndex), count)); T[] array3 = Enumerable.ToArray(Enumerable.Select, T>((global::System.Collections.Generic.IEnumerable>)array2, (Func, T>)((Sync sync) => ((SyncField)(object)sync).Value))); if (!_skipListChanges) { ((SyncElement)array).Changed -= ArrayChanged; array.Insert(array3, startIndex); ((SyncElement)array).Changed += ArrayChanged; } AddUpdateProxies(array, val, (global::System.Collections.Generic.IEnumerable>)array2); }; list.ElementsRemoved += delegate(SyncElementList> val, int startIndex, int count) { if (!_skipListChanges && array.Count >= startIndex + count) { ((SyncElement)array).Changed -= ArrayChanged; array.Remove(startIndex, count); ((SyncElement)array).Changed += ArrayChanged; } }; } private static void AddTubePointProxying(SyncArray array, SyncElementList> list) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) global::System.Collections.Generic.IEnumerator enumerator = array.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { TubePoint current = enumerator.Current; Point obj = list.Add(); ((SyncField)(object)obj.Position).Value = ((TubePoint)(ref current)).radius; ((SyncField)(object)obj.Value).Value = ((TubePoint)(ref current)).position; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } AddUpdateProxies(array, list, list.Elements); list.ElementsAdded += delegate(SyncElementList> val, int startIndex, int count) { Point[] array2 = Enumerable.ToArray>(Enumerable.Take>(Enumerable.Skip>(val.Elements, startIndex), count)); TubePoint[] array3 = Enumerable.ToArray(Enumerable.Select, TubePoint>((global::System.Collections.Generic.IEnumerable>)array2, (Func, TubePoint>)((Point point) => new TubePoint(((SyncField)(object)point.Value).Value, ((SyncField)(object)point.Position).Value)))); if (!_skipListChanges) { ((SyncElement)array).Changed -= ArrayChanged; array.Insert(array3, startIndex); ((SyncElement)array).Changed += ArrayChanged; } AddUpdateProxies(array, val, array2); }; list.ElementsRemoved += delegate(SyncElementList> val, int startIndex, int count) { if (!_skipListChanges && array.Count >= startIndex + count) { ((SyncElement)array).Changed -= ArrayChanged; array.Remove(startIndex, count); ((SyncElement)array).Changed += ArrayChanged; } }; } private static void AddUpdateProxies(SyncArray> array, SyncElementList> list, global::System.Collections.Generic.IEnumerable> elements) where T : IEquatable { global::System.Collections.Generic.IEnumerator> enumerator = elements.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Point point = enumerator.Current; ((SyncObject)point).Changed += delegate { //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (!_skipListChanges) { int num = list.IndexOfElement(point); ((SyncElement)array).Changed -= ArrayChanged; array[num] = new LinearKey(Sync.op_Implicit(point.Position), Sync.op_Implicit(point.Value)); ((SyncElement)array).Changed += ArrayChanged; } }; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static void AddUpdateProxies(SyncArray array, SyncElementList> list, global::System.Collections.Generic.IEnumerable> elements) where T : IEquatable { global::System.Collections.Generic.IEnumerator> enumerator = elements.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Sync sync = enumerator.Current; ((SyncField)(object)sync).OnValueChange += delegate { if (!_skipListChanges) { int num = list.IndexOfElement(sync); ((SyncElement)array).Changed -= ArrayChanged; array[num] = ((SyncField)(object)sync).Value; ((SyncElement)array).Changed += ArrayChanged; } }; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static void AddUpdateProxies(SyncArray array, SyncElementList> list, global::System.Collections.Generic.IEnumerable> elements) where T : class, IEquatable, IWorldElement { global::System.Collections.Generic.IEnumerator> enumerator = elements.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { SyncRef sync = enumerator.Current; ((SyncField)(object)sync).OnValueChange += delegate { if (!_skipListChanges) { int num = list.IndexOfElement(sync); ((SyncElement)array).Changed -= ArrayChanged; array[num] = sync.Target; ((SyncElement)array).Changed += ArrayChanged; } }; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static void AddUpdateProxies(SyncArray array, SyncElementList> list, global::System.Collections.Generic.IEnumerable> elements) { global::System.Collections.Generic.IEnumerator> enumerator = elements.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Point point = enumerator.Current; ((SyncObject)point).Changed += delegate { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!_skipListChanges) { int num = list.IndexOfElement(point); TubePoint val = default(TubePoint); ((TubePoint)(ref val))..ctor(((SyncField)(object)point.Value).Value, ((SyncField)(object)point.Position).Value); ((SyncElement)array).Changed -= ArrayChanged; array[num] = val; ((SyncElement)array).Changed += ArrayChanged; } }; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static void AddUpdateProxies(SyncArray> array, SyncElementList> list, global::System.Collections.Generic.IEnumerable> elements) where T : IEquatable { global::System.Collections.Generic.IEnumerator> enumerator = elements.GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Point point = enumerator.Current; ((SyncObject)point).Changed += delegate { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!_skipListChanges) { int num = list.IndexOfElement(point); ((SyncElement)array).Changed -= ArrayChanged; array[num] = new CurveKey(Sync.op_Implicit(point.Position), Sync.op_Implicit(point.Value), array[num].leftTangent, array[num].rightTangent); ((SyncElement)array).Changed += ArrayChanged; } }; } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } } private static bool Prefix(ISyncArray array, string name, FieldInfo fieldInfo, UIBuilder ui, float labelSize) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Expected O, but got Unknown //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Expected O, but got Unknown if (!ArrayEditorEnabled.Value) { return true; } if (!TryGetGenericParameter(typeof(SyncArray<>), ((object)array).GetType(), out global::System.Type genericParameter)) { return false; } ((ContainerWorker)(object)((Component)ui.Panel()).Slot).GetComponent((Predicate)null, false); Slot slot = (Slot)((MethodBase)_generateMemberField).Invoke((object)null, new object[4] { array, name, ui, 0.3f }); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ran GenerateMemberField "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); } log.LogInfo(val); ui.ForceNext = ((ContainerWorker)(object)slot).AttachComponent(true, (Action)null); LocaleString val2 = LocaleString.op_Implicit("(Proxy Array)"); ui.Text(ref val2, true, (Alignment?)null, true, (string)null); ui.NestOut(); global::System.Type genericParameter2; bool num = TryGetGenericParameter(typeof(SyncLinear<>), ((object)array).GetType(), out genericParameter2); global::System.Type genericParameter3; bool flag2 = TryGetGenericParameter(typeof(SyncCurve<>), ((object)array).GetType(), out genericParameter3); string text = $"{name}-{((IWorldElement)array).ReferenceID}-Proxy"; Slot assetsSlot = ui.World.AssetsSlot; bool flag3 = false; Slot proxySlot = assetsSlot.FindChild(text); if (proxySlot == null) { proxySlot = assetsSlot.AddSlot(text, true); WorldElementExtensions.FindNearestParent((IWorldElement)(object)array, (Predicate)null).Destroyed += delegate { proxySlot.Destroy(); }; flag3 = true; } proxySlot.PersistentSelf = false; ((ContainerWorker)(object)proxySlot).GetComponentOrAttach((Predicate)((DestroyOnUserLeave d) => d.TargetUser.Target == ((Worker)slot).LocalUser)).TargetUser.Target = ((Worker)slot).LocalUser; ISyncList val3; FieldInfo syncMemberFieldInfo; if (num && SupportsLerp(genericParameter2)) { global::System.Type type = typeof(ValueGradientDriver<>).MakeGenericType(new global::System.Type[1] { genericParameter2 }); bool attachedNew; Component orAttachComponent = GetOrAttachComponent(proxySlot, type, out attachedNew); val3 = (ISyncList)((Worker)orAttachComponent).GetSyncMember("Points"); syncMemberFieldInfo = ((Worker)orAttachComponent).GetSyncMemberFieldInfo("Points"); if (attachedNew) { ((MethodBase)_addLinearValueProxying.MakeGenericMethod(new global::System.Type[1] { genericParameter2 })).Invoke((object)null, new object[2] { array, val3 }); } } else if (flag2 && SupportsLerp(genericParameter3)) { global::System.Type type2 = typeof(ValueGradientDriver<>).MakeGenericType(new global::System.Type[1] { genericParameter3 }); bool attachedNew2; Component orAttachComponent2 = GetOrAttachComponent(proxySlot, type2, out attachedNew2); val3 = (ISyncList)((Worker)orAttachComponent2).GetSyncMember("Points"); syncMemberFieldInfo = ((Worker)orAttachComponent2).GetSyncMemberFieldInfo("Points"); if (attachedNew2) { ((MethodBase)_addCurveValueProxying.MakeGenericMethod(new global::System.Type[1] { genericParameter3 })).Invoke((object)null, new object[2] { array, val3 }); } } else if (genericParameter == typeof(TubePoint)) { bool attachedNew3; Component orAttachComponent3 = GetOrAttachComponent(proxySlot, typeof(ValueGradientDriver), out attachedNew3); val3 = (ISyncList)((Worker)orAttachComponent3).GetSyncMember("Points"); syncMemberFieldInfo = ((Worker)orAttachComponent3).GetSyncMemberFieldInfo("Points"); if (attachedNew3) { AddTubePointProxying((SyncArray)(object)array, (SyncElementList>)(object)val3); } } else if (Coder.IsEnginePrimitive(genericParameter)) { global::System.Type type3 = typeof(ValueMultiplexer<>).MakeGenericType(new global::System.Type[1] { genericParameter }); bool attachedNew4; Component orAttachComponent4 = GetOrAttachComponent(proxySlot, type3, out attachedNew4); val3 = (ISyncList)((Worker)orAttachComponent4).GetSyncMember("Values"); syncMemberFieldInfo = ((Worker)orAttachComponent4).GetSyncMemberFieldInfo("Values"); if (attachedNew4) { ((MethodBase)_addListValueProxying.MakeGenericMethod(new global::System.Type[1] { genericParameter })).Invoke((object)null, new object[2] { array, val3 }); } } else { if (!_iWorldElementType.IsAssignableFrom(genericParameter)) { proxySlot.Destroy(); return false; } global::System.Type type4 = typeof(ReferenceMultiplexer<>).MakeGenericType(new global::System.Type[1] { genericParameter }); bool attachedNew5; Component orAttachComponent5 = GetOrAttachComponent(proxySlot, type4, out attachedNew5); val3 = (ISyncList)((Worker)orAttachComponent5).GetSyncMember("References"); syncMemberFieldInfo = ((Worker)orAttachComponent5).GetSyncMemberFieldInfo("References"); if (attachedNew5) { ((MethodBase)_addListReferenceProxying.MakeGenericMethod(new global::System.Type[1] { genericParameter })).Invoke((object)null, new object[2] { array, val3 }); } } Slot listSlot; if (!((ILinkable)array).IsDriven) { ((MethodBase)_buildList).Invoke((object)null, new object[4] { val3, name, syncMemberFieldInfo, ui }); listSlot = ui.Current; ((ContainerWorker)(object)listSlot).GetComponentOrAttach((Predicate)((DestroyOnUserLeave d) => d.TargetUser.Target == ((Worker)slot).LocalUser)).TargetUser.Target = ((Worker)slot).LocalUser; listSlot.PersistentSelf = false; ((IChangeable)array).Changed += ArrayDriveCheck; } else { LocaleString val4 = LocaleString.op_Implicit("(array is driven)"); ui.Text(ref val4, true, (Alignment?)null, true, (string)null); } if (flag3) { ((IChangeable)array).Changed += ArrayChanged; } return false; void ArrayDriveCheck(IChangeable changeable) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (((ILinkable)(ISyncArray)changeable).IsDriven) { listSlot.DestroyChildren(false, true, false, (Predicate)null); CollectionExtensions.Do((global::System.Collections.Generic.IEnumerable)Enumerable.ToArray((global::System.Collections.Generic.IEnumerable)(object)((ContainerWorker)(object)listSlot).Components), (Action)delegate(Component c) { ((ComponentBase)(object)c).Destroy(); }); ((SyncField)(object)((ContainerWorker)(object)listSlot).AttachComponent(true, (Action)null).MinHeight).Value = 24f; UIBuilder val5 = new UIBuilder(listSlot, listSlot); RadiantUI_Constants.SetupEditorStyle(val5, false); LocaleString val6 = LocaleString.op_Implicit("(array is driven)"); val5.Text(ref val6, true, (Alignment?)null, true, (string)null); Slot obj = proxySlot; if (obj != null) { obj.Destroy(); } ((IChangeable)array).Changed -= ArrayDriveCheck; } } } private static void SetLinearPoint(Point point, LinearKey arrayElem) where T : IEquatable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ((SyncField)(object)point.Position).Value = arrayElem.time; ((SyncField)(object)point.Value).Value = arrayElem.value; } private static void SetCurvePoint(Point point, CurveKey arrayElem) where T : IEquatable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ((SyncField)(object)point.Position).Value = arrayElem.time; ((SyncField)(object)point.Value).Value = arrayElem.value; } private static void SetTubePoint(Point point, TubePoint arrayElem) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) ((SyncField)(object)point.Position).Value = ((TubePoint)(ref arrayElem)).radius; ((SyncField)(object)point.Value).Value = ((TubePoint)(ref arrayElem)).position; } private static void ArrayChanged(IChangeable changeable) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_03c6: Unknown result type (might be due to invalid IL or missing references) Log.LogDebug((object)"Array Changed"); ISyncArray val = (ISyncArray)changeable; if (((ILinkable)val).IsDriven) { ((IChangeable)val).Changed -= ArrayChanged; return; } string text = $"{((ISyncMember)val).Name}-{((IWorldElement)val).ReferenceID}-Proxy"; Slot val2 = ((IWorldElement)val).World.AssetsSlot.FindChild(text); if (val2 == null) { return; } ISyncList val3 = null; ComponentEnumerator enumerator = ((ContainerWorker)(object)val2).Components.GetEnumerator(); try { while (enumerator.MoveNext()) { Component current = enumerator.Current; if (((object)current).GetType().IsGenericType && ((object)current).GetType().GetGenericTypeDefinition() == typeof(ValueMultiplexer<>)) { ISyncMember syncMember = ((Worker)current).GetSyncMember("Values"); val3 = (ISyncList)(object)((syncMember is ISyncList) ? syncMember : null); _skipListChanges = true; World world = ((IWorldElement)val3).World; object obj = <>c.<>9__24_0; if (obj == null) { Action val4 = delegate { _skipListChanges = false; }; <>c.<>9__24_0 = val4; obj = (object)val4; } world.RunSynchronously((Action)obj, false, (IUpdatable)null, false); SyncElementListHelper.EnsureExactElementCount(val3, val.Count); for (int num = 0; num < val.Count; num++) { ((IField)val3.GetElement(num)).BoxedValue = val.GetElement(num); } } else if (((object)current).GetType().IsGenericType && ((object)current).GetType().GetGenericTypeDefinition() == typeof(ReferenceMultiplexer<>)) { ISyncMember syncMember2 = ((Worker)current).GetSyncMember("References"); val3 = (ISyncList)(object)((syncMember2 is ISyncList) ? syncMember2 : null); _skipListChanges = true; World world2 = ((IWorldElement)val3).World; object obj2 = <>c.<>9__24_1; if (obj2 == null) { Action val5 = delegate { _skipListChanges = false; }; <>c.<>9__24_1 = val5; obj2 = (object)val5; } world2.RunSynchronously((Action)obj2, false, (IUpdatable)null, false); SyncElementListHelper.EnsureExactElementCount(val3, val.Count); for (int num2 = 0; num2 < val.Count; num2++) { ((ISyncRef)val3.GetElement(num2)).Target = (IWorldElement)val.GetElement(num2); } } else { if (!((object)current).GetType().IsGenericType || !(((object)current).GetType().GetGenericTypeDefinition() == typeof(ValueGradientDriver<>))) { continue; } ISyncMember syncMember3 = ((Worker)current).GetSyncMember("Points"); val3 = (ISyncList)(object)((syncMember3 is ISyncList) ? syncMember3 : null); _skipListChanges = true; World world3 = ((IWorldElement)val3).World; object obj3 = <>c.<>9__24_2; if (obj3 == null) { Action val6 = delegate { _skipListChanges = false; }; <>c.<>9__24_2 = val6; obj3 = (object)val6; } world3.RunSynchronously((Action)obj3, false, (IUpdatable)null, false); SyncElementListHelper.EnsureExactElementCount(val3, val.Count); global::System.Type genericParameter; bool flag = TryGetGenericParameter(typeof(SyncLinear<>), ((object)val).GetType(), out genericParameter); global::System.Type genericParameter2; bool flag2 = TryGetGenericParameter(typeof(SyncCurve<>), ((object)val).GetType(), out genericParameter2); if (!TryGetGenericParameter(typeof(SyncArray<>), ((object)val).GetType(), out global::System.Type genericParameter3)) { break; } global::System.Type type = genericParameter3; for (int num3 = 0; num3 < val.Count; num3++) { ISyncMember element = val3.GetElement(num3); if (flag && SupportsLerp(genericParameter)) { ((MethodBase)_setLinearPoint.MakeGenericMethod(new global::System.Type[1] { genericParameter })).Invoke((object)null, new object[2] { element, val.GetElement(num3) }); } else if (flag2 && SupportsLerp(genericParameter2)) { ((MethodBase)_setCurvePoint.MakeGenericMethod(new global::System.Type[1] { genericParameter2 })).Invoke((object)null, new object[2] { element, val.GetElement(num3) }); } else if (type == typeof(TubePoint)) { SetTubePoint((Point)(object)element, (TubePoint)val.GetElement(num3)); } } } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } private static Component GetOrAttachComponent(Slot targetSlot, global::System.Type type, out bool attachedNew) { attachedNew = false; Component val = ((ContainerWorker)(object)targetSlot).GetComponent(type, false); if (val == null) { val = ((ContainerWorker)(object)targetSlot).AttachComponent(type, true, (Action)null); attachedNew = true; } return val; } private static bool SupportsLerp(global::System.Type type) { return Traverse.Create(typeof(Coder<>).MakeGenericType(new global::System.Type[1] { type })).Property("SupportsLerp", (object[])null).Value; } private static bool TryGetGenericParameter(global::System.Type baseType, global::System.Type concreteType, out global::System.Type? genericParameter) { genericParameter = null; if (concreteType == null || baseType == null || !baseType.IsGenericType) { return false; } if (concreteType.IsGenericType && concreteType.GetGenericTypeDefinition() == baseType) { global::System.Type[] genericArguments = concreteType.GetGenericArguments(); if (genericArguments.Length != 0) { genericParameter = genericArguments[0]; return true; } } return TryGetGenericParameter(baseType, concreteType.BaseType, out genericParameter); } } internal static ManualLogSource Log; internal static ConfigEntry ArrayEditorEnabled; internal static ConfigEntry ArrayEditorListUIImprovemts; public override void Load() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown Log = ((BasePlugin)this).Log; ArrayEditorEnabled = ((BasePlugin)this).Config.Bind("Array Editor", "Enable ArrayEditor", true, new ConfigDescription("Enables the Array Editor Mod.", (AcceptableValueBase)null, global::System.Array.Empty())); ArrayEditorListUIImprovemts = ((BasePlugin)this).Config.Bind("Array Editor", "Enable List UI Improvements", true, new ConfigDescription("Enables some List UI changes to make it a bit more nicer to use.", (AcceptableValueBase)null, global::System.Array.Empty())); try { if (ArrayEditorEnabled.Value) { ((BasePlugin)this).HarmonyInstance.PatchAll(); } Log.LogInfo((object)"BepisArrayEditor Loaded!"); } catch (global::System.Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BepisArrayEditor failed to patch: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } log.LogError(val); } ArrayEditorEnabled.SettingChanged += (EventHandler)([CompilerGenerated] (object? e, EventArgs s) => { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (ArrayEditorEnabled.Value) { try { Log.LogInfo((object)"Enabling BepisArrayEditor"); ((BasePlugin)this).HarmonyInstance.PatchAll(); return; } catch (global::System.Exception ex2) { ManualLogSource log2 = Log; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("BepisArrayEditor failed to patch: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2); } log2.LogError(val2); return; } } Log.LogInfo((object)"Disabling BepisArrayEditor"); ((BasePlugin)this).HarmonyInstance.UnpatchSelf(); }); } } public static class PluginMetadata { public const string GUID = "xyz.gyztormizirath.BepisArrayEditor"; public const string NAME = "BepisArrayEditor"; public const string VERSION = "1.0.2"; public const string AUTHORS = "Gyztor Mizirath"; public const string REPOSITORY_URL = "https://github.com/Gyztor/BepisArrayEditor"; }