internal void SetActiveColors()
            {
                Color finalColor = _color ?? _globalColor ?? _color_Original;
                ParametricBoxFrameController obstacleFrame = _obstacleFrameAccessor(ref _stretchableObstacle);

                if (finalColor == obstacleFrame.color)
                {
                    return;
                }

                ParametricBoxFakeGlowController obstacleFakeGlow = _obstacleFakeGlowAccessor(ref _stretchableObstacle);

                MaterialPropertyBlockController[] materialPropertyBlockControllers = _materialPropertyBlockControllersAccessor(ref _stretchableObstacle);
                obstacleFrame.color = finalColor;
                obstacleFrame.Refresh();
                obstacleFakeGlow.color = finalColor;
                obstacleFakeGlow.Refresh();
                Color value = finalColor * _addColorMultiplierAccessor(ref _stretchableObstacle);

                value.a = 0f;
                float obstacleCoreLerpToWhiteFactor = _obstacleCoreLerpToWhiteFactorAccessor(ref _stretchableObstacle);

                foreach (MaterialPropertyBlockController materialPropertyBlockController in materialPropertyBlockControllers)
                {
                    materialPropertyBlockController.materialPropertyBlock.SetColor(_addColorID, value);
                    materialPropertyBlockController.materialPropertyBlock.SetColor(_tintColorID, Color.Lerp(finalColor, Color.white, obstacleCoreLerpToWhiteFactor));
                    materialPropertyBlockController.ApplyChanges();
                }
            }
        private void UpdateWallColor(Color color)
        {
            foreach (ObstacleController wall in beatmapObjectManager.activeObstacleControllers)
            {
                StretchableObstacle stretchable = Helper.GetValue <StretchableObstacle>(wall, "_stretchableObstacle");

                ParametricBoxFrameController frame = Helper.GetValue <ParametricBoxFrameController>(stretchable, "_obstacleFrame");

                stretchable.SetSizeAndColor(frame.width, frame.height, frame.length, color);
            }
        }
        private static void Postfix(ref ObstacleController __instance, StretchableObstacle ____stretchableObstacle, ref SimpleColorSO ____color)
        {
            try
            {
                CustomMaterial customMaterial = MaterialAssetLoader.CustomMaterialObjects[MaterialAssetLoader.SelectedMaterial];
                if (customMaterial.FileName != "DefaultMaterials")
                {
                    Renderer mesh  = __instance.gameObject.GetComponentInChildren <Renderer>();
                    Color    color = ____color.color;

                    if (customMaterial.Descriptor.Overlay)
                    {
                        GameObject overlay = MeshUtils.CreateOverlay(mesh, customMaterial.MaterialRenderer, customMaterial.Descriptor.OverlayOffset);
                        MaterialUtils.SetMaterialsColor(overlay?.GetComponent <Renderer>().materials, color);
                        if (customMaterial.Descriptor.ReplaceMesh)
                        {
                            MeshUtils.ReplaceMesh(overlay.GetComponent <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                            if (!customMaterial.Descriptor.ReplaceOnlyOverlayMesh)
                            {
                                MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                            }
                        }
                    }
                    else
                    {
                        MaterialUtils.ReplaceRenderer(mesh, customMaterial.MaterialRenderer);
                        MaterialUtils.SetMaterialsColor(mesh?.materials, color);
                        if (customMaterial.Descriptor.ReplaceMesh)
                        {
                            MeshUtils.ReplaceMesh(__instance.gameObject.GetComponentInChildren <MeshFilter>(), customMaterial.MaterialMeshFilter, customMaterial.Descriptor.MeshScaleMultiplier);
                        }
                    }
                }

                if (!Configuration.EnableObstacleFrame)
                {
                    ParametricBoxFrameController frame = ____stretchableObstacle.GetPrivateField <ParametricBoxFrameController>("_obstacleFrame");
                    frame.enabled = false;
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
            }
        }
Beispiel #4
0
        public static void Init(ObstacleController __instance)
        {
            if (ColorController.isNull || !ColorController.instance.useCustomWallColor)
            {
                return;
            }

            Color color = ColorController.instance.wallColor;

            if (Helper.IsRainbow(color))
            {
                color = RainbowController.instance.GetWallColor();
            }

            StretchableObstacle stretchable = Helper.GetValue <StretchableObstacle>(__instance, "_stretchableObstacle");

            ParametricBoxFrameController frame = Helper.GetValue <ParametricBoxFrameController>(stretchable, "_obstacleFrame");

            stretchable.SetSizeAndColor(frame.width, frame.height, frame.length, color);
        }
Beispiel #5
0
        internal ObstacleColorizer(ObstacleControllerBase obstacleController)
        {
            StretchableObstacle stretchableObstacle = obstacleController.GetComponent <StretchableObstacle>();

            _obstacleFrame                    = _obstacleFrameAccessor(ref stretchableObstacle);
            _obstacleFakeGlow                 = _obstacleFakeGlowAccessor(ref stretchableObstacle);
            _addColorMultiplier               = _addColorMultiplierAccessor(ref stretchableObstacle);
            _obstacleCoreLerpToWhiteFactor    = _obstacleCoreLerpToWhiteFactorAccessor(ref stretchableObstacle);
            _materialPropertyBlockControllers = _materialPropertyBlockControllersAccessor(ref stretchableObstacle);

            if (obstacleController is ObstacleController trueObstacleController)
            {
                OriginalColor = _colorManagerAccessor(ref trueObstacleController).obstaclesColor;
            }
            else
            {
                // Fallback
                OriginalColor = Color.white;
            }

            Colorizers.Add(obstacleController, this);
        }
Beispiel #6
0
        private void HandleObstacleDidStartMovementEvent(BeatmapObjectSpawnController obstacleSpawnController, ObstacleController obstacleController)
        {
            try {
                StretchableObstacle             stretchableObstacle = ReflectionUtil.GetField <StretchableObstacle>(obstacleController, "_stretchableObstacle");
                StretchableCube                 stretchableCore     = ReflectionUtil.GetField <StretchableCube>(stretchableObstacle, "_stretchableCore");
                ParametricBoxFrameController    frameController     = ReflectionUtil.GetField <ParametricBoxFrameController>(stretchableObstacle, "_obstacleFrame");
                ParametricBoxFakeGlowController fakeGlowController  = ReflectionUtil.GetField <ParametricBoxFakeGlowController>(stretchableObstacle, "_obstacleFakeGlow");
                float time  = obstacleController.obstacleData.time;
                Color color = ColourManager.GetBarrierColour(time);
                frameController.color    = color;
                fakeGlowController.color = color;
                bool didRecolour = VFX.VFXRainbowBarriers.IsRainbowWalls();

                ChromaHandleBarrierSpawnedEvent?.Invoke(ref stretchableObstacle, ref obstacleSpawnController, ref obstacleController, ref didRecolour);

                if (!didRecolour && color != ColourManager.DefaultBarrierColour && color != Color.clear)
                {
                    RecolourWall(stretchableCore, ColourManager.GetCorrectedBarrierColour(time));
                }
            } catch (Exception e) {
                ChromaLogger.Log(e);
            }
        }