Exemple #1
0
        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);
                _zenjectManager.Add(zen);
                return(zen);
            });

            // Setup Own Zenject Stuff
            var zenjector = new Zenjector("SiraUtil");

            _zenjectManager.Add(zenjector);

            zenjector.OnApp <SiraInstaller>().WithParameters(config);
            zenjector.OnGame <SiraSaberInstaller>();

            zenjector.OnGame <SiraSaberEffectInstaller>()
            .Mutate <SaberBurnMarkArea>((ctx, obj) =>
            {
                var burnArea = obj as SaberBurnMarkArea;
                // Override (or modify) the component BEFORE it's installed
                var siraBurnArea = burnArea.gameObject.AddComponent <SiraSaberBurnMarkArea>();
                ctx.Container.QueueForInject(siraBurnArea);
                ctx.Container.Bind <SaberBurnMarkArea>().To <SiraSaberBurnMarkArea>().FromInstance(siraBurnArea).AsCached();
            })
            .Mutate <SaberBurnMarkSparkles>((ctx, obj) =>
            {
                var burnSparkles     = obj as SaberBurnMarkSparkles;
                var siraBurnSparkles = burnSparkles.gameObject.AddComponent <SiraSaberBurnMarkSparkles>();
                ctx.Container.QueueForInject(siraBurnSparkles);
                ctx.Container.Bind <SaberBurnMarkSparkles>().To <SiraSaberBurnMarkSparkles>().FromInstance(siraBurnSparkles).AsCached();
            })
            .Mutate <ObstacleSaberSparkleEffectManager>((ctx, obj) =>
            {
                var obstacleSparkles     = obj as ObstacleSaberSparkleEffectManager;
                var siraObstacleSparkles = obstacleSparkles.gameObject.AddComponent <SiraObstacleSaberSparkleEffectManager>();
                UnityEngine.Object.Destroy(obstacleSparkles);
                ctx.Container.QueueForInject(siraObstacleSparkles);
                ctx.Container.Bind <ObstacleSaberSparkleEffectManager>().To <SiraObstacleSaberSparkleEffectManager>().FromInstance(siraObstacleSparkles).AsCached();
            })
            .ShortCircuitForMultiplayer();

            zenjector.OnGame <SiraGameInstaller>().ShortCircuitForMultiplayer();
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        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();
        }