示例#1
0
        Color GetSaberColor()
        {
            Color saberCol;

            if (colorManager != null)
            {
                if (isLeft)
                {
                    saberCol = colorManager.ColorForSaberType(Saber.SaberType.SaberA);
                }
                else
                {
                    saberCol = colorManager.ColorForSaberType(Saber.SaberType.SaberB);
                }
            }
            else
            {
                if (isLeft)
                {
                    saberCol = new Color(0.659f, 0.125f, 0.125f, 1);
                }
                else
                {
                    saberCol = new Color(0.125f, 0.392f, 0.659f, 1);
                }
            }

            return(saberCol);
        }
 internal void Init(ParticleSystem sparkleParticleSystem, ParticleSystem glowParticleSystem, ColorManager colorManager)
 {
     _sparkleParticleSystem            = sparkleParticleSystem;
     _glowParticleSystem               = glowParticleSystem;
     _colors[0]                        = colorManager.ColorForSaberType(SaberType.SaberA);
     _colors[1]                        = colorManager.ColorForSaberType(SaberType.SaberB);
     SaberColorizer.SaberColorChanged += OnSaberColorChanged;
 }
示例#3
0
        public async Task <bool> Init(Saber saber)
        {
            _siraSaber = _saberFactory.Create();

            OriginalSaberModel = await GetSaberModel(saber);

            if (!OriginalSaberModel)
            {
                Object.DestroyImmediate(_siraSaber.gameObject);
                return(false);
            }

            _siraSaber.ChangeType(saber.saberType);
            _siraSaber.Saber.ChangeColorInstant(_colorManager.ColorForSaberType(saber.saberType));

            TrickModel      = _siraSaber.gameObject;
            _saberTransform = _siraSaber.transform;

            TrickModel.name = $"TrickModel {saber.saberType}";
            AddRigidbody(TrickModel);

            TrickModel.SetActive(false);

            if (!_config.HitNotesDuringTrick || _isMultiplayer)
            {
                _siraSaber.Saber.disableCutting = true;
            }

            return(true);
        }
示例#4
0
        private void Start()
        {
            List <LightWithId>[] lightsWithId = _lightManager.GetPrivateField <List <LightWithId>[]>("_lights");
            int maxLightId = _lightManager.GetPrivateField <int>("kMaxLightId");

            _lights = new List <Light> [maxLightId + 1];

            for (int id = 0; id < lightsWithId.Length; id++)
            {
                if (lightsWithId[id] == null)
                {
                    continue;
                }

                foreach (LightWithId lightWithId in lightsWithId[id])
                {
                    Vector3 direction = kOrigin - lightWithId.transform.position;

                    var light = new GameObject("DynamicLight").AddComponent <Light>();

                    light.type        = LightType.Directional;
                    light.color       = Color.black;
                    light.shadows     = LightShadows.None;           // shadows murder fps since there's so many lights being added
                    light.renderMode  = LightRenderMode.ForceVertex; // reduce performance toll
                    light.intensity   = 1f / (direction.sqrMagnitude * 5);
                    light.spotAngle   = 45;
                    light.cullingMask = AvatarLayers.kAllLayersMask;

                    light.transform.SetParent(lightWithId.transform);
                    light.transform.localPosition = Vector3.zero;
                    light.transform.rotation      = Quaternion.LookRotation(direction);

                    if (_lights[id] == null)
                    {
                        _lights[id] = new List <Light>(10);
                    }

                    _lights[id].Add(light);
                }
            }

            _logger.Trace($"Created {_lights.Sum(l => l?.Count)} lights");
            _logger.Trace($"Maximum intensity: {_lights.Where(l => l != null).SelectMany(l => l).Sum(l => l.intensity)}");

            AddPointLight(_colorManager.ColorForSaberType(SaberType.SaberA), _playerController.leftSaber.transform);
            AddPointLight(_colorManager.ColorForSaberType(SaberType.SaberB), _playerController.rightSaber.transform);
        }
示例#5
0
        private IEnumerator WaitForSabers(GameObject saberRoot)
        {
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Any()));

            if (Configuration.TrailType == TrailType.None)
            {
                HideVanillaTrails();
            }

            IEnumerable <Saber> defaultSabers = FindObjectsOfType <Saber>();

            foreach (Saber defaultSaber in defaultSabers)
            {
                Logger.log.Debug($"Hiding default '{defaultSaber.saberType}'");
                IEnumerable <MeshFilter> meshFilters = defaultSaber.transform.GetComponentsInChildren <MeshFilter>();
                foreach (MeshFilter meshFilter in meshFilters)
                {
                    meshFilter.gameObject.SetActive(!saberRoot);

                    MeshFilter filter = meshFilter.GetComponentInChildren <MeshFilter>();
                    filter?.gameObject.SetActive(!saberRoot);
                }

                Logger.log.Debug($"Attaching custom saber to '{defaultSaber.saberType}'");
                GameObject saber = GetCustomSaberByType(defaultSaber.saberType);
                if (saber)
                {
                    saber.transform.parent   = defaultSaber.transform;
                    saber.transform.position = defaultSaber.transform.position;
                    saber.transform.rotation = defaultSaber.transform.rotation;

                    if (Configuration.TrailType == TrailType.Custom)
                    {
                        HideVanillaTrails();

                        IEnumerable <CustomTrail> customTrails = saber.GetComponents <CustomTrail>();

                        if (customTrails.Count() == 0 && Configuration.OverrideTrailLength)
                        {
                            SetDefaultTrailLength(defaultSaber);
                        }
                        else
                        {
                            foreach (CustomTrail trail in customTrails)
                            {
                                trail.Init(defaultSaber, colorManager);
                            }
                        }
                    }
                    else if (Configuration.TrailType == TrailType.Vanilla && Configuration.OverrideTrailLength)
                    {
                        SetDefaultTrailLength(defaultSaber);
                    }

                    ApplyColorsToSaber(saber, colorManager.ColorForSaberType(defaultSaber.saberType));
                    ApplyScaleToSabers();
                }
            }
        }
示例#6
0
        private static bool Prefix(ColorManager __instance, SaberType type, ref Color __result)
        {
            Color rgbColor = __instance.ColorForSaberType(type);

            Color.RGBToHSV(rgbColor, out float h, out float s, out _);
            __result = Color.HSVToRGB(h, s, 1);
            return(false);
        }
示例#7
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static bool Prefix(ColorManager __instance, SaberType type, ref Color __result)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            Color rgbColor = __instance.ColorForSaberType(type);

            Color.RGBToHSV(rgbColor, out float h, out float s, out _);
            __result = Color.HSVToRGB(h, s, 1);
            return(false);
        }
示例#8
0
        public void DisableSaberColors()
        {
            if (interceptingLightshow != null)
            {
                interceptingLightshow.OnInterceptedSaberColors(null, null, -1f);

                return;
            }

            if (enabled)
            {
                disableSaberColorsOn = -1f;

                SetEnabled();
            }

            useCustomSaberColors = false;

            UpdateSaberColors(colorManager.ColorForSaberType(SaberType.SaberA), colorManager.ColorForSaberType(SaberType.SaberB));
        }
        private void ChangeColors()
        {
            Color color = materialColorType switch
            {
                MaterialColorType.SaberColorA => _colorManager.ColorForSaberType(SaberType.SaberA),
                MaterialColorType.SaberColorB => _colorManager.ColorForSaberType(SaberType.SaberB),
                MaterialColorType.ColorTypeA => _colorManager.ColorForType(ColorType.ColorA),
                MaterialColorType.ColorTypeB => _colorManager.ColorForType(ColorType.ColorB),
                MaterialColorType.ObstacleColor => _colorManager.GetObstacleEffectColor(),
                _ => new Color(0f, 0f, 0f),
            };

            if (_renderer.material.HasProperty(propertyName))
            {
                _renderer.material.SetColor(propertyName, color);
            }
            else
            {
                _renderer.material.color = color;
            }
        }
示例#10
0
        private IEnumerator WaitForSabers(GameObject saberRoot)
        {
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Any()));

            PlayerDataModelSO playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            IEnumerable <Saber> defaultSabers = Resources.FindObjectsOfTypeAll <Saber>();

            foreach (Saber defaultSaber in defaultSabers)
            {
                Logger.log.Debug($"Hiding default '{defaultSaber.saberType}'");
                IEnumerable <MeshFilter> meshFilters = defaultSaber.transform.GetComponentsInChildren <MeshFilter>();
                foreach (MeshFilter meshFilter in meshFilters)
                {
                    meshFilter.gameObject.SetActive(!saberRoot);

                    MeshFilter filter = meshFilter.GetComponentInChildren <MeshFilter>();
                    if (filter)
                    {
                        filter.gameObject.SetActive(!saberRoot);
                    }
                }

                Logger.log.Debug($"Attaching custom saber to '{defaultSaber.saberType}'");
                if (defaultSaber.saberType == Saber.SaberType.SaberA)
                {
                    PrepareSaber(saberRoot, defaultSaber, leftSaber);
                    ApplyColorsToSaber(leftSaber, colorManager.ColorForSaberType(defaultSaber.saberType));
                }
                else if (defaultSaber.saberType == Saber.SaberType.SaberB)
                {
                    PrepareSaber(saberRoot, defaultSaber, rightSaber);
                    ApplyColorsToSaber(rightSaber, colorManager.ColorForSaberType(defaultSaber.saberType));
                }
            }
        }
        private void SetCubeState(NoteController noteController, NoteCutInfo noteCutInfo, NoteData noteData, float cubeRotation)
        {
            float cubeX;
            float cubeY;

            if (_config.PositionFromCubeTransform)
            {
                const float positionScaling = 2.0f;
                var         position        = noteController.noteTransform.position * positionScaling;
                cubeX = position.x;
                cubeY = position.y;
            }
            else
            {
                var positionOffset = new Vector2(-1.5f, 1.5f);
                cubeX = noteData.lineIndex + positionOffset.x;
                cubeY = (int)noteData.noteLineLayer + positionOffset.y;
            }

            _aliveTime = 0f;

            _isDirectional = noteData.cutDirection != NoteCutDirection.Any && noteData.cutDirection != NoteCutDirection.None;

            if (_config.UseCustomColors)
            {
                _color      = noteData.colorType == ColorType.ColorA ? _config.LeftColor : _config.RightColor;
                _saberColor = noteCutInfo.saberType == SaberType.SaberA ? _config.LeftColor : _config.RightColor;
            }
            else
            {
                // This should work due to colors of both type A and B match for their respective saber and blocks
                _color      = _colorManager.ColorForType(noteData.colorType);
                _saberColor = _colorManager.ColorForSaberType(noteCutInfo.saberType);
            }

            _background.color             = _color;
            _blockTransform.localRotation = Quaternion.Euler(0f, 0f, cubeRotation);
            _blockTransform.localPosition = new Vector3(cubeX, cubeY, 0f);

            var arrowAlpha = _isDirectional ? 1f : 0f;

            _arrow.color = Fade(_config.ArrowColor, arrowAlpha);
        }
示例#12
0
        private void CreateTrail(SaberInstance saberInstance)
        {
            _lengthSlider.RemoveEvent(SetLength);
            _widthSlider.RemoveEvent(SetWidth);
            _whitestepSlider.RemoveEvent(SetWhitestep);

            var trailData = saberInstance?.GetTrailData();

            if (trailData == null)
            {
                return;
            }

            _trailPreviewer.Create(saberInstance.GameObject.transform.parent, trailData);

            LoadFromModel(trailData);

            _lengthSlider.AddEvent(SetLength);
            _widthSlider.AddEvent(SetWidth);
            _whitestepSlider.AddEvent(SetWhitestep);

            _trailPreviewer.SetColor(_colorManager.ColorForSaberType(SaberType.SaberA));
        }
示例#13
0
        private void OnNoteCut(INoteController noteController, NoteCutInfo info)
        {
            NoteData data = noteController.noteData;

            if (ShouldDisplayNote(data, info))
            {
                Vector3          center        = noteController.noteTransform.position;
                Vector3          localCutPoint = info.cutPoint - center;
                NoteCutDirection directionType = data.cutDirection;

                if (TwoNoteMode)
                {
                    int             index           = (int)info.saberType;
                    SliceController sliceController = _sliceControllers[index];
                    sliceController.UpdateSlice(localCutPoint, info.cutNormal, directionType);
                }
                else
                {
                    int             index           = 3 * data.lineIndex + (int)data.noteLineLayer;
                    SliceController sliceController = _sliceControllers[index];

                    Color color = UseCustomNoteColors ? _colorManager.ColorForSaberType(info.saberType) : _defaultColors[(int)info.saberType];
                    sliceController.UpdateBlockColor(color);
                    sliceController.UpdateSlice(localCutPoint, info.cutNormal, directionType);
                }

                if (_logNotesCut)
                {
                    Console.WriteLine($"[CutVisualizer] OnNoteCut -------------------------------");
                    Console.WriteLine($"[CutVisualizer] Center: ({center.x} {center.y})");
                    Console.WriteLine($"[CutVisualizer] Cut Normal: ({info.cutNormal.x} {info.cutNormal.y})");
                    Console.WriteLine($"[CutVisualizer] Cut Point: ({info.cutPoint.x} {info.cutPoint.y})");
                    Console.WriteLine($"[CutVisualizer] Cut Local: ({localCutPoint.x} {localCutPoint.y})");
                }
            }
        }
        private IEnumerator WaitForSabers(GameObject saberRoot)
        {
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Any()));

            IEnumerable <Saber> defaultSabers = Resources.FindObjectsOfTypeAll <Saber>();

            foreach (Saber defaultSaber in defaultSabers)
            {
                Logger.log.Debug($"Hiding default '{defaultSaber.saberType}'");
                IEnumerable <MeshFilter> meshFilters = defaultSaber.transform.GetComponentsInChildren <MeshFilter>();
                foreach (MeshFilter meshFilter in meshFilters)
                {
                    meshFilter.gameObject.SetActive(!saberRoot);

                    MeshFilter filter = meshFilter.GetComponentInChildren <MeshFilter>();
                    filter?.gameObject.SetActive(!saberRoot);
                }

                Logger.log.Debug($"Attaching custom saber to '{defaultSaber.saberType}'");
                GameObject saber = GetCustomSaberByType(defaultSaber.saberType);
                if (saber)
                {
                    saber.transform.parent   = defaultSaber.transform;
                    saber.transform.position = defaultSaber.transform.position;
                    saber.transform.rotation = defaultSaber.transform.rotation;

                    IEnumerable <CustomTrail> trails = saber.GetComponents <CustomTrail>();
                    foreach (CustomTrail trail in trails)
                    {
                        trail.Init(defaultSaber, colorManager);
                    }

                    ApplyColorsToSaber(saber, colorManager.ColorForSaberType(defaultSaber.saberType));
                }
            }
        }
示例#15
0
 public static void SetType(this Saber saber, SaberType type, ColorManager colorManager)
 {
     saber.ChangeType(type);
     saber.ChangeColor(colorManager.ColorForSaberType(type));
 }
示例#16
0
 public void Initialize()
 {
     AddPointLight(_colorManager.ColorForSaberType(SaberType.SaberA), _saberManager.leftSaber.transform);
     AddPointLight(_colorManager.ColorForSaberType(SaberType.SaberB), _saberManager.rightSaber.transform);
 }