Ejemplo n.º 1
0
        private void Start()
        {
            _eventManager = gameObject.GetComponent <EventManager>();
            if (_eventManager == null)
            {
                _eventManager = gameObject.AddComponent <EventManager>();
            }

            _eventManager.OnLevelStart.Invoke();

            _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
            if (_scoreController == null)
            {
                return;
            }
            _saberCollisionManager =
                Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
            _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
            _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();

            _scoreController.noteWasCutEvent          += SliceCallBack;
            _scoreController.noteWasMissedEvent       += NoteMissCallBack;
            _scoreController.multiplierDidChangeEvent += MultiplierCallBack;
            _scoreController.comboDidChangeEvent      += ComboChangeEvent;

            _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
            _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;

            _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;

            _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTriggerEvent;
        }
Ejemplo n.º 2
0
        private void InstallObstacleEffectManager(MutationContext ctx, ObstacleSaberSparkleEffectManager obstacleSparkles)
        {
            var siraObstacleSparkles = obstacleSparkles.Upgrade <ObstacleSaberSparkleEffectManager, SiraObstacleSaberSparkleEffectManager>();

            ctx.Container.QueueForInject(siraObstacleSparkles);
            ctx.Container.Bind <ObstacleSaberSparkleEffectManager>().To <SiraObstacleSaberSparkleEffectManager>().FromInstance(siraObstacleSparkles).AsCached();
        }
Ejemplo n.º 3
0
 public static void PostfixStart(ref ObstacleSaberSparkleEffectManager __instance)
 {
     if (!(__instance is SiraObstacleSaberSparkleEffectManager))
     {
         __instance.gameObject.AddComponent <SiraObstacleSaberSparkleEffectManager>();
     }
 }
Ejemplo n.º 4
0
        private void Start()
        {
            _leftEventManager = _leftSaber.GetComponent <EventManager>();
            if (_leftEventManager == null)
            {
                _leftEventManager = _leftSaber.AddComponent <EventManager>();
            }

            _rightEventManager = _rightSaber.GetComponent <EventManager>();
            if (_rightEventManager == null)
            {
                _rightEventManager = _rightSaber.AddComponent <EventManager>();
            }

            _leftEventManager.OnLevelStart.Invoke();
            _rightEventManager.OnLevelStart.Invoke();
            try
            {
                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (_scoreController == null)
                {
                    Console.WriteLine("SCORE CONTROLLER NULL");
                }
                _saberCollisionManager =
                    Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (_saberCollisionManager == null)
                {
                    Console.WriteLine("COLLISION MANAGER NULL");
                }
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (_gameEnergyCounter == null)
                {
                    Console.WriteLine("energery counter null");
                }
                _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (_beatmapCallback == null)
                {
                    Console.WriteLine("BEATMAP CALLBACK NULL");
                }

                _scoreController.noteWasCutEvent          += SliceCallBack;
                _scoreController.noteWasMissedEvent       += NoteMissCallBack;
                _scoreController.multiplierDidChangeEvent += MultiplierCallBack;
                _scoreController.comboDidChangeEvent      += ComboChangeEvent;

                _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;

                _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;

                _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }
        }
 public void Inject(ILoggerProvider loggerProvider, LoadedAvatar avatar, ScoreController scoreController, BeatmapObjectCallbackController beatmapObjectCallbackController, ObstacleSaberSparkleEffectManager sparkleEffectManager, ILevelEndActions levelEndActions)
 {
     _logger          = loggerProvider.CreateLogger <AvatarGameplayEventsPlayer>(avatar.descriptor.name);
     _scoreController = scoreController;
     _levelEndActions = levelEndActions;
     _beatmapObjectCallbackController = beatmapObjectCallbackController;
     _sparkleEffectManager            = sparkleEffectManager;
 }
Ejemplo n.º 6
0
 public static bool PrefixCancelMethod(ref ObstacleSaberSparkleEffectManager __instance)
 {
     if (!(__instance is SiraObstacleSaberSparkleEffectManager))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 7
0
 public void OnDisable()
 {
     if (effectManager != null)
     {
         effectManager.sparkleEffectDidStartEvent -= onSparkleEffectStart;
         effectManager.sparkleEffectDidEndEvent   -= onSparkleEffectEnd;
         effectManager = null;
         haptics       = null;
     }
 }
 public AvatarGameplayEventsPlayer(ILogger <AvatarGameplayEventsPlayer> logger, PlayerAvatarManager avatarManager, ScoreController scoreController, [InjectOptional] ILevelEndActions levelEndActions, [InjectOptional] IMultiplayerLevelEndActionsPublisher multiplayerLevelEndActions, BeatmapObjectCallbackController beatmapObjectCallbackController, ObstacleSaberSparkleEffectManager sparkleEffectManager)
 {
     _logger                          = logger;
     _avatarManager                   = avatarManager;
     _scoreController                 = scoreController;
     _levelEndActions                 = levelEndActions;
     _multiplayerLevelEndActions      = multiplayerLevelEndActions;
     _beatmapObjectCallbackController = beatmapObjectCallbackController;
     _sparkleEffectManager            = sparkleEffectManager;
 }
Ejemplo n.º 9
0
        public void Inject(ILoggerProvider loggerProvider, LoadedAvatar avatar, ScoreController scoreController, BeatmapObjectCallbackController beatmapObjectCallbackController, ILevelEndActions levelEndActions)
        {
            _logger          = loggerProvider.CreateLogger <AvatarGameplayEventsPlayer>(avatar.descriptor.name);
            _scoreController = scoreController;
            _levelEndActions = levelEndActions;
            _beatmapObjectCallbackController = beatmapObjectCallbackController;

            // unfortunately this is not bound through Zenject
            _sparkleEffectManager = FindObjectOfType <ObstacleSaberSparkleEffectManager>();
        }
Ejemplo n.º 10
0
 public BSEvents([InjectOptional] ILevelEndActions levelEndActions, IReadonlyBeatmapData beatmapData, ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager, ScoreController scoreController, BeatmapObjectManager beatmapObjectManager, BeatmapCallbacksController beatmapCallbacksController, ComboController comboController)
 {
     _levelEndActions = levelEndActions;
     _beatmapData     = beatmapData;
     _obstacleSaberSparkleEffectManager = obstacleSaberSparkleEffectManager;
     _scoreController            = scoreController;
     _beatmapObjectManager       = beatmapObjectManager;
     _beatmapCallbacksController = beatmapCallbacksController;
     _comboController            = comboController;
     _bombSubtypeIdentifier      = NoteData.SubtypeIdentifier(ColorType.None);
 }
Ejemplo n.º 11
0
        public SiraSaberEffectManager(IGamePause gamePause, SaberManager saberManager, SaberClashChecker saberClashChecker, SaberBurnMarkArea saberBurnMarkArea,
                                      SaberBurnMarkSparkles saberBurnMarkSparkles, ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager)
        {
            _gamePause = gamePause;
            saberClashChecker.Init(saberManager);
            _saberManagers.Add(saberClashChecker as SiraSaberClashChecker);
            _saberManagers.Add(saberBurnMarkArea as SiraSaberBurnMarkArea);
            _saberManagers.Add(saberBurnMarkSparkles as SiraSaberBurnMarkSparkles);
            _saberManagers.Add(obstacleSaberSparkleEffectManager as SiraObstacleSaberSparkleEffectManager);

            _siraSaberClashChecker = saberClashChecker as SiraSaberClashChecker;
        }
Ejemplo n.º 12
0
 public void Update()
 {
     // Look for the effect manager every tick until we find it
     if (effectManager == null)
     {
         effectManager = UnityEngine.Object.FindObjectOfType <ObstacleSaberSparkleEffectManager>();
         if (effectManager != null)
         {
             foundEffectManager();
         }
     }
 }
Ejemplo n.º 13
0
        public SiraObstacleSaberSparkleEffectManager()
        {
            _sparkleEndEvent   = Utilities.GetEventHandlers <ObstacleSaberSparkleEffectManager, Action <SaberType> >(this, "sparkleEffectDidEndEvent");
            _sparkleStartEvent = Utilities.GetEventHandlers <ObstacleSaberSparkleEffectManager, Action <SaberType> >(this, "sparkleEffectDidStartEvent");
            ObstacleSaberSparkleEffectManager original = GetComponent <ObstacleSaberSparkleEffectManager>();

            foreach (FieldInfo info in original.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                info.SetValue(this, info.GetValue(original));
            }
            Destroy(original);
        }
        private void SceneManagerOnSceneLoaded(Scene newScene, LoadSceneMode mode)
        {
            _eventManager = gameObject.GetComponent <EventManager>();
            if (_eventManager == null)
            {
                _eventManager = gameObject.AddComponent <EventManager>();
            }

            _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
            if (_scoreController == null)
            {
                return;
            }

            //_eventManager.OnLevelStart?.Invoke(); // replaced by LevelStartedEvent()

            _saberCollisionManager =
                Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
            _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
            _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
            _beatmapDataModel = Resources.FindObjectsOfTypeAll <BeatmapDataSO>().FirstOrDefault();

            _scoreController.noteWasCutEvent          += SliceCallBack;
            _scoreController.noteWasMissedEvent       += NoteMissCallBack;
            _scoreController.multiplierDidChangeEvent += MultiplierCallBack;
            _scoreController.comboDidChangeEvent      += ComboChangeEvent;

            if (_saberCollisionManager)
            {
                _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;
            }

            if (_gameEnergyCounter)
            {
                _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;
            }

            if (_beatmapObjectCallbackController)
            {
                _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += OnBeatmapEventDidTriggerEvent;
            }

            _lastNoteId = -1;

            /*if (_beatmapDataModel)
             * {
             *  _beatmapDataModel.beatmapDataDidChangeEvent += BeatmapDataChangedCallback;
             *  BeatmapDataChangedCallback();
             * }*/
        }
Ejemplo n.º 15
0
        internal SiraSaberEffectManager([InjectOptional] IGamePause gamePause, SaberManager saberManager, SaberClashChecker saberClashChecker, SaberBurnMarkArea saberBurnMarkArea,
                                        SaberBurnMarkSparkles saberBurnMarkSparkles, ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager)
        {
            _gamePause    = gamePause;
            _saberManager = saberManager;
            saberClashChecker.Init(saberManager);
            _saberManagers.Add(saberClashChecker as SiraSaberClashChecker);
            _saberManagers.Add(saberBurnMarkArea as SiraSaberBurnMarkArea);
            _saberManagers.Add(saberBurnMarkSparkles as SiraSaberBurnMarkSparkles);
            _saberManagers.Add(obstacleSaberSparkleEffectManager as SiraObstacleSaberSparkleEffectManager);

            _siraSaberClashChecker = saberClashChecker as SiraSaberClashChecker;
            _siraObstacleSaberSparkleEffectManager = obstacleSaberSparkleEffectManager as SiraObstacleSaberSparkleEffectManager;
        }
Ejemplo n.º 16
0
 public BSEvents(BeatmapObjectManager beatmapObjectManager,
                 GameEnergyCounter gameEnergyCounter,
                 GameplayCoreSceneSetupData gameplayCoreSceneSetupData,
                 ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager,
                 ScoreController scoreController,
                 PlayerDataModel playerDataModel,
                 PrepareLevelCompletionResults prepareLevelCompletionResults,
                 IBeatmapObjectCallbackController beatmapObjectCallbackController,
                 IDifficultyBeatmap difficultyBeatmap)
 {
     _beatmapObjectManager              = beatmapObjectManager;
     _gameEnergyCounter                 = gameEnergyCounter;
     _gameplayCoreSceneSetupData        = gameplayCoreSceneSetupData;
     _obstacleSaberSparkleEffectManager = obstacleSaberSparkleEffectManager;
     _scoreController = scoreController;
     _playerDataModel = playerDataModel;
     _prepareLevelCompletionResults   = prepareLevelCompletionResults;
     _beatmapObjectCallbackController = beatmapObjectCallbackController;
     _difficultyBeatmap = difficultyBeatmap;
 }
Ejemplo n.º 17
0
        private void Init()
        {
            try
            {
                _EventManager.OnLevelStart.Invoke();

                _scoreController       = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                _saberCollisionManager =
                    Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();

                UnsubscribeFromEvents();
                SubscribeToEvents();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 18
0
        public EventPlayerInterface(
            PluginConfig pluginConfig,
            [Inject(Id = "LastNoteId")] float lastNoteTime,
            ObstacleSaberSparkleEffectManager obstacleSaberSparkleEffectManager,
            GameEnergyCounter energyCounter,
            ScoreController scoreController,
            BeatmapObjectManager beatmapObjectManager)
        {
            _pluginConfig = pluginConfig;
            _lastNoteTime = lastNoteTime;
            _obstacleSaberSparkleEffectManager = obstacleSaberSparkleEffectManager;
            _energyCounter        = energyCounter;
            _scoreController      = scoreController;
            _beatmapObjectManager = beatmapObjectManager;
            _partEventsList       = new List <PartEvents>();

            if (!_pluginConfig.EnableEvents)
            {
                return;
            }

            // OnSlice LevelEnded Combobreak
            _beatmapObjectManager.noteWasCutEvent    += OnNoteCut;
            _beatmapObjectManager.noteWasMissedEvent += OnNoteMiss;

            // Sabers clashing
            _obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent += SaberStartCollide;
            _obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent   += SaberEndCollide;

            // OnLevelFail
            _energyCounter.gameEnergyDidReach0Event += InvokeOnLevelFail;

            // MultiplierUp
            _scoreController.multiplierDidChangeEvent += MultiplayerDidChange;

            // Combo changed
            _scoreController.comboDidChangeEvent += InvokeComboChanged;
        }
Ejemplo n.º 19
0
        private void AddEvents()
        {
            if (_leftSaber)
            {
                _leftEventManager = _leftSaber.GetComponent <EventManager>();
                if (_leftEventManager == null)
                {
                    _leftEventManager = _leftSaber.AddComponent <EventManager>();
                }
            }

            if (_rightSaber)
            {
                _rightEventManager = _rightSaber.GetComponent <EventManager>();
                if (_rightEventManager == null)
                {
                    _rightEventManager = _rightSaber.AddComponent <EventManager>();
                }
            }

            if (_leftEventManager)
            {
                if (_leftEventManager.OnLevelStart != null)
                {
                    _leftEventManager.OnLevelStart.Invoke();
                }
                else
                {
                    return;
                }
            }

            if (_rightEventManager)
            {
                if (_rightEventManager.OnLevelStart != null)
                {
                    _rightEventManager.OnLevelStart.Invoke();
                }
                else
                {
                    return;
                }
            }

            try
            {
                _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                if (_beatmapObjectSpawnController == null)
                {
                    Logger.Log("Spawn Controller is 'NULL'", LogLevel.Warning);
                    //_beatmapObjectSpawnController = _saberRoot.AddComponent<BeatmapObjectSpawnController>();
                }

                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (_scoreController == null)
                {
                    Logger.Log("Score Controller is 'NULL'", LogLevel.Warning);
                    //_scoreController = _saberRoot.AddComponent<ScoreController>();
                }

                _saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (_saberCollisionManager == null)
                {
                    Logger.Log("Collision Manager is 'NULL'", LogLevel.Warning);
                    //_saberCollisionManager = _saberRoot.AddComponent<ObstacleSaberSparkleEffectManager>();
                }

                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (_gameEnergyCounter == null)
                {
                    Logger.Log("Energy Counter is 'NULL'", LogLevel.Warning);
                    //_gameEnergyCounter = _saberRoot.AddComponent<GameEnergyCounter>();
                }

                _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (_beatmapCallback == null)
                {
                    Logger.Log("Beatmap Callback is 'NULL'", LogLevel.Warning);
                    //_beatmapCallback = _saberRoot.AddComponent<BeatmapObjectCallbackController>();
                }

                _gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault();
                if (_gamePauseManager == null)
                {
                    Logger.Log("GamePauseManager is 'NULL'", LogLevel.Warning);
                    //_gamePauseManager = _saberRoot.AddComponent<GamePauseManager>();
                }

                _playerHeadAndObstacleInteraction = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault();
                if (_playerHeadAndObstacleInteraction == null)
                {
                    Logger.Log("PlayerHeadAndObstacleInteraction is 'NULL'", LogLevel.Warning);
                    //_playerHeadAndObstacleInteraction = _saberRoot.AddComponent<PlayerHeadAndObstacleInteraction>();
                }

                if (_beatmapObjectSpawnController)
                {
                    _beatmapObjectSpawnController.noteWasCutEvent    += SliceCallBack;
                    _beatmapObjectSpawnController.noteWasMissedEvent += NoteMissCallBack;
                }

                if (_scoreController)
                {
                    _scoreController.multiplierDidChangeEvent += MultiplierCallBack;
                    _scoreController.comboDidChangeEvent      += ComboChangeEvent;
                }

                if (_saberCollisionManager)
                {
                    _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                    _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;
                }

                if (_gameEnergyCounter)
                {
                    _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;
                }

                if (_beatmapCallback)
                {
                    _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
                }

                //ReflectionUtil.SetPrivateField(_gamePauseManager, "_gameDidResumeSignal", (Action)OnPauseMenuClosed); //For some reason _gameDidResumeSignal isn't public.
            }
            catch (Exception ex)
            {
                Logger.Log($"{ex.Message}\n{ex.StackTrace}", LogLevel.Error);
                throw;
            }

            try
            {
                var mgs         = GetGameSceneSetup();
                var beatmapData = mgs.GameplayCoreSceneSetupData.difficultyBeatmap.beatmapData;

                var beatmapLinesData = beatmapData.beatmapLinesData;
                var LastTime         = 0.0f;

                for (var i = 0; i < beatmapLinesData.Length; i++)
                {
                    var beatmapObjectsData = beatmapLinesData[i].beatmapObjectsData;
                    for (var j = beatmapObjectsData.Length - 1; j >= 0; j--)
                    {
                        if (beatmapObjectsData[j].beatmapObjectType == BeatmapObjectType.Note)
                        {
                            if (((NoteData)beatmapObjectsData[j]).noteType != NoteType.Bomb)
                            {
                                if (beatmapObjectsData[j].time > LastTime)
                                {
                                    LastNoteId = beatmapObjectsData[j].id;
                                    LastTime   = beatmapObjectsData[j].time;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log($"{ex.Message}\n{ex.StackTrace}", LogLevel.Error);
                throw;
            }
        }
Ejemplo n.º 20
0
        private void AddEvents()
        {
            _leftEventManager = _leftSaber.GetComponent <EventManager>();
            if (_leftEventManager == null)
            {
                _leftEventManager = _leftSaber.AddComponent <EventManager>();
            }

            _rightEventManager = _rightSaber.GetComponent <EventManager>();
            if (_rightEventManager == null)
            {
                _rightEventManager = _rightSaber.AddComponent <EventManager>();
            }

            _leftEventManager.OnLevelStart.Invoke();
            _rightEventManager.OnLevelStart.Invoke();
            try
            {
                _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                if (_beatmapObjectSpawnController == null)
                {
                    Console.WriteLine("SPAWN CONTROLLER NULL");
                    //_beatmapObjectSpawnController = _saberRoot.AddComponent<BeatmapObjectSpawnController>();
                }
                _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (_scoreController == null)
                {
                    Console.WriteLine("SCORE CONTROLLER NULL");
                    //_scoreController = _saberRoot.AddComponent<ScoreController>();
                }
                _saberCollisionManager =
                    Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (_saberCollisionManager == null)
                {
                    Console.WriteLine("COLLISION MANAGER NULL");
                    //_saberCollisionManager = _saberRoot.AddComponent<ObstacleSaberSparkleEffectManager>();
                }
                _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (_gameEnergyCounter == null)
                {
                    Console.WriteLine("energery counter null");
                    //_gameEnergyCounter = _saberRoot.AddComponent<GameEnergyCounter>();
                }
                _beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (_beatmapCallback == null)
                {
                    Console.WriteLine("BEATMAP CALLBACK NULL");
                    //_beatmapCallback = _saberRoot.AddComponent<BeatmapObjectCallbackController>();
                }

                _gamePauseManager = Resources.FindObjectsOfTypeAll <GamePauseManager>().FirstOrDefault();
                if (_gamePauseManager == null)
                {
                    Console.WriteLine("GamePauseManager Null");
                    //_gamePauseManager = _saberRoot.AddComponent<GamePauseManager>();
                }

                _playerHeadAndObstacleInteraction = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault();
                if (_playerHeadAndObstacleInteraction == null)
                {
                    Console.WriteLine("PlayerHeadAndObstacleInteraction Null");
                    //_playerHeadAndObstacleInteraction = _saberRoot.AddComponent<PlayerHeadAndObstacleInteraction>();
                }

                _beatmapObjectSpawnController.noteWasCutEvent    += SliceCallBack;
                _beatmapObjectSpawnController.noteWasMissedEvent += NoteMissCallBack;
                _scoreController.multiplierDidChangeEvent        += MultiplierCallBack;
                _scoreController.comboDidChangeEvent             += ComboChangeEvent;

                _saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                _saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;

                _gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;

                _beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
                //  ReflectionUtil.SetPrivateField(_gamePauseManager, "_gameDidResumeSignal", (Action)OnPauseMenuClosed); //For some reason _gameDidResumeSignal isn't public.
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }

            try
            {
                StandardLevelSceneSetup mgs         = GetGameSceneSetup();
                BeatmapData             beatmapData = mgs.standardLevelSceneSetupData.difficultyBeatmap.beatmapData;

                BeatmapLineData[] beatmapLinesData = beatmapData.beatmapLinesData;
                float             LastTime         = 0.0f;

                for (int i = 0; i < beatmapLinesData.Length; i++)
                {
                    BeatmapObjectData[] beatmapObjectsData = beatmapLinesData[i].beatmapObjectsData;
                    for (int j = beatmapObjectsData.Length - 1; j > 0; j--)
                    {
                        if (beatmapObjectsData[j].beatmapObjectType == BeatmapObjectType.Note)
                        {
                            if (((NoteData)beatmapObjectsData[j]).noteType != NoteType.Bomb)
                            {
                                if (beatmapObjectsData[j].time > LastTime)
                                {
                                    LastNoteId = beatmapObjectsData[j].id;
                                    LastTime   = beatmapObjectsData[j].time;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.Message);
                throw;
            }
        }
Ejemplo n.º 21
0
 static bool Prefix(ActiveObstaclesManager ____activeObstaclesManager, ObstacleSaberSparkleEffect ____obstacleSaberSparkleEffectPefab, PlayerController ____playerController, HapticFeedbackController ____hapticFeedbackController, ref Saber[] ____sabers, ref ObstacleSaberSparkleEffect[] ____effects, ref Transform[] ____effectsTransforms, ref bool[] ____isSystemActive, ref bool[] ____wasSystemActive, ref Vector3[] ____burnMarkPositions, ObstacleSaberSparkleEffectManager __instance)
 {
     if (!PluginConfig.obstacleRumble && PluginConfig.enabled)
     {
         ____wasSystemActive[0] = ____isSystemActive[0];
         ____wasSystemActive[1] = ____isSystemActive[1];
         ____isSystemActive[0]  = false;
         ____isSystemActive[1]  = false;
         foreach (ObstacleController obstacleController in ____activeObstaclesManager.activeObstacleControllers)
         {
             Bounds bounds = obstacleController.bounds;
             for (int i = 0; i < 2; i++)
             {
                 Vector3 vector;
                 if (____sabers[i].isActiveAndEnabled && __instance.GetBurnMarkPos(bounds, obstacleController.transform, ____sabers[i].saberBladeBottomPos, ____sabers[i].saberBladeTopPos, out vector))
                 {
                     ____isSystemActive[i]    = true;
                     ____burnMarkPositions[i] = vector;
                     ____effects[i].SetPositionAndRotation(vector, __instance.GetEffectRotation(vector, obstacleController.transform, bounds));
                     XRNode node = (i == 0) ? XRNode.LeftHand : XRNode.RightHand;
                     //____hapticFeedbackController.ContinuousRumble(node);
                     if (!____wasSystemActive[i])
                     {
                         ____effects[i].StartEmission();
                         __instance.GetPrivateField <Action <Saber.SaberType> >("sparkleEffectDidStartEvent")(____sabers[i].saberType);
                     }
                 }
             }
         }
         for (int j = 0; j < 2; j++)
         {
             if (!____isSystemActive[j] && ____wasSystemActive[j])
             {
                 ____effects[j].StopEmission();
                 __instance.GetPrivateField <Action <Saber.SaberType> >("sparkleEffectDidEndEvent")(____sabers[j].saberType);
             }
         }
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 22
0
        private void AddEvents()
        {
            leftEventManager = leftSaber?.GetComponent <EventManager>();
            if (!leftEventManager)
            {
                leftEventManager = leftSaber.AddComponent <EventManager>();
            }

            rightEventManager = rightSaber?.GetComponent <EventManager>();
            if (!rightEventManager)
            {
                rightEventManager = rightSaber.AddComponent <EventManager>();
            }

            if (leftEventManager?.OnLevelStart == null ||
                rightEventManager?.OnLevelStart == null)
            {
                return;
            }

            leftEventManager.OnLevelStart.Invoke();
            rightEventManager.OnLevelStart.Invoke();

            try
            {
                beatmapObjectManager = Resources.FindObjectsOfTypeAll <BeatmapObjectManager>().FirstOrDefault();
                if (beatmapObjectManager)
                {
                    beatmapObjectManager.noteWasCutEvent    += SliceCallBack;
                    beatmapObjectManager.noteWasMissedEvent += NoteMissCallBack;
                }
                else
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(BeatmapObjectManager)}'.");
                }

                scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                if (scoreController)
                {
                    scoreController.multiplierDidChangeEvent += MultiplierCallBack;
                    scoreController.comboDidChangeEvent      += ComboChangeEvent;
                }
                else
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(ScoreController)}'.");
                }

                saberCollisionManager = Resources.FindObjectsOfTypeAll <ObstacleSaberSparkleEffectManager>().FirstOrDefault();
                if (saberCollisionManager)
                {
                    saberCollisionManager.sparkleEffectDidStartEvent += SaberStartCollide;
                    saberCollisionManager.sparkleEffectDidEndEvent   += SaberEndCollide;
                }
                else
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(ObstacleSaberSparkleEffectManager)}'.");
                }

                gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                if (gameEnergyCounter)
                {
                    gameEnergyCounter.gameEnergyDidReach0Event += FailLevelCallBack;
                }
                else
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(GameEnergyCounter)}'.");
                }

                beatmapCallback = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().FirstOrDefault();
                if (beatmapCallback)
                {
                    beatmapCallback.beatmapEventDidTriggerEvent += LightEventCallBack;
                }
                else
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(BeatmapObjectCallbackController)}'.");
                }

                playerHeadAndObstacleInteraction = Resources.FindObjectsOfTypeAll <PlayerHeadAndObstacleInteraction>().FirstOrDefault();
                if (!playerHeadAndObstacleInteraction)
                {
                    Logger.log.Warn($"Failed to locate a suitable '{nameof(PlayerHeadAndObstacleInteraction)}'.");
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
                throw;
            }

            try
            {
                float       LastTime    = 0.0f;
                LevelData   levelData   = BS_Utils.Plugin.LevelData;
                BeatmapData beatmapData = levelData.GameplayCoreSceneSetupData.difficultyBeatmap.beatmapData;

                IEnumerable <BeatmapLineData> beatmapLinesData = beatmapData.beatmapLinesData;
                foreach (BeatmapLineData beatMapLineData in beatmapLinesData)
                {
                    IList <BeatmapObjectData> beatmapObjectsData = beatMapLineData.beatmapObjectsData;
                    for (int i = beatmapObjectsData.Count - 1; i >= 0; i--)
                    {
                        BeatmapObjectData beatmapObjectData = beatmapObjectsData[i];
                        if (beatmapObjectData.beatmapObjectType == BeatmapObjectType.Note &&
                            ((NoteData)beatmapObjectData).noteType != NoteType.Bomb)
                        {
                            if (beatmapObjectData.time > LastTime)
                            {
                                lastNoteId = beatmapObjectData.id;
                                LastTime   = beatmapObjectData.time;
                            }

                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
                throw;
            }
        }