/// <summary>
        /// Recalculates saber objects.
        /// </summary>
        public void Recalculate()
        {
            IEnumerable <Saber> sabers = new List <Saber>();

            if (_sabers != null)
            {
                sabers = _sabers.Where(s => s != null);

                foreach (var burnEffect in _effects)
                {
                    DestroyImmediate(burnEffect);
                }
            }

            _effects           = new ObstacleSaberSparkleEffect[0];
            _effectsTransforms = new Transform[0];
            _burnMarkPositions = new Vector3[0];
            _wasSystemActive   = new bool[0];
            _isSystemActive    = new bool[0];
            _sabers            = new Saber[0];

            foreach (var saber in sabers)
            {
                RegisterSaber(saber);
            }
        }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
0
 private static void SetObstacleSaberSparkleColor(ObstacleSaberSparkleEffect obstacleSaberSparkleEffect, ObstacleController obstacleController)
 {
     Color.RGBToHSV(obstacleController.GetObstacleColorizer().Color, out float h, out float s, out _);
     obstacleSaberSparkleEffect.color = Color.HSVToRGB(h, s, 1);
 }