public Plugin(Conf conf, IPALogger log, Zenjector zenjector, PluginMetadata metadata) { var config = conf.Generated <Config>(); _harmony = new Harmony(_harmonyID); config.Version = metadata.Version; zenjector .On <PCAppInit>() .Pseudo(Container => { log?.Debug("Initializing Core Bindings"); Container.BindLoggerAsSiraLogger(log); Container.BindInstance(config).AsSingle(); }); zenjector.OnMenu <DisoMenuInstaller>(); zenjector .On <MenuInstaller>() .Register <CommonSoundInstaller>() .Pseudo((ctx, Container) => { if (config.MusicPlayerEnabled) { log?.Debug("Upgrading to our DiPlayer"); var binding = ctx.GetComponent <ZenjectBinding>(); var original = (binding.Components.FirstOrDefault(x => x is SongPreviewPlayer) as SongPreviewPlayer) !; var fader = original.GetComponent <FadeOutSongPreviewPlayerOnSceneTransitionStart>(); var focus = original.GetComponent <SongPreviewPlayerPauseOnInputFocusLost>(); var newPlayer = original.Upgrade <SongPreviewPlayer, DisoPreviewPlayer>(); Container.QueueForInject(newPlayer); Container.Unbind <SongPreviewPlayer>(); Container.Bind(typeof(SongPreviewPlayer), typeof(DisoPreviewPlayer)).To <DisoPreviewPlayer>().FromInstance(newPlayer).AsSingle(); fader.SetField <FadeOutSongPreviewPlayerOnSceneTransitionStart, SongPreviewPlayer>("_songPreviewPlayer", newPlayer); focus.SetField <SongPreviewPlayerPauseOnInputFocusLost, SongPreviewPlayer>("_songPreviewPlayer", newPlayer); } log?.Debug("Exposing UI Audio Manager"); var audioManager = ctx.GetRootGameObjects().ElementAt(0).GetComponentInChildren <BasicUIAudioManager>(); Container.Bind <BasicUIAudioManager>().FromInstance(audioManager).AsSingle(); var gameObject = new GameObject("Audio Sourcer"); var mixer = audioManager.GetField <AudioSource, BasicUIAudioManager>("_audioSource").outputAudioMixerGroup; var clone = gameObject.AddComponent <AudioSource>(); clone.outputAudioMixerGroup = mixer; Container.BindInstance(clone).WithId("audio.sourcer").AsSingle(); }) .Initialized((ctx, Container) => { var manager = Container.ResolveId <SiraUtil.Interfaces.IRegistrar <AudioClip> >(nameof(Managers.DiClickManager)); }); }
public void Init(IPALogger _logger, Zenjector zenjector) { Instance = this; Logger = _logger; Logger.Debug("Logger initialized."); #if DEBUG zenjector.OnApp <TestInstaller>(); //zenjector.OnGame<TestInstaller>().Expose<ScoreController>(); #endif webSocketServer = new Server.Server(); zenjector.OnGame <ClientInstaller>(false); zenjector.On <GameCoreSceneSetup>().Pseudo((_) => {}).Expose <ScoreUIController>(); }
public Plugin(Conf conf, IPALogger logger, Zenjector zenjector) { Log = logger; var config = conf.Generated <Config>(); zenjector .On <MenuInstaller>() .Pseudo((Container) => { Container.BindInstance(config); Container.BindInterfacesTo <DiffdelController>().AsSingle(); }) .Mutate <StandardLevelDetailViewController>((ctx, levelDetailViewController) => { var levelDetail = Accessors.LevelDetailView(ref levelDetailViewController); var levelParams = Accessors.ParamsPanel(ref levelDetail); Accessors.NPSText(ref levelParams) = Accessors.NPSText(ref levelParams).Upgrade <TextMeshProUGUI, ButtonText>(); Accessors.DifficultySegment(ref levelDetail) = Accessors.DifficultySegment(ref levelDetail).Upgrade <BeatmapDifficultySegmentedControlController, DiffdelDifficultyControlController>(); }); }
public Plugin(IPA.Config.Config conf, IPALogger logger, PluginMetadata metadata) { Log = logger; _pluginMetadata = metadata; Config config = conf.Generated <Config>(); Harmony = new Harmony("dev.auros.sirautil"); // Set Config Verison config.Version = metadata.Version; // Setup Zenjector _zenjectManager = new ZenjectManager(); PluginInitInjector.AddInjector(typeof(Zenjector), (prev, __, meta) => { if (prev != null) { return(prev); } var zen = new Zenjector(meta.Id, meta); _zenjectManager.Add(zen); return(zen); }); // Setup Own Zenject Stuff var zenjector = new Zenjector("SiraUtil", metadata); _zenjectManager.Add(zenjector); zenjector.OnApp <SiraInstaller>().WithParameters(config); zenjector.OnGame <SiraSaberInstaller>(false).ShortCircuitForTutorial(); zenjector.OnMenu <SiraMenuInstaller>(); zenjector.OnGame <SiraSaberEffectInstaller>() .Mutate <SaberBurnMarkArea>(InstallSaberArea) .Mutate <SaberBurnMarkSparkles>(InstallSaberSparkles) .Mutate <ObstacleSaberSparkleEffectManager>(InstallObstacleEffectManager) .Expose <SaberClashEffect>() .ShortCircuitForMultiplayer(); zenjector.OnGame <SiraGameLevelInstaller>() .Mutate <PrepareLevelCompletionResults>((ctx, completionResults) => { if (!ctx.Container.HasBinding <Submission>()) { ctx.Container.BindInterfacesAndSelfTo <Submission>().AsSingle(); } var binding = completionResults.GetComponent <ZenjectBinding>(); var siraCompletionResults = completionResults.Upgrade <PrepareLevelCompletionResults, Submission.SiraPrepareLevelCompletionResults>(); binding.SetField("_ifNotBound", true); ctx.Container.QueueForInject(siraCompletionResults); ctx.Container.Unbind(typeof(PrepareLevelCompletionResults)); ctx.Container.Bind <PrepareLevelCompletionResults>().To <Submission.SiraPrepareLevelCompletionResults>().FromInstance(siraCompletionResults).AsCached(); }).OnlyForStandard(); zenjector.OnGame <SiraGameLevelInstaller>() .Mutate <MissionLevelFinishedController>((ctx, controller) => { if (!ctx.Container.HasBinding <Submission>()) { ctx.Container.BindInterfacesAndSelfTo <Submission>().AsSingle(); } var siraController = controller.Upgrade <MissionLevelFinishedController, Submission.SiraMissionLevelFinishedController>(); ctx.Container.QueueForInject(siraController); ctx.AddInjectable(siraController); }).OnlyForCampaigns(); zenjector.OnGame <SiraGameInstaller>(true).ShortCircuitForMultiplayer(); zenjector.On <GameplayCoreInstaller>().Pseudo(Container => { if (System.DateTime.Now.Month == 4 && System.DateTime.Now.Day == 1 && AprilFools.maxInSession >= AprilFools.sessionTrack) { Container.BindInterfacesTo <AprilFools>().AsSingle(); } }).OnlyForStandard(); // multi specific for toni zenjector.OnGame <SiraMultiGameInstaller>(false) .Mutate <SaberBurnMarkArea>(InstallSaberArea) .Mutate <SaberBurnMarkSparkles>(InstallSaberSparkles) .Mutate <ObstacleSaberSparkleEffectManager>(InstallObstacleEffectManager) .Expose <SaberClashEffect>().OnlyForMultiplayer(); }
public Plugin(IPA.Config.Config conf, IPALogger logger, PluginMetadata metadata) { Log = logger; Config config = conf.Generated <Config>(); Harmony = new Harmony("dev.auros.sirautil"); // Set Config Verison config.Version = metadata.Version; // Setup Zenjector _zenjectManager = new ZenjectManager(); PluginInitInjector.AddInjector(typeof(Zenjector), (prev, __, meta) => { if (prev != null) { return(prev); } var zen = new Zenjector(meta.Id, meta); _zenjectManager.Add(zen); return(zen); }); // Setup Own Zenject Stuff var zenjector = new Zenjector("SiraUtil", metadata); _zenjectManager.Add(zenjector); zenjector.OnApp <SiraInstaller>().WithParameters(config); zenjector.On <MenuInstaller>().Pseudo(Container => { Container.BindInterfacesTo <Submission.Display>().AsSingle(); Container.Resolve <CanvasContainer>().CurvedCanvasTemplate = Container.Resolve <MainMenuViewController>().GetComponent <Canvas>(); }); zenjector.OnGame <SiraSaberInstaller>(); zenjector.OnGame <SiraSaberEffectInstaller>() .Mutate <SaberBurnMarkArea>(InstallSaberArea) .Mutate <SaberBurnMarkSparkles>(InstallSaberSparkles) .Mutate <ObstacleSaberSparkleEffectManager>(InstallObstacleEffectManager) .Expose <SaberClashEffect>() .ShortCircuitForMultiplayer(); zenjector.OnGame <SiraGameLevelInstaller>() .Mutate <PrepareLevelCompletionResults>((ctx, completionResults) => { var binding = completionResults.GetComponent <ZenjectBinding>(); var siraCompletionResults = completionResults.Upgrade <PrepareLevelCompletionResults, Submission.SiraPrepareLevelCompletionResults>(); binding.SetField("_ifNotBound", true); ctx.Container.QueueForInject(siraCompletionResults); ctx.Container.Unbind(typeof(PrepareLevelCompletionResults)); ctx.Container.Bind <PrepareLevelCompletionResults>().To <Submission.SiraPrepareLevelCompletionResults>().FromInstance(siraCompletionResults).AsCached(); }).OnlyForStandard(); zenjector.OnGame <SiraGameInstaller>(true).ShortCircuitForMultiplayer(); // multi specific for toni zenjector.OnGame <SiraMultiGameInstaller>(false) .Mutate <SaberBurnMarkArea>(InstallSaberArea) .Mutate <SaberBurnMarkSparkles>(InstallSaberSparkles) .Mutate <ObstacleSaberSparkleEffectManager>(InstallObstacleEffectManager) .Expose <SaberClashEffect>().OnlyForMultiplayer(); }