static bool Prefix(SphereCuttableBySaber __instance, Saber saber, Vector3 cutPoint, SphereCollider ____collider)
 {
     if (__instance.canBeCut)
     {
         if (Config.feet ||
             saber.name == NalulunaModifierController.saberFootLName ||
             saber.name == NalulunaModifierController.saberFootRName)
         {
             //Logger.log.Debug($"distance={Vector3.Distance(__instance.transform.position, saber.transform.position)}, instance={__instance.transform.position}, saber={saber.transform.position}, {saber.saberBladeBottomPos}, {saber.saberBladeTopPos}, cutPoint={cutPoint}");
             return(Vector3.Distance(__instance.transform.position, saber.transform.position) < ____collider.radius);
         }
     }
     return(true);
 }
Esempio n. 2
0
        public void Init(Saber saber, ColorManager colorManager)
        {
            Logger.log.Debug($"Replacing Trail for '{saber?.saberType}'");

            if (gameObject.name != "LeftSaber" && gameObject.name != "RightSaber")
            {
                Logger.log.Warn("Parent not LeftSaber or RightSaber");
                Destroy(this);
            }

            if (!saber)
            {
                Logger.log.Warn("Saber not found");
                Destroy(this);
            }

            IEnumerable <SaberWeaponTrail> trails = Resources.FindObjectsOfTypeAll <SaberWeaponTrail>().ToArray();

            foreach (SaberWeaponTrail trail in trails)
            {
                ReflectionUtil.SetPrivateField(trail, "_multiplierSaberColor", new Color(0f, 0f, 0f, 0f));
                ReflectionUtil.SetPrivateField(trail as XWeaponTrail, "_whiteSteps", 0);
            }

            SaberWeaponTrail oldtrail = Resources.FindObjectsOfTypeAll <GameCoreSceneSetup>().FirstOrDefault()
                                        ?.GetPrivateField <BasicSaberModelController>("_basicSaberModelControllerPrefab")
                                        ?.GetPrivateField <SaberWeaponTrail>("_saberWeaponTrail");

            if (oldtrail)
            {
                try
                {
                    //Logger.log.Debug(ReflectionUtil.GetPrivateField<Color>(oldtrail, "_multiplierSaberColor").ToString());
                    oldTrailRendererPrefab = ReflectionUtil.GetPrivateField <XWeaponTrailRenderer>(oldtrail, "_trailRendererPrefab");
                }
                catch (Exception ex)
                {
                    Logger.log.Error(ex);
                    throw;
                }

                trail = gameObject.AddComponent <CustomWeaponTrail>();
                trail.Init(oldTrailRendererPrefab, colorManager, PointStart, PointEnd, TrailMaterial, TrailColor, Length, MultiplierColor, colorType);
            }
            else
            {
                Logger.log.Debug($"Trail not found for '{saber?.saberType}'");
                Destroy(this);
            }
        }
Esempio n. 3
0
        public override void Init(Transform parent, Saber saber)
        {
            var saberModel = saber.saberType == SaberType.SaberA ? _saberSet.LeftSaber : _saberSet.RightSaber;

            _saberInstance = _saberInstanceFactory.Create(saberModel);

            _saberInstance.SetParent(parent);
            _saberInstance.CreateTrail(_saberTrail.GetField <SaberTrailRenderer, SaberTrail>("_trailRendererPrefab"));
            SetColor(_saberColor ?? _colorManager.ColorForSaberType(_saberInstance.Model.SaberSlot.ToSaberType()));

            _eventPlayer?.SetPartEventList(_saberInstance.Events, saber.saberType);

            _logger.Info("Instantiated Saber");
        }
Esempio n. 4
0
        private IEnumerator PreloadDefaultSabers()
        {
            FirstFetch = false;

            //Logger.Log("Preloading default sabers!", LogLevel.Debug);
            //HarmonyInstance harmony = HarmonyInstance.Create("CustomSaberHarmonyInstance");
            //harmony.PatchAll(Assembly.GetExecutingAssembly());

            Logger.Log("Loading GameCore scene");
            SceneManager.LoadSceneAsync("GameCore", LoadSceneMode.Additive);
            Logger.Log("Loaded!");

            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Count() > 1));

            Logger.Log("Got sabers!");

            foreach (var s in Resources.FindObjectsOfTypeAll <Saber>())
            {
                Logger.Log($"Saber: {s.name}, GameObj: {s.gameObject.name}, {s.ToString()}");
                if (s.name == "LeftSaber")
                {
                    LeftSaber = Saber.Instantiate(s);
                }
                else if (s.name == "RightSaber")
                {
                    RightSaber = Saber.Instantiate(s);
                }
            }
            Logger.Log("Finished! Got default sabers! Setting active state");

            if (LeftSaber)
            {
                Object.DontDestroyOnLoad(LeftSaber.gameObject);
                LeftSaber.gameObject.SetActive(false);
                LeftSaber.name = "___OriginalSaberPreviewB";
            }

            if (RightSaber)
            {
                Object.DontDestroyOnLoad(RightSaber.gameObject);
                RightSaber.gameObject.SetActive(false);
                RightSaber.name = "___OriginalSaberPreviewA";
            }

            Logger.Log("Unloading GameCore");
            SceneManager.UnloadSceneAsync("GameCore");

            //Logger.Log("Unloading harmony patches", LogLevel.Debug);
            //harmony.UnpatchAll("CustomSaberHarmonyInstance");
        }
 private void FindSabers()
 {
     Plugin.Log.Debug("Looking for sabers...");
     try
     {
         saberManager = Resources.FindObjectsOfTypeAll <SaberManager>().FirstOrDefault();
         rSaber       = saberManager.rightSaber;
         lSaber       = saberManager.leftSaber;
     } catch (Exception exception)
     {
         CriticalErrorHandler(true, 324, exception);
     }
     Plugin.Log.Debug("Success! Found sabers.");
 }
 static bool Prefix(GameNoteController __instance, Saber saber)
 {
     if (Config.ignoreBadColor)
     {
         NoteType  noteType    = __instance.noteData.noteType;
         SaberType saberType   = saber.saberType;
         bool      saberTypeOK = ((noteType == NoteType.NoteA && saberType == SaberType.SaberA) || (noteType == NoteType.NoteB && saberType == SaberType.SaberB));
         return(saberTypeOK);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 7
0
 static bool Prefix(GameNoteController __instance, Saber saber)
 {
     if (Config.ignoreBadColor ||
         (Config.fourSabers && (saber.name == NalulunaModifierController.saberFootLName || saber.name == NalulunaModifierController.saberFootRName)))
     {
         ColorType colorType   = __instance.noteData.colorType;
         SaberType saberType   = saber.saberType;
         bool      saberTypeOK = ((colorType == ColorType.ColorA && saberType == SaberType.SaberA) || (colorType == ColorType.ColorB && saberType == SaberType.SaberB));
         return(saberTypeOK);
     }
     else
     {
         return(true);
     }
 }
Esempio n. 8
0
        public IEnumerator SwapSabers(Saber saber1, Saber saber2)
        {
            yield return(new WaitForSecondsRealtime(0.5f));

            beepSound.Play();
            Log("Swapping sabers");
            Transform transform1 = saber1.transform.parent.transform;

            Transform transform2 = saber2.transform.parent.transform;

            saber2.transform.parent = transform1;
            saber1.transform.parent = transform2;
            saber2.transform.SetPositionAndRotation(transform1.transform.position, player.rightSaber.transform.parent.rotation);
            saber1.transform.SetPositionAndRotation(transform2.transform.position, player.leftSaber.transform.parent.rotation);
        }
Esempio n. 9
0
        public static Saber Crear(Saber saber)
        {
            try
            {
                Enum.TryParse("Habilitado", out EnumEstado EEstado);
                saber.Estado = EEstado;

                var command = new MySqlCommand()
                {
                    CommandText = "sp_saber_crear", CommandType = System.Data.CommandType.StoredProcedure
                };
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_codigo", Direction = System.Data.ParameterDirection.Input, Value = saber.Codigo
                });
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_descripcion", Direction = System.Data.ParameterDirection.Input, Value = saber.Descripcion
                });
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_nivelLogro", Direction = System.Data.ParameterDirection.Input, Value = saber.Logro.ToString()
                });
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_estado", Direction = System.Data.ParameterDirection.Input, Value = saber.Estado.ToString()
                });
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_porcentajeLogro", Direction = System.Data.ParameterDirection.Input, Value = saber.PorcentajeLogro
                });
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "out_id", Direction = System.Data.ParameterDirection.Output, Value = -1
                });

                var datos = DataSource.ExecuteProcedure(command);

                saber.Id = Convert.ToInt32(datos.Parameters["out_id"].Value);

                return(saber);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
        }
Esempio n. 10
0
        private void Update()
        {
            if (!(Configuration.instance.ConfigurationData.OneColor &&
                  Configuration.instance.ConfigurationData.PlayMode == PlayMode.BeatSaber &&
                  Configuration.instance.ConfigurationData.RemoveOtherSaber))
            {
                return;
            }

            // Move the other saber away since there's a bug in the base game which makes it
            // able to cut bombs still
            Saber saberToHide = Configuration.instance.ConfigurationData.UseLeftSaber ? this.saberManager.rightSaber : this.saberManager.leftSaber;

            saberToHide.gameObject.transform.position = new Vector3(0.0f, -1000.0f, 0.0f);
            saberToHide.gameObject.transform.rotation = Quaternion.Euler(90.0f, 0.0f, 0.0f);
        }
Esempio n. 11
0
        void ModifySaber(Saber saber)
        {
            var length      = Preferences.Length;
            var saberBlade  = saber.transform.Find("Blade");
            var saberTop    = saber.saberBladeTopPosTransform;
            var saberBottom = saber.saberBladeBottomPosTransform;

            var originalLength = saberBlade.localScale.y;
            var originZ        = saberBlade.localPosition.z - originalLength / 2f;

            saberBlade.localScale    = new Vector3(saberBlade.localScale.x, length, saberBlade.localScale.z);
            saberBlade.localPosition = new Vector3(saberBlade.localPosition.x, saberBlade.localPosition.y, originZ + length / 2f);

            saberTop.localPosition    = new Vector3(saberTop.localPosition.x, saberTop.localPosition.y, (saberTop.localPosition.z - originZ) / originalLength * length);
            saberBottom.localPosition = new Vector3(saberBottom.localPosition.x, saberBottom.localPosition.y, (saberBottom.localPosition.z - originZ) / originalLength * length);
        }
Esempio n. 12
0
        /// <summary>
        /// Transform the spear based on two controllers
        /// </summary>
        private void TransformForTwoControllerSpear()
        {
            // Determine the forward hand
            if (Configuration.instance.ConfigurationData.UseTriggerToSwitchHands)
            {
                if (BehaviorCatalog.instance.InputManager.GetLeftTriggerClicked())
                {
                    this.useLeftHandForward = true;
                }
                if (BehaviorCatalog.instance.InputManager.GetRightTriggerClicked())
                {
                    this.useLeftHandForward = false;
                }
            }

            // Get positions and rotations of hands
            Pose    forwardHand = this.useLeftHandForward ? this.GetLeftPosition() : this.GetRightPosition();
            Pose    rearHand    = this.useLeftHandForward ? this.GetRightPosition() : this.GetLeftPosition();
            Vector3 forward     = (forwardHand.position - rearHand.position).normalized;
            Vector3 up          = forwardHand.rotation * Vector3.one;

            // Determine final saber position
            Vector3 saberPosition;
            float   handSeparationSquared = (forwardHand.position - rearHand.position).sqrMagnitude;

            if (handSeparationSquared > handleLength * handleLength)
            {
                // Clamp the saber at the extent of the forward hand
                saberPosition = forwardHand.position;
            }
            else
            {
                // Allow the saber to be pushed forward by the rear hand
                saberPosition = rearHand.position + (forward * handleLength);
            }

            if (Configuration.instance.ConfigurationData.ReverseSpearDirection)
            {
                forward = -forward;
            }

            // Apply transforms to saber
            Saber saberToTransform = Configuration.instance.ConfigurationData.UseLeftSpear ? this.saberManager.leftSaber : this.saberManager.rightSaber;

            saberToTransform.transform.position = saberPosition;
            saberToTransform.transform.rotation = Quaternion.LookRotation(forward, up);
        }
Esempio n. 13
0
        public void Init(Saber parentSaber)
        {
            Console.WriteLine("Replacing Trail");

            saber = parentSaber;

            if (gameObject.name != "LeftSaber" && gameObject.name != "RightSaber")
            {
                Console.WriteLine("Parent not LeftSaber or RightSaber");
                Destroy(this);
            }

            if (saber == null)
            {
                Console.WriteLine("Saber not found");
                Destroy(this);
            }

            SaberWeaponTrail oldtrail = Resources.FindObjectsOfTypeAll <GameCoreInstaller>()
                                        .FirstOrDefault()?.GetPrivateField <BasicSaberModelController>("_basicSaberModelControllerPrefab")
                                        ?.GetPrivateField <SaberWeaponTrail>("_saberWeaponTrail");

            if (oldtrail != null)
            {
                try
                {
                    ReflectionUtil.SetPrivateField(oldtrail, "_multiplierSaberColor", new Color(0f, 0f, 0f, 0f));
                    oldColorManager        = ReflectionUtil.GetPrivateField <ColorManager>(oldtrail, "_colorManager");
                    oldTrailRendererPrefab = ReflectionUtil.GetPrivateField <XWeaponTrailRenderer>(oldtrail, "_trailRendererPrefab");
                    oldtrail.gameObject.SetActive(false);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine(e.Message);
                    throw;
                }

                trail = gameObject.AddComponent <CustomWeaponTrail>();
                trail.init(oldTrailRendererPrefab, oldColorManager, PointStart, PointEnd, TrailMaterial, TrailColor, Length, MultiplierColor, colorType);
            }
            else
            {
                Console.WriteLine("Trail not found");
                Destroy(this);
            }
        }
Esempio n. 14
0
        internal static bool Prefix(ref Saber ____saber, ref DiContainer ____container, ref SaberModelContainer __instance, SaberModelController ____saberModelControllerPrefab)
        {
            var providers = ____container.Resolve <List <IModelProvider> >().Where(x => x.Type.DerivesFrom(typeof(SaberModelController)));

            if (providers.Count() == 0)
            {
                var provider = ____container.Resolve <SaberProvider>();
                if (!provider.IsSafe())
                {
                    provider.ModelPrefab = ____saberModelControllerPrefab;
                }
                return(true);
            }
            var baseProvider = providers.OrderByDescending(x => x.Priority).First();
            SaberModelController saberModelController = null;
            var providerX = ____container.Resolve <SaberProvider>();

            if (!providerX.IsSafe())
            {
                saberModelController = providerX.ModelPrefab = new GameObject(baseProvider.GetType().FullName).AddComponent(baseProvider.Type) as SaberModelController;
            }
            else
            {
                saberModelController = providerX.ModelPrefab;
            }
            ____container.Inject(saberModelController);
            Accessors.SaberTrail(ref saberModelController)     = Accessors.SaberTrail(ref ____saberModelControllerPrefab);
            Accessors.SaberGlowColor(ref saberModelController) = Accessors.SaberGlowColor(ref ____saberModelControllerPrefab);
            var glowColors = Accessors.SaberGlowColor(ref saberModelController);

            for (int i = 0; i < glowColors.Length; i++)
            {
                ____container.Inject(glowColors[i]);
            }
            Accessors.FakeSaberGlowColor(ref saberModelController) = Accessors.FakeSaberGlowColor(ref ____saberModelControllerPrefab);
            var fakeGlowColors = Accessors.FakeSaberGlowColor(ref saberModelController);

            for (int i = 0; i < fakeGlowColors.Length; i++)
            {
                ____container.Inject(fakeGlowColors[i]);
            }
            Accessors.SaberLight(ref saberModelController) = Accessors.SaberLight(ref ____saberModelControllerPrefab);
            saberModelController.gameObject.transform.SetParent(__instance.transform, false);
            saberModelController.Init(__instance.transform, ____saber);
            return(false);
        }
Esempio n. 15
0
        public static void Postfix(GameNoteController __instance, Saber saber)
        {
            if (sabers == null)
            {
                sabers = Resources.FindObjectsOfTypeAll <Saber>();
            }
            var otherSaber = sabers.Where((x) => x != saber).First();

            if (Vector3.Distance(otherSaber.saberBladeTopPos, __instance.gameObject.transform.position) < threshold)
            {
                if (spawner == null)
                {
                    spawner = Resources.FindObjectsOfTypeAll <NoteCutEffectSpawner>().FirstOrDefault();
                }
                ReflectionUtil.GetField <NoteCutHapticEffect, NoteCutEffectSpawner>(spawner, "_noteCutHapticEffect").HitNote(otherSaber.saberType);
            }
        }
Esempio n. 16
0
        private void PrepareSaber(GameObject saberRoot, Saber saber, GameObject customSaber)
        {
            if (saberRoot)
            {
                customSaber.transform.parent = saber.transform;
            }

            customSaber.transform.position = saber.transform.position;
            customSaber.transform.rotation = saber.transform.rotation;

            IEnumerable <CustomTrail> trails = customSaber.GetComponents <CustomTrail>();

            foreach (CustomTrail trail in trails)
            {
                trail.Init(saber, colorManager);
            }
        }
Esempio n. 17
0
        public override void AI()
        {
            Player player = Main.player[projectile.owner];

            if (Saber.AINormalSlash(projectile, SlashLogic))
            {
            }
            else
            {
                // Charged attack
                Saber.AISetChargeSlashVariables(player, chargeSlashDirection);
                Saber.NormalSlash(projectile, player);
            }
            projectile.damage    = 0;
            projectile.ai[0]    += 1f; // Framerate
            projectile.position += player.velocity;
        }
Esempio n. 18
0
        public static Color GetColor(this Saber saber)
        {
            ISaberModelController modelController = saber.gameObject.GetComponentInChildren <ISaberModelController>(true);

            if (modelController is BasicSaberModelController)
            {
                BasicSaberModelController bsmc = modelController as BasicSaberModelController;
                Light light = SaberLight(ref bsmc);
                return(light.color);
            }
            else if (modelController is IColorable)
            {
                IColorable colorable = modelController as IColorable;
                return(colorable.Color);
            }
            return(Color.white);
        }
Esempio n. 19
0
        /// <summary>
        /// Change the color of a saber.
        /// </summary>
        /// <param name="_">The saber.</param>
        /// <param name="color">The color to change the saber to.</param>
        /// <param name="smc">The model controller of the saber.</param>
        /// <param name="tintColor">The tint color of the new color.</param>
        /// <param name="setSaberGlowColors">The glow color groups of the saber.</param>
        /// <param name="setSaberFakeGlowColors">The fake glow color groups of the saber.</param>
        /// <param name="light">The light of the saber.</param>
        public static void ChangeColor(this Saber _, Color color, SaberModelController smc, Color tintColor, SetSaberGlowColor[] setSaberGlowColors, SetSaberFakeGlowColor[] setSaberFakeGlowColors, TubeBloomPrePassLight light)
        {
            Accessors.TrailColor(ref Accessors.SaberTrail(ref smc)) = (color * tintColor).linear;

            for (int i = 0; i < setSaberGlowColors.Length; i++)
            {
                setSaberGlowColors[i].OverrideColor(color);
            }
            for (int i = 0; i < setSaberFakeGlowColors.Length; i++)
            {
                setSaberFakeGlowColors[i].OverrideColor(color);
            }
            if (light != null)
            {
                light.color = color;
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Registers a saber into the effect manager.
 /// </summary>
 /// <param name="saber">The saber being registered.</param>
 public void SaberCreated(Saber saber)
 {
     if (!_safeReady)
     {
         _temporaryQueue.Enqueue(saber);
     }
     else if (saber != null)
     {
         _saberManagers.ForEach(isr => isr.RegisterSaber(saber));
         _managedSabers.Add(saber);
     }
     if (!_siraSaberClashChecker.MultiSaberMode)
     {
         _siraSaberClashChecker.MultiSaberMode = true;
         RepatchDefault(_saberManager.leftSaber, _saberManager.rightSaber, _saberManager);
     }
 }
Esempio n. 21
0
        public static List <Saber> LeerSubSaberes(int codigo)
        {
            try
            {
                var command = new MySqlCommand()
                {
                    CommandText = "sp_unidades_leersubsaberes", CommandType = System.Data.CommandType.StoredProcedure
                };
                command.Parameters.Add(new MySqlParameter()
                {
                    ParameterName = "in_codigo", Direction = System.Data.ParameterDirection.Input, Value = codigo
                });
                var datos = DataSource.GetDataSet(command);

                List <Saber> saberes = new List <Saber>();
                if (datos.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in datos.Tables[0].Rows)
                    {
                        var prodData = row;
                        Enum.TryParse(prodData["nivelLogro"].ToString(), out EnumLogro ELogro);
                        Enum.TryParse(prodData["estado"].ToString(), out EnumEstado EEstado);
                        var sabe = new Saber()
                        {
                            Codigo          = Convert.ToString(prodData["codigo"]),
                            Descripcion     = prodData["descripcion"].ToString(),
                            Logro           = ELogro,
                            Estado          = EEstado,
                            PorcentajeLogro = prodData["porcentajeLogro"].ToString(),
                            Id = Convert.ToInt32(prodData["id"])
                        };
                        saberes.Add(sabe);
                    }
                }
                return(saberes);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
            }
            return(null);
        }
Esempio n. 22
0
 public void Tick()
 {
     if (leftSaber != playerController.leftSaber)
     {
         leftSaber = playerController.leftSaber;
     }
     if (rightSaber != playerController.rightSaber)
     {
         rightSaber = playerController.rightSaber;
     }
     leftQuaternions.Add(leftSaber.transform.rotation);
     rightQuaternions.Add(rightSaber.transform.rotation);
     if (leftQuaternions.Count >= 2 && rightQuaternions.Count >= 2)
     {
         leftAngles.Add(Quaternion.Angle(leftQuaternions.Last(), leftQuaternions[leftQuaternions.Count - 2]));
         rightAngles.Add(Quaternion.Angle(rightQuaternions.Last(), rightQuaternions[rightQuaternions.Count - 2]));
     }
 }
Esempio n. 23
0
        public static void Run()
        {
            ICharacter emiya       = new Archer("emiya");
            ICharacter artoria     = new Saber("artoria");
            ICharacter cu_chulainn = new Lancer("cu_chulainn");

            Invoker        invoker    = new Invoker();
            List <Command> commandsPK = new List <Command>()
            {
                new CommonAttack(emiya),
                new SpeedAttack(artoria),
                new CounterAttack(cu_chulainn)
            };

            commandsPK.ForEach(cmd => { invoker.AddCommand(cmd); });

            invoker.Invoke();
        }
Esempio n. 24
0
        static void SetSaberLength(Saber saber, float length)
        {
            var saberTop    = saber.GetPrivateField <Transform>("_topPos");
            var saberBottom = saber.GetPrivateField <Transform>("_bottomPos");

            saberTop.localPosition = new Vector3(saberTop.localPosition.x, saberTop.localPosition.y, saberBottom.localPosition.z + length);

            var trail = Resources.FindObjectsOfTypeAll <GameCoreInstaller>().FirstOrDefault()
                        ?.GetPrivateField <BasicSaberModelController>("_basicSaberModelControllerPrefab")
                        ?.GetPrivateField <SaberWeaponTrail>("_saberWeaponTrail");

            if (trail != null)
            {
                var trailTop    = trail.GetPrivateField <Transform>("_pointEnd");
                var trailBottom = trail.GetPrivateField <Transform>("_pointStart");

                trailTop.localPosition = new Vector3(trailTop.localPosition.x, trailTop.localPosition.y, trailBottom.localPosition.z + length);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Gets the color of a saber.
        /// </summary>
        /// <param name="saber">The saber to get the color of.</param>
        /// <returns></returns>
        public static Color GetColor(this Saber saber)
        {
            if (saber is IColorable saberColorable)
            {
                return(saberColorable.Color);
            }
            SaberModelController modelController = saber.gameObject.GetComponentInChildren <SaberModelController>(true);

            if (modelController is IColorable)
            {
                var colorable = modelController as IColorable;
                return(colorable.Color);
            }
            else if (modelController is SaberModelController smc)
            {
                return(Accessors.TrailColor(ref Accessors.SaberTrail(ref smc)).gamma);
            }
            return(Color.white);
        }
Esempio n. 26
0
        /// <summary>
        /// Disables the rendering of the other saber
        /// </summary>
        private IEnumerator DisableOtherSaberMesh()
        {
            yield return(new WaitForSecondsRealtime(0.1f));

            if (!(Configuration.instance.ConfigurationData.OneColor &&
                  Configuration.instance.ConfigurationData.PlayMode == PlayMode.BeatSaber &&
                  Configuration.instance.ConfigurationData.RemoveOtherSaber))
            {
                yield break;
            }

            Saber saberToHide    = Configuration.instance.ConfigurationData.UseLeftSpear ? this.saberManager.rightSaber : this.saberManager.leftSaber;
            var   saberRenderers = saberToHide.gameObject.GetComponentsInChildren <Renderer>();

            foreach (var r in saberRenderers)
            {
                r.enabled = false;
            }
        }
Esempio n. 27
0
        public static List <Saber> LeerHabilitado()
        {
            try
            {
                var command = new MySqlCommand()
                {
                    CommandText = "sp_saber_leerHabilitados", CommandType = System.Data.CommandType.StoredProcedure
                };
                var datos = DataSource.GetDataSet(command);

                List <Saber> sabers = new List <Saber>();
                if (datos.Tables[0].Rows.Count > 0)
                {
                    foreach (System.Data.DataRow row in datos.Tables[0].Rows)
                    {
                        var prodData = row;

                        Enum.TryParse(prodData["nivelLogro"].ToString(), out EnumLogro ELogro);
                        Enum.TryParse("Habilitado", out EnumEstado EEstado);
                        var sabe = new Saber()
                        {
                            Codigo          = Convert.ToString(prodData["codigo"]),
                            Descripcion     = prodData["descripcion"].ToString(),
                            Logro           = ELogro,
                            Estado          = EEstado,
                            PorcentajeLogro = prodData["porcentajeLogro"].ToString(),
                            Id = Convert.ToInt32(prodData["id"])
                        };
                        sabers.Add(sabe);
                    }
                }
                return(sabers);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
            }
            return(null);
        }
Esempio n. 28
0
        public override void LateUpdate()
        {
            for (int i = 0; i < _saberBurnData.Count; i++)
            {
                Saber          saber          = _saberBurnData[i].saber;
                Color          color          = _saberBurnData[i].color;
                ParticleSystem particleSystem = _saberBurnData[i].burnMarkParticleSystem;
                ParticleSystem.EmissionModule emissionModule = _saberBurnData[i].burnMarkEmissionModule;

                var  vector   = new Vector3(0f, 0f, 0f);
                bool isActive = saber != null && saber.isActiveAndEnabled && GetBurnMarkPos(saber.saberBladeBottomPos, saber.saberBladeTopPos, out vector);
                if (isActive)
                {
                    particleSystem.transform.localPosition = vector;
                }
                if (isActive && !_saberBurnData[i].prevBurnMarkPosValid)
                {
                    emissionModule.enabled = isActive;
                }
                else if (!isActive && !_saberBurnData[i].prevBurnMarkPosValid)
                {
                    emissionModule.enabled = false;
                    particleSystem.Clear();
                }
                _sparklesEmitParams.startColor = color;
                if (isActive && _saberBurnData[i].prevBurnMarkPosValid)
                {
                    Vector3 a         = vector - _saberBurnData[i].prevBurnMarkPos;
                    float   magnitude = a.magnitude;
                    float   num       = 0.05f;
                    int     num2      = (int)(magnitude / num);
                    int     num3      = (num2 > 0) ? num2 : 1;
                    for (int j = 0; j <= num2; j++)
                    {
                        _sparklesEmitParams.position = _saberBurnData[i].prevBurnMarkPos + a * j / num3;
                        _sparklesPS.Emit(_sparklesEmitParams, 1);
                    }
                }
                _saberBurnData[i].prevBurnMarkPosValid = isActive;
                _saberBurnData[i].prevBurnMarkPos      = vector;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// To be invoked every time when starting the GameCore scene.
        /// </summary>
        /// <remarks>
        /// Note that no delay is done with this method
        /// </remarks>
        public void BeginGameCoreScene()
        {
            if (ConfigOptions.instance.OneColor)
            {
                this.TransformToOneColor();
            }

            if (ConfigOptions.instance.TwoControllers)
            {
                Logging.Info("Disabling submission on Two Controller option");
                BS_Utils.Gameplay.ScoreSubmission.DisableSubmission(Plugin.assemblyName);
                previousForwardHand = ConfigOptions.instance.LeftHanded ? XRNode.RightHand : XRNode.LeftHand;
            }

            if (ConfigOptions.instance.TwoControllers || ConfigOptions.instance.RemoveOtherSpear)
            {
                Saber saberToHide = ConfigOptions.instance.LeftHanded ? this.playerController.rightSaber : this.playerController.leftSaber;
                saberToHide.gameObject.SetActive(false);
            }
        }
Esempio n. 30
0
        public override void Init(Transform parent, Saber saber)
        {
            if (saber.saberType == SaberType.SaberA)
            {
                _saber = UnityEngine.Object.Instantiate(Plugin.LeftSaber, parent, false);
            }
            else
            {
                _saber = UnityEngine.Object.Instantiate(Plugin.RightSaber, parent, false);
            }

            _saber.transform.localScale = new Vector3(1, 1, Preferences.Length / 0.30f);

            SetColor(_color ?? _colorManager.ColorForSaberType(saber.saberType));

            this.trail = _saber.AddComponent <ClawTrail>();
            this.trail.RegisterPrefab(this._saberTrail.GetPrivateField <SaberTrailRenderer>("_trailRendererPrefab"));
            this.trail.Setup(_color ?? _colorManager.ColorForSaberType(saber.saberType), saber.movementData);
            Plugin.Log.Log(IPA.Logging.Logger.Level.Debug, "_saberTrail has been activated");
        }