diff --git a/src/SHME.ExternalTool.Guts/CollectionExtensions.cs b/src/SHME.ExternalTool.Guts/CollectionExtensions.cs index df484d1..7f90f40 100644 --- a/src/SHME.ExternalTool.Guts/CollectionExtensions.cs +++ b/src/SHME.ExternalTool.Guts/CollectionExtensions.cs @@ -1,6 +1,7 @@ using SHME.ExternalTool.Graphics; using System; using System.Collections.Generic; +using System.Linq; namespace SHME.ExternalTool; @@ -47,4 +48,26 @@ public static int IndexFromKey(this SortedDictionary return -1; } + + // These SelectX methods are just a hack to avoid creating anonymous + // methods in the main tool assembly whose signatures contain types + // defined in an external assembly. PointOfInterest or Trigger, for + // example, are defined in SHME.ExternalTool.Guts. Under Mono in + // Linux, when BizHawk tries to load the main plugin assembly, Mono + // tries to load the types it finds in method signatures, failing on + // the aforementioned examples (among others) because the DLLs found + // in the ExternalTool attribute's LoadAssemblyFiles array haven't + // been loaded yet. This is a bit roundabout, but still effective. + public static IEnumerable SelectItem2(this IEnumerable<(TItem1, TItem2)> enumerable) + { + return enumerable.Select((tuple) => tuple.Item2); + } + public static IEnumerable SelectManyItem2(this IEnumerable<(TItem1, IList)> enumerable) + { + return enumerable.SelectMany((tuple) => tuple.Item2); + } + public static IEnumerable<(TItem1, TItem2)> SelectTuple(this IEnumerable<(TItem1, TItem2)> enumerable) + { + return enumerable.Select((tuple) => tuple); + } } diff --git a/src/SHME.ExternalTool/UI/CustomMainForm.cs b/src/SHME.ExternalTool/UI/CustomMainForm.cs index faecff9..ffffd60 100644 --- a/src/SHME.ExternalTool/UI/CustomMainForm.cs +++ b/src/SHME.ExternalTool/UI/CustomMainForm.cs @@ -445,11 +445,10 @@ private void DrawOverlayCommonPre(ref Matrix4x4 matrix, ref Vector3 position, re { Guts.Camera.GetVisibleRenderables( ref Guts.VisibleRenderables, [ - .. Guts.Pois.Values - .Select((tuple) => tuple.Item2), + .. Guts.Pois.Values.SelectItem2(), .. Guts.CameraPaths.Values - .Select((path) => path) - .SelectMany((tuple) => tuple.Item2), + .SelectTuple() + .SelectManyItem2(), .. Guts.Gems, .. Guts.Lines]); }