Esempio n. 1
0
        public void Init(Saber parentSaber)
        {
            Logger.Log("Replacing Trail", LogLevel.Debug);

            saber = parentSaber;

            if (gameObject.name != "LeftSaber" && gameObject.name != "RightSaber")
            {
                Logger.Log("Parent not LeftSaber or RightSaber", LogLevel.Warning);
                Destroy(this);
            }

            if (saber == null)
            {
                Logger.Log("Saber not found", LogLevel.Warning);
                Destroy(this);
            }

            SaberWeaponTrail[] trails = Resources.FindObjectsOfTypeAll <SaberWeaponTrail>().ToArray();
            for (int i = 0; i < trails.Length; i++)
            {
                SaberWeaponTrail trail = trails[i];
                ReflectionUtil.SetPrivateField(trail, "_multiplierSaberColor", new Color(0f, 0f, 0f, 0f));
                ReflectionUtil.SetPrivateField(trail as Xft.XWeaponTrail, "_whiteSteps", 0);
            }

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

            if (oldtrail != null)
            {
                try
                {
                    Logger.Log(ReflectionUtil.GetPrivateField <Color>(oldtrail, "_multiplierSaberColor").ToString(), LogLevel.Debug);
                    //ReflectionUtil.SetPrivateField(oldtrail, "_multiplierSaberColor", new Color(0f, 0f, 0f, 0f));
                    //        oldColorManager = ReflectionUtil.GetPrivateField<ColorManager>(oldtrail, "_colorManager");
                    oldTrailRendererPrefab = ReflectionUtil.GetPrivateField <XWeaponTrailRenderer>(oldtrail, "_trailRendererPrefab");

                    //oldtrail.Start();
                    //oldtrail.gameObject.SetActive(false);
                }
                catch (Exception ex)
                {
                    Logger.Log($"{ex.Message}\n{ex.StackTrace}", LogLevel.Error);
                    throw;
                }

                trail = gameObject.AddComponent <CustomWeaponTrail>();
                trail.init(oldTrailRendererPrefab, Plugin.colorManager, PointStart, PointEnd, TrailMaterial, TrailColor, Length, MultiplierColor, colorType);
            }
            else
            {
                Logger.Log("Trail not found", LogLevel.Debug);
                Destroy(this);
            }
        }
 public void init(XWeaponTrailRenderer TrailRendererPrefab, ColorManager colorManager, Transform PointStart, Transform PointEnd, Material TrailMaterial, Color TrailColor, int Length, Color multiplierSaberColor, ColorType colorType)
 {
     _pointStart           = PointStart;
     _pointEnd             = PointEnd;
     _maxFrame             = Length;
     _colorManager         = colorManager;
     _trailRendererPrefab  = TrailRendererPrefab;
     _multiplierSaberColor = multiplierSaberColor;
     _customColor          = TrailColor;
     _customMaterial       = TrailMaterial;
     _saberType            = colorType;
 }
Esempio n. 3
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. 4
0
        public void Init(XWeaponTrailRenderer TrailRendererPrefab, ColorManager colorManager, Transform PointStart, Transform PointEnd, Material TrailMaterial, Color TrailColor, int Length, int Granularity, Color multiplierSaberColor, ColorType colorType)
        {
            _colorManager         = colorManager;
            _multiplierSaberColor = multiplierSaberColor;
            _customColor          = TrailColor;
            _customMaterial       = TrailMaterial;
            _saberType            = colorType;

            _pointStart = PointStart;
            _pointEnd   = PointEnd;
            _maxFrame   = Length;
            Logger.log.Info($"Granularity: {_granularity}");
            _granularity         = Granularity;
            _trailRendererPrefab = TrailRendererPrefab;
        }
Esempio n. 5
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. 6
0
        private void Start()
        {
            Console.WriteLine("Replacing Trail");

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

            GameObject _saber = FindParentWithName(this.gameObject, "Saber");

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

            trail = _saber.GetComponent <XWeaponTrail>();
            if (trail != null)
            {
                ReflectionUtil.SetPrivateField(trail, "PointStart", PointStart);
                ReflectionUtil.SetPrivateField(trail, "PointEnd", PointEnd);
                ReflectionUtil.SetPrivateField(trail, "MyColor", TrailColor);
                ReflectionUtil.SetPrivateField(trail, "MyMaterial", TrailMaterial);
                ReflectionUtil.SetPrivateField(trail, "MaxFrame", Length);

                XWeaponTrailRenderer trailRenderer = ReflectionUtil.GetPrivateField <XWeaponTrailRenderer>(trail, "_trailRenderer");
                MeshRenderer         meshRenderer  = ReflectionUtil.GetPrivateField <MeshRenderer>(trailRenderer, "_meshRenderer");
                meshRenderer.material = TrailMaterial;

                trail.UpdateHeadElem();
                trail.UpdateVertex();
            }
            else
            {
                Console.WriteLine("Trail not found");
                Destroy(this);
            }
        }