static void ApplyToSaber(SaberModelContainer saberModelContainer) { var saber = saberModelContainer.GetPrivateField <Saber>("_saber"); var saberTop = saber.GetPrivateField <Transform>("_saberBladeTopTransform"); var saberBottom = saber.GetPrivateField <Transform>("_saberBladeBottomTransform"); saberTop.localPosition = new Vector3(saberTop.localPosition.x, saberTop.localPosition.y, saberBottom.localPosition.z + CurrentLength); }
static void Postfix(SaberModelContainer __instance) { var saber = __instance.GetPrivateField <Saber>("_saber"); if (!IsValidSaber(saber)) { return; } SaberLength.TrackSaber(__instance); }
static void ApplyToSaber(SaberModelContainer saberModelContainer) { var saber = saberModelContainer.GetPrivateField <Saber>("_saber"); var saberModelController = saberModelContainer.GetComponent <SaberModelController>(); var saberTop = saber.GetPrivateField <Transform>("_saberBladeTopTransform"); var saberBottom = saber.GetPrivateField <Transform>("_saberBladeBottomTransform"); saberTop.localPosition = new Vector3(saberTop.localPosition.x, saberTop.localPosition.y, saberBottom.localPosition.z + CurrentLength); // TODO: Remove this dirty renderer hack and implement a custom saber model through DI foreach (var saberRenderer in saberModelContainer.GetComponentsInChildren <MeshRenderer>()) { saberRenderer.enabled = IsVisible; } }
internal static void TrackSaber(SaberModelContainer saberModelContainer) { ActiveSabers.Add(new WeakReference <SaberModelContainer>(saberModelContainer)); ApplyToSaber(saberModelContainer); }
private static void Postfix(SaberModelContainer __instance, Saber ____saber) { __instance.gameObject.AddComponent <ChromaSaberController>().Init(____saber); }
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)) && x.Priority >= 0); var provider = GetProvider(____container); if (providers.Count() == 0) { if (!provider.IsSafe()) { provider.ModelPrefab = ____saberModelControllerPrefab; } return(true); } var baseProvider = providers.OrderByDescending(x => x.Priority).First(); var originalPrefab = ____saberModelControllerPrefab; var instanceTransform = __instance.transform; var container = ____container; var saber = ____saber; if (!provider.IsSafe(false)) { var smc = new GameObject(baseProvider.GetType().FullName).AddComponent(baseProvider.Type) as SaberModelController; SetupSaber(____container, ____saberModelControllerPrefab, smc); provider.ModelPrefab = smc; } provider.GetModel((smc) => { container.QueueForInject(smc); SetupSaber(container, originalPrefab, smc); smc.gameObject.transform.SetParent(instanceTransform, false); smc.Init(instanceTransform, saber); }); return(false); }
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); }