コード例 #1
0
        internal static void Prefix(DiContainer container, NoteCutSoundEffect ____noteCutSoundEffectPrefab)
        {
            var settings = container.Resolve <VolumeSettings>();

            GetGoodCutVolume(ref ____noteCutSoundEffectPrefab) = 0.5f * settings.GoodCuts;
            GetBadCutVolume(ref ____noteCutSoundEffectPrefab)  = 0.9f * settings.BadCuts;
        }
コード例 #2
0
 public void OnActiveSceneChanged(Scene prevScene, Scene nextScene)
 {
     Logger.log.Debug(nextScene.name);
     SharedCoroutineStarter.instance.StartCoroutine(LoadAudio());
     if (nextScene.name == "MenuViewControllers")
     {
         basicUIAudioManager = Resources.FindObjectsOfTypeAll <BasicUIAudioManager>().FirstOrDefault();
         if (_clickSounds != null)
         {
             ReflectionUtil.SetField(basicUIAudioManager, "_clickSounds", _clickSounds);
         }
     }
     if (nextScene.name == "GameCore")
     {
         noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
         noteCutSoundEffect        = Resources.FindObjectsOfTypeAll <NoteCutSoundEffect>().FirstOrDefault();
         bombCutSoundEffectManager = Resources.FindObjectsOfTypeAll <BombCutSoundEffectManager>().FirstOrDefault();
         if (_longCutEffectsAudioClips != null)
         {
             ReflectionUtil.SetField(noteCutSoundEffectManager, "_longCutEffectsAudioClips", _longCutEffectsAudioClips);
         }
         if (_shortCutEffectsAudioClips != null)
         {
             ReflectionUtil.SetField(noteCutSoundEffectManager, "_shortCutEffectsAudioClips", _shortCutEffectsAudioClips);
         }
         if (_badCutSoundEffectAudioClips != null)
         {
             ReflectionUtil.SetField(noteCutSoundEffect, "_badCutSoundEffectAudioClips", _badCutSoundEffectAudioClips);
         }
         if (_bombExplosionAudioClips != null)
         {
             ReflectionUtil.SetField(bombCutSoundEffectManager, "_bombExplosionAudioClips", _bombExplosionAudioClips);
         }
     }
 }
        public static CustomNoteCutSoundEffect CopyOriginal(NoteCutSoundEffect original)
        {
            var gameObj = Instantiate(original.gameObject);

            gameObj.name = "This is a copy!";
            //gameObj.SetActive(false);
            original = gameObj.GetComponent <NoteCutSoundEffect>();
            var noteCutSoundEffect = (CustomNoteCutSoundEffect)ReflectionUtil.CopyComponent(original, typeof(NoteCutSoundEffect),
                                                                                            typeof(CustomNoteCutSoundEffect), gameObj);

            DestroyImmediate(original);
            noteCutSoundEffect.Awake();
            return(noteCutSoundEffect);
        }
コード例 #4
0
        //Code snippet comes from Taz's NoteHitVolume plugin:
        //https://github.com/taz030485/NoteHitVolume/blob/master/NoteHitVolume/NoteHitVolume.cs
        public static void SetVolume(float hitVolume, float missVolume)
        {
            hitVolume  = Mathf.Clamp01(hitVolume);
            missVolume = Mathf.Clamp01(missVolume);
            var pooled = false;

            if (_noteCutSoundEffect == null)
            {
                var noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
                if (noteCutSoundEffectManager == null)
                {
                    return;
                }
                _noteCutSoundEffect =
                    noteCutSoundEffectManager.GetPrivateField <NoteCutSoundEffect>("_noteCutSoundEffectPrefab");
                pooled      = true;
                PrefabFound = true;
            }

            if (_normalVolume == 0)
            {
                _normalVolume     = _noteCutSoundEffect.GetPrivateField <float>("_goodCutVolume");
                _normalMissVolume = _noteCutSoundEffect.GetPrivateField <float>("_badCutVolume");
            }

            var newGoodVolume = _normalVolume * hitVolume;
            var newBadVolume  = _normalMissVolume * missVolume;

            _noteCutSoundEffect.SetPrivateField("_goodCutVolume", newGoodVolume);
            _noteCutSoundEffect.SetPrivateField("_badCutVolume", newBadVolume);

            if (pooled)
            {
                var pool = Resources.FindObjectsOfTypeAll <NoteCutSoundEffect>();
                foreach (var effect in pool)
                {
                    if (effect.name.Contains("Clone"))
                    {
                        effect.SetPrivateField("_goodCutVolume", newGoodVolume);
                        effect.SetPrivateField("_badCutVolume", newBadVolume);
                    }
                }
            }
        }
コード例 #5
0
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex == 4)
            {
                bool pooled = false;
                if (noteCutSoundEffect == null)
                {
                    var noteCutSoundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().FirstOrDefault();
                    noteCutSoundEffect = ReflectionUtil.GetPrivateField <NoteCutSoundEffect>(noteCutSoundEffectManager, "_noteCutSoundEffectPrefab");
                    pooled             = true;
                }

                if (normalVolume == 0)
                {
                    normalVolume     = ReflectionUtil.GetPrivateField <float>(noteCutSoundEffect, "_goodCutVolume");
                    normalMissVolume = ReflectionUtil.GetPrivateField <float>(noteCutSoundEffect, "_badCutVolume");
                }

                float newGoodVolume = normalVolume * Settings.NoteHitVolume;
                float newBadVolume  = normalMissVolume * Settings.NoteMissVolume;
                ReflectionUtil.SetPrivateField(noteCutSoundEffect, "_goodCutVolume", newGoodVolume);
                ReflectionUtil.SetPrivateField(noteCutSoundEffect, "_badCutVolume", newBadVolume);

                if (pooled)
                {
                    var pool = Resources.FindObjectsOfTypeAll <NoteCutSoundEffect>();
                    foreach (var effect in pool)
                    {
                        if (effect.name.Contains("Clone"))
                        {
                            ReflectionUtil.SetPrivateField(effect, "_goodCutVolume", newGoodVolume);
                            ReflectionUtil.SetPrivateField(effect, "_badCutVolume", newBadVolume);
                        }
                    }
                }
            }
        }
        private static bool Prefix(NoteCutSoundEffectManager __instance, BeatmapObjectData beatmapObjectData, ref AudioTimeSyncController ____audioTimeSyncController,
                                   ref float ____prevNoteATime, ref float ____prevNoteBTime, ref NoteCutSoundEffect ____prevNoteASoundEffect, ref NoteCutSoundEffect ____prevNoteBSoundEffect,
                                   ref NoteCutSoundEffect.Pool ____noteCutSoundEffectPool, ref PlayerController ____playerController, ref float ____beatAlignOffset,
                                   ref RandomObjectPicker <AudioClip> ____randomShortCutSoundPicker, ref RandomObjectPicker <AudioClip> ____randomLongCutSoundPicker,
                                   ref BeatmapObjectSpawnController ____beatmapObjectSpawnController)
        {
            if (beatmapObjectData.beatmapObjectType != BeatmapObjectType.Note)
            {
                return(false);
            }
            NoteData noteData  = (NoteData)beatmapObjectData;
            float    timeScale = ____audioTimeSyncController.timeScale;

            if (noteData.noteType != NoteType.NoteA && noteData.noteType != NoteType.NoteB)
            {
                return(false);
            }
            if ((noteData.noteType == NoteType.NoteA && ((noteData.time > ____prevNoteATime) && noteData.time < ____prevNoteATime + 0.001f)) || (noteData.noteType == NoteType.NoteB && ((noteData.time > ____prevNoteBTime) && noteData.time < ____prevNoteBTime + 0.001f)))
            {
                return(false);
            }
            bool flag = false;

            if (noteData.time < ____prevNoteATime + 0.001f || noteData.time < ____prevNoteBTime + 0.001f)
            {
                if (noteData.noteType == NoteType.NoteA && ____prevNoteBSoundEffect.enabled)
                {
                    ____prevNoteBSoundEffect.volumeMultiplier = 0.9f;
                    flag = true;
                }
                else if (noteData.noteType == NoteType.NoteB && ____prevNoteASoundEffect.enabled)
                {
                    ____prevNoteASoundEffect.volumeMultiplier = 0.9f;
                    flag = true;
                }
            }
            NoteCutSoundEffect noteCutSoundEffect = ____noteCutSoundEffectPool.Spawn();

            noteCutSoundEffect.transform.SetPositionAndRotation(__instance.transform.localPosition, Quaternion.identity);
            noteCutSoundEffect.didFinishEvent += __instance.HandleCutSoundEffectDidFinish;
            Saber saber = null;

            if (noteData.noteType == NoteType.NoteA)
            {
                ____prevNoteATime        = noteData.time;
                saber                    = ____playerController.leftSaber;
                ____prevNoteASoundEffect = noteCutSoundEffect;
            }
            else if (noteData.noteType == NoteType.NoteB)
            {
                ____prevNoteBTime        = noteData.time;
                saber                    = ____playerController.rightSaber;
                ____prevNoteBSoundEffect = noteCutSoundEffect;
            }
            if (noteData.noteType == NoteType.NoteA || noteData.noteType == NoteType.NoteB)
            {
                bool      flag2            = noteData.timeToPrevBasicNote < ____beatAlignOffset;
                AudioClip audioClip        = flag2 ? ____randomShortCutSoundPicker.PickRandomObject() : ____randomLongCutSoundPicker.PickRandomObject();
                float     volumeMultiplier = 1f;
                if (flag)
                {
                    volumeMultiplier = 0.9f;
                }
                else if (flag2)
                {
                    volumeMultiplier = 0.9f;
                }
                noteCutSoundEffect.Init(audioClip, (double)(noteData.time / timeScale) + ____audioTimeSyncController.dspTimeOffset, ____beatAlignOffset, ____beatmapObjectSpawnController.missedTimeOffset, noteData.timeToPrevBasicNote / timeScale, noteData.timeToNextBasicNote / timeScale, saber, noteData, __instance.handleWrongSaberTypeAsGood, volumeMultiplier, __instance.useTestAudioClip);
            }
            HashSet <NoteCutSoundEffect> activeItems         = ____noteCutSoundEffectPool.activeItems;
            NoteCutSoundEffect           noteCutSoundEffect2 = null;
            float num = float.MaxValue;

            foreach (NoteCutSoundEffect noteCutSoundEffect3 in activeItems)
            {
                if (noteCutSoundEffect3.noteData.time < num)
                {
                    num = noteCutSoundEffect3.noteData.time;
                    noteCutSoundEffect2 = noteCutSoundEffect3;
                }
            }
            if (activeItems.Count > 64)
            {
                noteCutSoundEffect2.StopPlayingAndFinish();
            }
            return(false);
        }