static CustomMoreSongsFlowCoordinator() { try { SongDetailViewController = FieldAccessor <MoreSongsFlowCoordinator, SongDetailViewController> .GetAccessor("_songDetailView"); MoreSongsNavigationController = FieldAccessor <MoreSongsFlowCoordinator, NavigationController> .GetAccessor("_moreSongsNavigationcontroller"); MoreSongsView = FieldAccessor <MoreSongsFlowCoordinator, MoreSongsListViewController> .GetAccessor("_moreSongsView"); DownloadQueueView = FieldAccessor <MoreSongsFlowCoordinator, DownloadQueueViewController> .GetAccessor("_downloadQueueView"); string abortDownloadsMethodName = "AbortAllDownloads"; AbortAllDownloadsMethod = typeof(DownloadQueueViewController).GetMethod(abortDownloadsMethodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (AbortAllDownloadsMethod == null) { throw new MissingMethodException($"Method {abortDownloadsMethodName} does not exist.", abortDownloadsMethodName); } CanCreate = true; } catch (Exception ex) { CanCreate = false; Plugin.log.Error($"Error creating accessors for MoreSongsFlowCoordinator, Downloader will be unavailable in Multiplayer: {ex.Message}"); Plugin.log.Debug(ex); } }
static GetUserInfo() { try { AccessPlatformUserModel = FieldAccessor <PlatformLeaderboardsModel, IPlatformUserModel> .GetAccessor("_platformUserModel"); } catch (Exception ex) { Logger.log.Error($"Error getting PlatformUserModel, GetUserInfo is unavailable: {ex.Message}"); Logger.log.Debug(ex); } }
public (ValueGetter get, ValueSetter set) GetAccessors(string member) { var access = FieldAccessor <TOwning, TMember> .GetAccessor(member); return( o => { var obj = (TOwning)o; return access(ref obj); }, (o, v) => { var obj = (TOwning)o; var val = (TMember)v; access(ref obj) = val !; } ); }
public static void Setup(MultiplayerResultsViewController resultsView, IBeatmapLevel level) { if (!resultsView) { return; } if (instance == null) { Plugin.log.Debug("Setting up BeatSaverVoting interop..."); var modInfo = IPA.Loader.PluginManager.GetPluginFromId("BeatSaverVoting"); Plugin.log.Debug("Found BeatSaverVoting plugin!"); if (modInfo == null) { return; } UpButton = FieldAccessor <VotingUI, Transform> .GetAccessor("upButton"); DownButton = FieldAccessor <VotingUI, Transform> .GetAccessor("downButton"); LastSong = FieldAccessor <VotingUI, IBeatmapLevel> .GetAccessor("_lastSong"); Plugin.log.Debug("Got accessors"); Assembly votingAssembly = modInfo.Assembly; instance = VotingUI.instance; votingUIHost = new GameObject("VotingUIHost").AddComponent <RectTransform>(); votingUIHost.SetParent(resultsView.transform, false); votingUIHost.anchorMin = Vector2.zero; votingUIHost.anchorMax = Vector2.one; votingUIHost.sizeDelta = Vector2.zero; votingUIHost.anchoredPosition = new Vector2(2.25f, -6f); votingUIHost.SetParent(resultsView.resultsTab, true); BSMLParser.instance.Parse(Utilities.GetResourceContent(votingAssembly, "BeatSaverVoting.UI.votingUI.bsml"), votingUIHost.gameObject, instance); Plugin.log.Debug("Created UI"); UnityEngine.UI.Image upArrow = UpButton(ref instance).transform.Find("Arrow")?.GetComponent <UnityEngine.UI.Image>(); UnityEngine.UI.Image downArrow = DownButton(ref instance).transform.Find("Arrow")?.GetComponent <UnityEngine.UI.Image>(); if (upArrow != null && downArrow != null) { upArrow.color = new Color(0.341f, 0.839f, 0.341f); downArrow.color = new Color(0.984f, 0.282f, 0.305f); } } else { votingUIHost.gameObject.SetActive(true); } LastSong(ref instance) = level; Plugin.log.Debug("Calling GetVotesForMap..."); instance.InvokePrivateMethod("GetVotesForMap", new object[0]); Plugin.log.Debug("Called GetVotesForMap!"); }
private void InitializeSO(string id, int index) { LightSwitchEventEffect lightSwitchEventEffect = _lightSwitchEventEffect; FieldAccessor <LightSwitchEventEffect, ColorSO> .Accessor colorSOAcessor = FieldAccessor <LightSwitchEventEffect, ColorSO> .GetAccessor(id); MultipliedColorSO lightMultSO = (MultipliedColorSO)colorSOAcessor(ref lightSwitchEventEffect); Color multiplierColor = _multiplierColorAccessor(ref lightMultSO); SimpleColorSO lightSO = _baseColorAccessor(ref lightMultSO); _originalColors[index] = lightSO.color; MultipliedColorSO mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); _multiplierColorAccessor(ref mColorSO) = multiplierColor; SimpleColorSO sColorSO; if (_simpleColorSOs[index] == null) { sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(lightSO.color); _simpleColorSOs[index] = sColorSO; } else { sColorSO = _simpleColorSOs[index]; } _baseColorAccessor(ref mColorSO) = sColorSO; colorSOAcessor(ref lightSwitchEventEffect) = mColorSO; }
private void InitializeSO(string id, int index, bool highlight = false) { ParticleSystemEventEffect particleSystemEventEffect = _particleSystemEventEffect; FieldAccessor <ParticleSystemEventEffect, ColorSO> .Accessor colorSOAcessor = FieldAccessor <ParticleSystemEventEffect, ColorSO> .GetAccessor(id); MultipliedColorSO lightMultSO = (MultipliedColorSO)colorSOAcessor(ref particleSystemEventEffect); Color multiplierColor = _multiplierColorAccessor(ref lightMultSO); SimpleColorSO lightSO = _baseColorAccessor(ref lightMultSO); MultipliedColorSO mColorSO = ScriptableObject.CreateInstance <MultipliedColorSO>(); _multiplierColorAccessor(ref mColorSO) = multiplierColor; SimpleColorSO sColorSO; if (_simpleColorSOs[index] == null) { sColorSO = ScriptableObject.CreateInstance <SimpleColorSO>(); sColorSO.SetColor(lightSO.color); _simpleColorSOs[index] = sColorSO; } else { sColorSO = _simpleColorSOs[index]; } _baseColorAccessor(ref mColorSO) = sColorSO; if (highlight) { _multipliedHighlightColorSOs[index] = mColorSO; } else { _multipliedColorSOs[index] = mColorSO; } colorSOAcessor(ref particleSystemEventEffect) = mColorSO; }