예제 #1
0
        private void Inject(ILoggerProvider loggerProvider, LightWithIdManager lightManager)
        {
            name = nameof(DynamicLightingController);

            _logger       = loggerProvider.CreateLogger <DynamicLightingController>();
            _lightManager = lightManager;
        }
예제 #2
0
        /// <summary>
        /// Finds the <see cref="LightWithIdManager"/> of the given <paramref name="environment"/>
        /// </summary>
        /// <param name="environment">Where to search for a <see cref="LightWithIdManager"/></param>
        /// <exception cref="ManagerNotFoundException"></exception>
        internal static LightWithIdManager FindLightWithIdManager(Scene environment)
        {
            LightWithIdManager manager = null;

            void RecursiveFindManager(Transform directParent)
            {
                for (int i = 0; i < directParent.childCount; i++)
                {
                    Transform child = directParent.GetChild(i);
                    if (child.GetComponent <LightWithIdManager>() != null)
                    {
                        manager = child.GetComponent <LightWithIdManager>();
                    }
                    if (child.childCount != 0)
                    {
                        RecursiveFindManager(child);
                    }
                }
            }

            GameObject[] roots = environment.GetRootGameObjects();
            foreach (GameObject root in roots)
            {
                RecursiveFindManager(root.transform);
            }
            if (manager != null)
            {
                return(manager);
            }
            else
            {
                throw new ManagerNotFoundException();
            }
        }
예제 #3
0
 private static void RegisterLight(LightWithIdMonoBehaviour?newLight, LightWithIdManager lightWithIdManager)
 {
     if (newLight != null)
     {
         lightWithIdManager.RegisterLight(newLight);
     }
 }
예제 #4
0
        internal void GameAwake(LightWithIdManager lightManager)
        {
            GetComponent <MeshRenderer>().enabled = false;
            if (GetComponent <MeshFilter>().mesh.vertexCount == 0)
            {
                tubeBloomLight = Instantiate(Prefab);
                tubeBloomLight.transform.parent = transform;
                PlatformManager.SpawnedObjects.Add(tubeBloomLight.gameObject);

                tubeBloomLight.transform.localRotation = Quaternion.identity;
                tubeBloomLight.transform.localPosition = Vector3.zero;
                tubeBloomLight.transform.localScale    = new Vector3(1 / transform.lossyScale.x, 1 / transform.lossyScale.y, 1 / transform.lossyScale.z);

                tubeBloomLight.gameObject.SetActive(false);

                TubeBloomPrePassLightWithId lightWithId = tubeBloomLight.GetComponent <TubeBloomPrePassLightWithId>();
                if (lightWithId)
                {
                    lightWithId.SetField("_tubeBloomPrePassLight", tubeBloomLight);
                    ((LightWithIdMonoBehaviour)lightWithId).SetField("_ID", (int)lightsID);
                    ((LightWithIdMonoBehaviour)lightWithId).SetField("_lightManager", lightManager);
                }

                tubeBloomLight.SetField("_width", width * 2);
                tubeBloomLight.SetField("_length", length);
                tubeBloomLight.SetField("_center", center);
                tubeBloomLight.SetField("_transform", tubeBloomLight.transform);
                tubeBloomLight.SetField("_maxAlpha", 0.1f);
                tubeBloomLight.SetField("_bloomFogIntensityMultiplier", fogIntensityMultiplier);

                ParametricBoxController parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>();
                tubeBloomLight.SetField("_parametricBoxController", parabox);

                Parametric3SliceSpriteController parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>();
                tubeBloomLight.SetField("_dynamic3SliceSprite", parasprite);
                parasprite.Init();
                parasprite.GetComponent <MeshRenderer>().enabled = false;

                SetColorToDefault();
                tubeBloomLight.gameObject.SetActive(true);
            }
            else
            {
                // swap for <3
                PlatformManager.InactiveHeart.SetActive(false);
                iHeartBeatSaber = Instantiate(PlatformManager.InactiveHeart);
                PlatformManager.SpawnedObjects.Add(iHeartBeatSaber);
                iHeartBeatSaber.transform.parent     = transform;
                iHeartBeatSaber.transform.position   = transform.position;
                iHeartBeatSaber.transform.localScale = Vector3.one;
                iHeartBeatSaber.transform.rotation   = transform.rotation;
                InstancedMaterialLightWithId lightWithId = iHeartBeatSaber.GetComponent <InstancedMaterialLightWithId>();
                ((LightWithIdMonoBehaviour)lightWithId).SetField("_ID", (int)lightsID);
                ((LightWithIdMonoBehaviour)lightWithId).SetField("_lightManager", lightManager);
                lightWithId.SetField("_minAlpha", 0f);
                iHeartBeatSaber.GetComponent <MeshFilter>().mesh = GetComponent <MeshFilter>().mesh;
                iHeartBeatSaber.SetActive(true);
            }
        }
예제 #5
0
 public void Construct(IBeatmapObjectCallbackController beatmapObjectCallbackController,
                       LightWithIdManager lightWithIdManager,
                       ColorScheme colorScheme)
 {
     _beatmapObjectCallbackController = beatmapObjectCallbackController;
     _lightWithIdManager = lightWithIdManager;
     _colorScheme        = colorScheme;
 }
예제 #6
0
        private void Inject(ILoggerProvider loggerProvider, LightWithIdManager lightManager, DiContainer container)
        {
            name = nameof(DynamicTubeBloomPrePassLightingController);

            _logger       = loggerProvider.CreateLogger <DynamicTubeBloomPrePassLightingController>();
            _lightManager = lightManager;
            _container    = container;
        }
예제 #7
0
 static public void Postfix(LightWithIdManager ____lighManager)
 {
     if (HasBeenRun)
     {
         return;
     }
     //HasBeenRun = true;
     GameLightManager = ____lighManager;
 }
예제 #8
0
        private void Inject(ILoggerProvider loggerProvider, LightWithIdManager lightManager, ColorManager colorManager, PlayerController playerController)
        {
            _logger           = loggerProvider.CreateLogger <GameplayLightingController>();
            _lightManager     = lightManager;
            _colorManager     = colorManager;
            _playerController = playerController;

            _lightManager.didSetColorForIdEvent += OnSetColorForId;
        }
        /// <summary>
        /// Creates Additional <see cref="LightSwitchEventEffect"/>s<br/>
        /// [May create redundant/duplicate <see cref="LightSwitchEventEffect"/>s!]<br/>
        /// [May cover <see cref="BeatmapEventType"/>s that aren't supposed to be supported anymore!]<br/>
        /// [Possible Semantic Error!]
        /// </summary>
        internal static void CreateAdditionalLightSwitchControllers(LightWithIdManager lightManager)
        {
            LightSwitchEventEffect templateSwitchEffect = Resources.FindObjectsOfTypeAll <LightSwitchEventEffect>().FirstOrDefault();

            for (int i = 6; i < 16; i++)
            {
                //This Component is spawned onto a base game object and not cleaned up by Custom Platforms (in good faith that the game does so for us by unloading the environment scene)
                LightSwitchEventEffect newSwitchEffect = ReflectionUtil.CopyComponent(templateSwitchEffect, typeof(LightSwitchEventEffect), typeof(LightSwitchEventEffect), templateSwitchEffect.gameObject) as LightSwitchEventEffect;
                newSwitchEffect.SetPrivateField("_lightManager", lightManager);
                newSwitchEffect.SetPrivateField("_lightsID", i);
                newSwitchEffect.SetPrivateField("_event", (BeatmapEventType)(i - 1));
            }
        }
예제 #10
0
        public LightWithIdManagerWrapper(LightWithIdManager manager)
        {
            this.manager = manager;

            offColor = new Color(0f, 0f, 0f, 0f);

            //accessible via colors
            Helper.SetValue <LightWithIdManager, Color?[]>(this, "_colors", manager.colors);

            //accessed by chroma and ClearLights
            Helper.SetValue <LightWithIdManager, List <ILightWithId>[]>(this, "_lights", Helper.GetValue <List <ILightWithId>[]>(manager, "_lights"));

            manager.didSetColorForIdEvent += OnDidSetColorForIdEvent;
        }
예제 #11
0
 public void Inject(
     ColorScheme colorScheme,
     LightWithIdManager lightWithIdManager,
     BeatmapObjectCallbackController bocc,
     BeatEffectSpawner beatEffectSpawner,
     IAudioTimeSource timeSource,
     LightSwitchEventEffect[] defaultLights
     )
 {
     this.colorScheme        = colorScheme;
     this.lightWithIdManager = lightWithIdManager;
     this.bocc = bocc;
     this.beatEffectSpawner = beatEffectSpawner;
     this.timeSource        = timeSource;
     this.defaultLights     = defaultLights;
 }
        public static void ChangeColors()
        {
            colorManager = Resources.FindObjectsOfTypeAll <ColorManager>().FirstOrDefault();

            var playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault();

            colorSchemesSettings = playerDataModel.playerData.colorSchemesSettings;

            menuLightsManager = Resources.FindObjectsOfTypeAll <MenuLightsManager>().FirstOrDefault();
            bsLightManager    = Resources.FindObjectsOfTypeAll <LightWithIdManager>().FirstOrDefault();

            var overrideColorScheme = colorSchemesSettings.overrideDefaultColors ? colorSchemesSettings.GetSelectedColorScheme() : colorManager.GetField <ColorSchemeSO>("_defaultColorScheme").colorScheme;

            Utils.AdjustColorBW(overrideColorScheme);

            Plugin.Logger.Info("selected:" + overrideColorScheme.colorSchemeName);

            colorManager.SetPrivateField("_colorScheme", overrideColorScheme);

            SetMenuEnvironmentColors(overrideColorScheme);

            SetLogoColors(overrideColorScheme);
            SetMenuPlayersPlaceColors(overrideColorScheme);

            SetPointerColors(overrideColorScheme);

            SetColoredTextIconColors(overrideColorScheme);
            SetColoredImageColors(overrideColorScheme);

            SetSliderColors(overrideColorScheme);
            SetToggleColors(overrideColorScheme);
            SetAnimationClipColors(overrideColorScheme);
            SetButtonColors(overrideColorScheme);
            SetTMPUGUIColors(overrideColorScheme);
            SetMissionToggleColors(overrideColorScheme);
            SetTableCellColors(overrideColorScheme);
            SetFireWorkColors(overrideColorScheme);

            colorManager.Start();
            menuLightsManager.RefreshColors();

            currentColorScheme = overrideColorScheme;

            Plugin.Logger.Info("applied all colors");
        }
예제 #13
0
        /// <exception cref="ManagerNotFoundException"></exception>
        internal static void FindManager()
        {
            Scene?scene;

            try {
                scene = GetCurrentEnvironment();
            } catch (EnvironmentSceneNotFoundException e) {
                throw new ManagerNotFoundException(e);
            }

            LightWithIdManager manager = null;

            void RecursiveFindManager(GameObject directParent)
            {
                for (int i = 0; i < directParent.transform.childCount; i++)
                {
                    GameObject child = directParent.transform.GetChild(i).gameObject;
                    if (child.GetComponent <LightWithIdManager>() != null)
                    {
                        manager = child.GetComponent <LightWithIdManager>();
                    }
                    if (child.transform.childCount != 0)
                    {
                        RecursiveFindManager(child);
                    }
                }
            }

            GameObject[] roots = scene?.GetRootGameObjects();
            foreach (GameObject root in roots)
            {
                RecursiveFindManager(root);
            }
            if (manager != null)
            {
                LightManager = manager;
            }
            else
            {
                throw new ManagerNotFoundException();
            }
        }
예제 #14
0
 private void OnGameScene()
 {
     lightManager = BeatSaberSearching.FindLightWithIdManager(BeatSaberSearching.GetCurrentEnvironment());
 }
예제 #15
0
 public void Construct(LightWithIdManager lightWithIdManager, [InjectOptional] ColorManager colorManager)
 {
     _lightWithIdManager = lightWithIdManager;
     _colorManager       = colorManager;
 }
예제 #16
0
            private LSEColorManager(MonoBehaviour mono, BeatmapEventType type)
            {
                _lse  = mono;
                _type = type;
                InitializeSOs(mono, "_lightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mLightColor0);
                InitializeSOs(mono, "_highlightColor0", ref _lightColor0, ref _lightColor0_Original, ref _mHighlightColor0);
                InitializeSOs(mono, "_lightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mLightColor1);
                InitializeSOs(mono, "_highlightColor1", ref _lightColor1, ref _lightColor1_Original, ref _mHighlightColor1);

                if (mono is LightSwitchEventEffect lse)
                {
                    InitializeSOs(mono, "_lightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mLightColor0Boost);
                    InitializeSOs(mono, "_highlightColor0Boost", ref _lightColor0Boost, ref _lightColor0Boost_Original, ref _mHighlightColor0Boost);
                    InitializeSOs(mono, "_lightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mLightColor1Boost);
                    InitializeSOs(mono, "_highlightColor1Boost", ref _lightColor1Boost, ref _lightColor1Boost_Original, ref _mHighlightColor1Boost);
                    _supportBoostColor = true;

                    LightWithIdManager lightManager = lse.GetField <LightWithIdManager, LightSwitchEventEffect>("_lightManager");
                    Lights = lightManager.GetField <List <ILightWithId>[], LightWithIdManager>("_lights")[lse.lightsId].ToList();

                    IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >();
                    TrackLaneRingsManager[] managers = Object.FindObjectsOfType <TrackLaneRingsManager>();
                    foreach (ILightWithId light in Lights)
                    {
                        if (light is MonoBehaviour monoBehaviour)
                        {
                            int z = Mathf.RoundToInt(monoBehaviour.transform.position.z);

                            TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>();
                            if (ring != null)
                            {
                                TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0);
                                if (mngr != null)
                                {
                                    z = 1000 + mngr.Rings.IndexOf(ring);
                                }
                            }

                            if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list))
                            {
                                list.Add(light);
                            }
                            else
                            {
                                list = new List <ILightWithId>()
                                {
                                    light
                                };
                                lightsPreGroup.Add(z, list);
                            }
                        }
                    }

                    LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][];
                    int i = 0;
                    foreach (List <ILightWithId> lightList in lightsPreGroup.Values)
                    {
                        if (lightList is null)
                        {
                            continue;
                        }

                        LightsPropagationGrouped[i] = lightList.ToArray();
                        i++;
                    }
                }
            }
예제 #17
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static bool Prefix(LightSwitchEventEffect __instance, BeatmapEventData beatmapEventData, BeatmapEventType ____event, LightWithIdManager ____lightManager)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (TechnicolorConfig.Instance.TechnicolorEnabled && beatmapEventData.type == ____event &&
                beatmapEventData.value > 0 && beatmapEventData.value <= 7)
            {
                if (TechnicolorConfig.Instance.TechnicolorLightsGrouping == TechnicolorLightsGrouping.ISOLATED)
                {
                    ____lightManager.SetColorForId(__instance.lightsId, TechnicolorController.GetTechnicolor(beatmapEventData.value > 3, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle));

                    List <LightWithId>[] lightManagerLights = _lightsWithIdAccessor(ref ____lightManager);
                    List <LightWithId>   lights             = lightManagerLights[__instance.lightsId];
                    for (int i = 0; i < lights.Count; i++)
                    {
                        lights[i].ColorWasSet(TechnicolorController.GetTechnicolor(beatmapEventData.value > 3, beatmapEventData.time + lights[i].GetInstanceID(), TechnicolorConfig.Instance.TechnicolorLightsStyle));
                    }

                    return(false);
                }
                else if (TechnicolorController.TechniLightRandom.NextDouble() < TechnicolorConfig.Instance.TechnicolorLightsFrequency)
                {
                    bool blue = beatmapEventData.value <= 3;
                    switch (TechnicolorConfig.Instance.TechnicolorLightsGrouping)
                    {
                    case TechnicolorLightsGrouping.ISOLATED_GROUP:
                        // ternary operator gore
                        ____event.SetLightingColors(
                            blue ? (Color?)TechnicolorController.GetTechnicolor(false, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle) : null,
                            blue ? null : (Color?)TechnicolorController.GetTechnicolor(true, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle));
                        break;

                    case TechnicolorLightsGrouping.STANDARD:
                    default:
                        Color?t = TechnicolorController.GetTechnicolor(!blue, beatmapEventData.time, TechnicolorConfig.Instance.TechnicolorLightsStyle);
                        LightColorizer.SetAllLightingColors(blue ? null : t, blue ? t : null);
                        break;
                    }
                }
            }

            return(true);
        }
예제 #18
0
 private void Construct(ILogger <DynamicTubeBloomPrePassLightingController> logger, LightWithIdManager lightManager, DiContainer container)
 {
     _logger       = logger;
     _lightManager = lightManager;
     _container    = container;
 }
예제 #19
0
 public void Construct(MaterialSwapper materialSwapper, [InjectOptional] LightWithIdManager lightWithIdManager)
 {
     _materialSwapper    = materialSwapper;
     _lightWithIdManager = lightWithIdManager;
 }
예제 #20
0
        /// <summary>
        /// Steals the heart from the GreenDayScene<br/>
        /// Then De-Serializes the data from the embedded resource heart.mesh onto the GreenDayHeart to make it more visually pleasing<br/>
        /// Also adjusts it position and color.
        /// Now Loads a Light Prefab since the one in the Menu is f****d.
        /// </summary>
        private static void LoadHeartAndLightSource()
        {
            Scene greenDay = SceneManager.LoadScene("GreenDayGrenadeEnvironment", new LoadSceneParameters(LoadSceneMode.Additive));

            SharedCoroutineStarter.instance.StartCoroutine(fuckUnity());
            IEnumerator <WaitUntil> fuckUnity() //did you know loaded scenes are loaded asynchronously, regarless if you use async or not?
            {
                yield return(new WaitUntil(() => { return greenDay.isLoaded; }));

                GameObject root = greenDay.GetRootGameObjects()[0];

                Heart = root.transform.Find("GreenDayCity/armHeartLighting").gameObject;
                Heart.SetActive(false);
                Heart.transform.SetParent(null);
                Heart.name = "<3";
                SceneManager.MoveGameObjectToScene(Heart, SCENE);

                LightSource = root.transform.Find("GlowLineL (2)").gameObject;
                LightSource.SetActive(false);
                LightSource.transform.SetParent(null);
                LightSource.name = "LightSource";
                SceneManager.MoveGameObjectToScene(LightSource, SCENE);
                SceneManager.UnloadSceneAsync("GreenDayGrenadeEnvironment");

                Settings.ShowHeartChanged += Heart.SetActive;

                using Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomFloorPlugin.heart.mesh");
                using StreamReader streamReader     = new StreamReader(manifestResourceStream);

                string meshfile = streamReader.ReadToEnd();

                string[]   dimension1      = meshfile.Split('|');
                string[][] dimension2      = new string[][] { dimension1[0].Split('/'), dimension1[1].Split('/') };
                string[][] string_vector3s = new string[dimension2[0].Length][];

                int i = 0;

                foreach (string string_vector3 in dimension2[0])
                {
                    string_vector3s[i++] = string_vector3.Split(',');
                }

                List <Vector3> vertices  = new List <Vector3>();
                List <int>     triangles = new List <int>();

                foreach (string[] string_vector3 in string_vector3s)
                {
                    vertices.Add(new Vector3(float.Parse(string_vector3[0], NUM_INV), float.Parse(string_vector3[1], NUM_INV), float.Parse(string_vector3[2], NUM_INV)));
                }
                foreach (string s_int in dimension2[1])
                {
                    triangles.Add(int.Parse(s_int, NUM_INV));
                }

                Mesh mesh = new Mesh {
                    vertices  = vertices.ToArray(),
                    triangles = triangles.ToArray()
                };
                Vector3    position = new Vector3(-8f, 25f, 26f);
                Quaternion rotation = Quaternion.Euler(-100f, 90f, 90f);
                Vector3    scale    = new Vector3(25f, 25f, 25f);

                Heart.GetComponent <MeshFilter>().mesh = mesh;
                Heart.transform.position   = position;
                Heart.transform.rotation   = rotation;
                Heart.transform.localScale = scale;

                LightWithIdManager           manager     = FindLightWithIdManager(GetCurrentEnvironment());
                InstancedMaterialLightWithId lightWithId = Heart.GetComponent <InstancedMaterialLightWithId>();

                typeof(LightWithIdMonoBehaviour).GetField("_lightManager", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(lightWithId, manager);

                Heart.SetActive(Settings.ShowHeart);
                Heart.GetComponent <InstancedMaterialLightWithId>().ColorWasSet(Color.magenta);
            }
        }
예제 #21
0
 public void Construct(MaterialSwapper materialSwapper, [Inject(Id = "PostProcessEnabled")] BoolSO postProcessEnabled, [InjectOptional] LightWithIdManager lightWithIdManager)
 {
     _materialSwapper    = materialSwapper;
     _postProcessEnabled = postProcessEnabled;
     _lightWithIdManager = lightWithIdManager;
 }
예제 #22
0
        internal LightColorizer(LightSwitchEventEffect lightSwitchEventEffect, BeatmapEventType beatmapEventType)
        {
            _lightSwitchEventEffect = lightSwitchEventEffect;
            _eventType = beatmapEventType;
            InitializeSO("_lightColor0", 0);
            InitializeSO("_highlightColor0", 0);
            InitializeSO("_lightColor1", 1);
            InitializeSO("_highlightColor1", 1);
            InitializeSO("_lightColor0Boost", 2);
            InitializeSO("_highlightColor0Boost", 2);
            InitializeSO("_lightColor1Boost", 3);
            InitializeSO("_highlightColor1Boost", 3);

            // AAAAAA PROPAGATION STUFFF
            LightWithIdManager lightManager = _lightManagerAccessor(ref lightSwitchEventEffect);

            Lights = _lightsAccessor(ref lightManager)[lightSwitchEventEffect.lightsId].ToList();

            IDictionary <int, List <ILightWithId> > lightsPreGroup = new Dictionary <int, List <ILightWithId> >();

            TrackLaneRingsManager[] managers = UnityEngine.Object.FindObjectsOfType <TrackLaneRingsManager>();
            foreach (ILightWithId light in Lights)
            {
                if (light is MonoBehaviour monoBehaviour)
                {
                    int z = Mathf.RoundToInt(monoBehaviour.transform.position.z);

                    TrackLaneRing ring = monoBehaviour.GetComponentInParent <TrackLaneRing>();
                    if (ring != null)
                    {
                        TrackLaneRingsManager mngr = managers.FirstOrDefault(it => it.Rings.IndexOf(ring) >= 0);
                        if (mngr != null)
                        {
                            z = 1000 + mngr.Rings.IndexOf(ring);
                        }
                    }

                    if (lightsPreGroup.TryGetValue(z, out List <ILightWithId> list))
                    {
                        list.Add(light);
                    }
                    else
                    {
                        list = new List <ILightWithId>()
                        {
                            light
                        };
                        lightsPreGroup.Add(z, list);
                    }
                }
            }

            LightsPropagationGrouped = new ILightWithId[lightsPreGroup.Count][];
            int i = 0;

            foreach (List <ILightWithId> lightList in lightsPreGroup.Values)
            {
                if (lightList is null)
                {
                    continue;
                }

                LightsPropagationGrouped[i] = lightList.ToArray();
                i++;
            }

            // ok we done
            Colorizers.Add(beatmapEventType, this);
        }