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 <XWeaponTrail> trails = Resources.FindObjectsOfTypeAll <XWeaponTrail>(); foreach (XWeaponTrail trail in trails) { ReflectionUtil.SetField(trail, "_trailWidth", 0f); } XWeaponTrail oldtrail = Resources.FindObjectsOfTypeAll <GameCoreSceneSetup>().FirstOrDefault() ?.GetField <BasicSaberModelController, GameCoreSceneSetup>("_basicSaberModelControllerPrefab") ?.GetField <XWeaponTrail, BasicSaberModelController>("_saberWeaponTrail"); if (oldtrail) { try { oldTrailRendererPrefab = ReflectionUtil.GetField <XWeaponTrailRenderer, XWeaponTrail>(oldtrail, "_trailRendererPrefab"); } catch (Exception ex) { Logger.log.Error(ex); throw; } if (Configuration.OverrideTrailLength) { Length = (int)(Length * Configuration.TrailLength); Granularity = (int)(Granularity * Configuration.TrailLength); } if (Length > 1) { trail = gameObject.AddComponent <CustomWeaponTrail>(); trail.Init(oldTrailRendererPrefab, colorManager, PointStart, PointEnd, TrailMaterial, TrailColor, Length, Granularity, MultiplierColor, colorType); } //if (Configuration.OverrideTrailLength) SetGranularity((int)(trail.GetField<int, CustomWeaponTrail>("_granularity") * Configuration.TrailLength)); } else { Logger.log.Debug($"Trail not found for '{saber?.saberType}'"); Destroy(this); } }
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); } }