public void CreateColumns(GameObject go) { if (spectrogramColumns == null) { spectrogramColumns = new List <SpectrogramColumns>(); } if (columnDescriptors == null) { columnDescriptors = new List <Spectrogram>(); } Spectrogram[] localDescriptors = go.GetComponentsInChildren <Spectrogram>(true); foreach (Spectrogram spec in localDescriptors) { SpectrogramColumns specCol = spec.gameObject.AddComponent <SpectrogramColumns>(); ReflectionUtil.SetPrivateField(specCol, "_columnPrefab", spec.columnPrefab); ReflectionUtil.SetPrivateField(specCol, "_separator", spec.separator); ReflectionUtil.SetPrivateField(specCol, "_minHeight", spec.minHeight); ReflectionUtil.SetPrivateField(specCol, "_maxHeight", spec.maxHeight); ReflectionUtil.SetPrivateField(specCol, "_columnWidth", spec.columnWidth); ReflectionUtil.SetPrivateField(specCol, "_columnDepth", spec.columnDepth); spectrogramColumns.Add(specCol); columnDescriptors.Add(spec); } }
public void CreateEffects(GameObject go) { if (lightRotationEffects == null) { lightRotationEffects = new List <LightRotationEventEffect>(); } if (effectDescriptors == null) { effectDescriptors = new List <RotationEventEffect>(); } RotationEventEffect[] localDescriptors = go.GetComponentsInChildren <RotationEventEffect>(true); if (localDescriptors == null) { return; } foreach (RotationEventEffect effectDescriptor in effectDescriptors) { LightRotationEventEffect rotEvent = effectDescriptor.gameObject.AddComponent <LightRotationEventEffect>(); ReflectionUtil.SetPrivateField(rotEvent, "_event", (BeatmapEventType)effectDescriptor.eventType); ReflectionUtil.SetPrivateField(rotEvent, "_rotationVector", effectDescriptor.rotationVector); ReflectionUtil.SetPrivateField(rotEvent, "_transform", rotEvent.transform); ReflectionUtil.SetPrivateField(rotEvent, "_startRotation", rotEvent.transform.rotation); lightRotationEffects.Add(rotEvent); effectDescriptors.Add(effectDescriptor); } }
public void CreateTrackRings(GameObject go) { rotationSpawners = new List <TrackLaneRingsRotationEffectSpawner>(); stepSpawners = new List <TrackLaneRingsPositionStepEffectSpawner>(); trackLaneRingsManagers = new List <TrackLaneRingsManager>(); trackRingsDescriptors = new List <TrackRings>(); TrackRings[] ringsDescriptors = go.GetComponentsInChildren <TrackRings>(); foreach (TrackRings trackRingDesc in ringsDescriptors) { trackRingsDescriptors.Add(trackRingDesc); TrackLaneRingsManager ringsManager = trackRingDesc.gameObject.AddComponent <TrackLaneRingsManager>(); trackLaneRingsManagers.Add(ringsManager); PlatformManager.SpawnedComponents.Add(ringsManager); TrackLaneRing ring = trackRingDesc.trackLaneRingPrefab.AddComponent <TrackLaneRing>(); PlatformManager.SpawnedComponents.Add(ring); ReflectionUtil.SetPrivateField(ringsManager, "_trackLaneRingPrefab", ring); ReflectionUtil.SetPrivateField(ringsManager, "_ringCount", trackRingDesc.ringCount); ReflectionUtil.SetPrivateField(ringsManager, "_ringPositionStep", trackRingDesc.ringPositionStep); if (trackRingDesc.useRotationEffect) { TrackLaneRingsRotationEffect rotationEffect = trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffect>(); PlatformManager.SpawnedComponents.Add(rotationEffect); ReflectionUtil.SetPrivateField(rotationEffect, "_trackLaneRingsManager", ringsManager); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationAngle", trackRingDesc.startupRotationAngle); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationStep", trackRingDesc.startupRotationStep); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationPropagationSpeed", (int)Math.Round(trackRingDesc.startupRotationPropagationSpeed)); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationFlexySpeed", trackRingDesc.startupRotationFlexySpeed); TrackLaneRingsRotationEffectSpawner rotationEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffectSpawner>(); rotationSpawners.Add(rotationEffectSpawner); PlatformManager.SpawnedComponents.Add(rotationEffectSpawner); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapObjectCallbackController", Plugin.bocc); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.rotationSongEventType); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationStep", trackRingDesc.rotationStep); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationPropagationSpeed", (int)Math.Round(trackRingDesc.rotationPropagationSpeed)); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationFlexySpeed", trackRingDesc.rotationFlexySpeed); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_trackLaneRingsRotationEffect", rotationEffect); } if (trackRingDesc.useStepEffect) { TrackLaneRingsPositionStepEffectSpawner stepEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsPositionStepEffectSpawner>(); stepSpawners.Add(stepEffectSpawner); PlatformManager.SpawnedComponents.Add(stepEffectSpawner); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapObjectCallbackController", Plugin.bocc); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_trackLaneRingsManager", ringsManager); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.stepSongEventType); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_minPositionStep", trackRingDesc.minPositionStep); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_maxPositionStep", trackRingDesc.maxPositionStep); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_moveSpeed", trackRingDesc.moveSpeed); } } }
public static void UpdateEventTubeLightList() { LightSwitchEventEffect[] lightSwitchEvents = Resources.FindObjectsOfTypeAll <LightSwitchEventEffect>(); foreach (LightSwitchEventEffect switchEffect in lightSwitchEvents) { ReflectionUtil.SetPrivateField( switchEffect, "_lights", BloomPrePass.GetLightsWithID(ReflectionUtil.GetPrivateField <int>(switchEffect, "_lightsID")) ); } }
public void UpdateSpectrogramDataProvider() { BasicSpectrogramData[] datas = Resources.FindObjectsOfTypeAll <BasicSpectrogramData>(); if (datas.Length == 0) { return; } BasicSpectrogramData spectrogramData = datas.First(); foreach (SpectrogramColumns specCol in spectrogramColumns) { ReflectionUtil.SetPrivateField(specCol, "_spectrogramData", spectrogramData); } }
public void UpdateSongController() { BeatmapObjectCallbackController beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); if (beatmapObjectCallbackController == null) { return; } foreach (LightRotationEventEffect rotationEffect in lightRotationEffects) { ReflectionUtil.SetPrivateField(rotationEffect, "_beatmapObjectCallbackController", beatmapObjectCallbackController); beatmapObjectCallbackController.beatmapEventDidTriggerEvent += rotationEffect.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger; } }
/// <summary> /// Passes <see cref="BasicSpectrogramData"/> on to all <see cref="SpectrogramColumns"/><br/> /// </summary> internal void UpdateSpectrogramDataProvider() { BasicSpectrogramData[] datas = Resources.FindObjectsOfTypeAll <BasicSpectrogramData>(); if (datas.Length != 0) { BasicSpectrogramData spectrogramData = datas.FirstOrDefault(); if (spectrogramData != null) { foreach (SpectrogramColumns specCol in spectrogramColumns) { ReflectionUtil.SetPrivateField(specCol, "_spectrogramData", spectrogramData); } } } }
public void CreateTubeLights(GameObject go) { if (tbppLights == null) { tbppLights = new List <BloomPrePassLight>(); } if (tubeLightDescriptors == null) { tubeLightDescriptors = new List <TubeLight>(); } TubeLight[] localDescriptors = go.GetComponentsInChildren <TubeLight>(true); if (localDescriptors == null) { return; } foreach (TubeLight tl in localDescriptors) { BloomPrePassLight tubeBloomLight; if (tl.GetComponent <MeshFilter>().mesh.vertexCount == 0) { tubeBloomLight = tl.gameObject.AddComponent <TubeBloomPrePassLight>(); (tubeBloomLight as TubeBloomPrePassLight).Init(); } else { tubeBloomLight = tl.gameObject.AddComponent <MeshBloomPrePassLight>(); (tubeBloomLight as MeshBloomPrePassLight).Init(); } ReflectionUtil.SetPrivateField(tubeBloomLight, "_width", tl.width); ReflectionUtil.SetPrivateField(tubeBloomLight, "_length", tl.length); ReflectionUtil.SetPrivateField(tubeBloomLight, "_center", tl.center); tubeBloomLight.color = tl.color; var prop = typeof(BloomPrePassLight).GetField("_ID", BindingFlags.NonPublic | BindingFlags.Instance); prop.SetValue(tubeBloomLight, (int)tl.lightsID); tbppLights.Add(tubeBloomLight); tubeLightDescriptors.Add(tl); } }
public void FindBeatMapEventController() { BeatmapObjectCallbackController _beatmapObjectCallbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); if (_beatmapObjectCallbackController == null) { return; } foreach (TrackLaneRingsRotationEffectSpawner spawner in rotationSpawners) { ReflectionUtil.SetPrivateField(spawner, "_beatmapObjectCallbackController", _beatmapObjectCallbackController); _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += spawner.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger; } foreach (TrackLaneRingsPositionStepEffectSpawner spawner in stepSpawners) { ReflectionUtil.SetPrivateField(spawner, "_beatmapObjectCallbackController", _beatmapObjectCallbackController); _beatmapObjectCallbackController.beatmapEventDidTriggerEvent += spawner.HandleBeatmapObjectCallbackControllerBeatmapEventDidTrigger; } }
/// <summary> /// Creates <see cref="SpectrogramColumns"/> for each <see cref="Spectrogram"/> on the given <paramref name="gameObject"/> /// </summary> /// <param name="gameObject">What <see cref="GameObject"/> to create <see cref="SpectrogramColumns"/> for</param> internal void CreateColumns(GameObject gameObject) { spectrogramColumns = new List <SpectrogramColumns>(); columnDescriptors = new List <Spectrogram>(); Spectrogram[] localDescriptors = gameObject.GetComponentsInChildren <Spectrogram>(true); foreach (Spectrogram spec in localDescriptors) { SpectrogramColumns specCol = spec.gameObject.AddComponent <SpectrogramColumns>(); PlatformManager.SpawnedComponents.Add(specCol); ReflectionUtil.SetPrivateField(specCol, "_columnPrefab", spec.columnPrefab); ReflectionUtil.SetPrivateField(specCol, "_separator", spec.separator); ReflectionUtil.SetPrivateField(specCol, "_minHeight", spec.minHeight); ReflectionUtil.SetPrivateField(specCol, "_maxHeight", spec.maxHeight); ReflectionUtil.SetPrivateField(specCol, "_columnWidth", spec.columnWidth); ReflectionUtil.SetPrivateField(specCol, "_columnDepth", spec.columnDepth); spectrogramColumns.Add(specCol); columnDescriptors.Add(spec); } }
public void CreateEffects(GameObject go) { if (lightRotationEffects == null) { lightRotationEffects = new List <LightPairRotationEventEffect>(); } if (effectDescriptors == null) { effectDescriptors = new List <PairRotationEventEffect>(); } PairRotationEventEffect[] localDescriptors = go.GetComponentsInChildren <PairRotationEventEffect>(true); if (localDescriptors == null) { return; } // Get the BeatmapObjectCallbackController floating in the level. BeatmapObjectCallbackController beatmapObjectCallbackController = ((BeatmapObjectCallbackController[])GameObject.FindObjectsOfType(typeof(BeatmapObjectCallbackController)))[0]; foreach (PairRotationEventEffect effectDescriptor in localDescriptors) { LightPairRotationEventEffect rotEvent = effectDescriptor.gameObject.AddComponent <LightPairRotationEventEffect>(); PlatformManager.SpawnedComponents.Add(rotEvent); // Convert the effect descriptor into the behaviour from the base game. ReflectionUtil.SetPrivateField(rotEvent, "_eventL", (BeatmapEventType)effectDescriptor.eventTypeL); ReflectionUtil.SetPrivateField(rotEvent, "_eventR", (BeatmapEventType)effectDescriptor.eventTypeR); ReflectionUtil.SetPrivateField(rotEvent, "_rotationVector", effectDescriptor.rotationVector); ReflectionUtil.SetPrivateField(rotEvent, "_overrideRandomValues", false); ReflectionUtil.SetPrivateField(rotEvent, "_startRotation", effectDescriptor.startRotation); ReflectionUtil.SetPrivateField(rotEvent, "_transformL", effectDescriptor.transformL); ReflectionUtil.SetPrivateField(rotEvent, "_transformR", effectDescriptor.transformR); ReflectionUtil.SetPrivateField(rotEvent, "_beatmapObjectCallbackController", beatmapObjectCallbackController); lightRotationEffects.Add(rotEvent); effectDescriptors.Add(effectDescriptor); } }
/*internal static void SetColorToDefault(CustomPlatform currentPlatform) * { * for (int i = 0; i < 16; i++) * { * defaultLightWithIdManager.SetColorForId(i, Color.green); * } * }*/ public static void UpdateEventTubeLightList() { // For some reason the prefab *and* the DiContainer give us a manager that does nothing? var managers = Resources.FindObjectsOfTypeAll <LightWithIdManager>(); var manager = managers.First(it => it.name.Equals("LightWithIdManager")); var lights = PlatformManager.Instance.GetComponentsInChildren <LightWithId>(); foreach (var light in lights) { light.InvokeMethod("OnDisable"); ReflectionUtil.SetPrivateField(light, "_lightManager", manager, typeof(LightWithId)); light.InvokeMethod("OnEnable"); // Hack to prevent null reference exceptions var bppl = light.GetComponent <TubeBloomPrePassLight>(); if (bppl != null) { var lightType = bppl.GetPrivateField <BloomPrePassLightTypeSO>("_lightType", typeof(BloomPrePassLight)); bppl.SetPrivateField("_registeredWithLightType", lightType, typeof(BloomPrePassLight)); } } var bocc = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); var rings = PlatformManager.Instance.GetComponentsInChildren <TrackLaneRingsRotationEffectSpawner>(); foreach (var ring in rings) { ReflectionUtil.SetPrivateField(ring, "_beatmapObjectCallbackController", bocc); } var ringsP = PlatformManager.Instance.GetComponentsInChildren <TrackLaneRingsPositionStepEffectSpawner>(); foreach (var ring in ringsP) { ReflectionUtil.SetPrivateField(ring, "_beatmapObjectCallbackController", bocc); } }
public void CreateTrackRings(GameObject go) { var _container = BSEvents.Instance.diContainer; if (rotationSpawners == null) { rotationSpawners = new List <TrackLaneRingsRotationEffectSpawner>(); } if (stepSpawners == null) { stepSpawners = new List <TrackLaneRingsPositionStepEffectSpawner>(); } if (trackLaneRingsManagers == null) { trackLaneRingsManagers = new List <TrackLaneRingsManager>(); } if (trackRingsDescriptors == null) { trackRingsDescriptors = new List <TrackRings>(); } TrackRings[] ringsDescriptors = go.GetComponentsInChildren <TrackRings>(); foreach (TrackRings trackRingDesc in ringsDescriptors) { trackRingsDescriptors.Add(trackRingDesc); var ringsManager = trackRingDesc.gameObject.AddComponent <TrackLaneRingsManager>(); trackLaneRingsManagers.Add(ringsManager); var ring = trackRingDesc.trackLaneRingPrefab.AddComponent <TrackLaneRing>(); ReflectionUtil.SetPrivateField(ringsManager, "_trackLaneRingPrefab", ring); ReflectionUtil.SetPrivateField(ringsManager, "_ringCount", trackRingDesc.ringCount); ReflectionUtil.SetPrivateField(ringsManager, "_ringPositionStep", trackRingDesc.ringPositionStep); var bocc = new BeatmapObjectCallbackController(); if (trackRingDesc.useRotationEffect) { var rotationEffect = _container.InstantiateComponent <TrackLaneRingsRotationEffect>(trackRingDesc.gameObject); //var rotationEffect = trackRingDesc.gameObject.AddComponent<TrackLaneRingsRotationEffect>(); ReflectionUtil.SetPrivateField(rotationEffect, "_trackLaneRingsManager", ringsManager); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationAngle", trackRingDesc.startupRotationAngle); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationStep", trackRingDesc.startupRotationStep); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationPropagationSpeed", trackRingDesc.startupRotationPropagationSpeed); ReflectionUtil.SetPrivateField(rotationEffect, "_startupRotationFlexySpeed", trackRingDesc.startupRotationFlexySpeed); //var rotationEffectSpawner = _container.InstantiateComponent<TrackLaneRingsRotationEffectSpawner>(trackRingDesc.gameObject); var rotationEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsRotationEffectSpawner>(); rotationSpawners.Add(rotationEffectSpawner); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.rotationSongEventType); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationStep", trackRingDesc.rotationStep); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationPropagationSpeed", trackRingDesc.rotationPropagationSpeed); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_rotationFlexySpeed", trackRingDesc.rotationFlexySpeed); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_trackLaneRingsRotationEffect", rotationEffect); ReflectionUtil.SetPrivateField(rotationEffectSpawner, "_beatmapObjectCallbackController", bocc); } if (trackRingDesc.useStepEffect) { //var stepEffectSpawner = _container.InstantiateComponent<TrackLaneRingsPositionStepEffectSpawner>(trackRingDesc.gameObject); var stepEffectSpawner = trackRingDesc.gameObject.AddComponent <TrackLaneRingsPositionStepEffectSpawner>(); stepSpawners.Add(stepEffectSpawner); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_trackLaneRingsManager", ringsManager); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapEventType", (BeatmapEventType)trackRingDesc.stepSongEventType); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_minPositionStep", trackRingDesc.minPositionStep); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_maxPositionStep", trackRingDesc.maxPositionStep); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_moveSpeed", trackRingDesc.moveSpeed); ReflectionUtil.SetPrivateField(stepEffectSpawner, "_beatmapObjectCallbackController", bocc); } } }
public static void SetupTubeLight(TubeLight tl, DiContainer _container) { var prefab = Resources.FindObjectsOfTypeAll <TubeBloomPrePassLight>().First(x => x.name == "Neon"); // Don't init twice if (tl.tubeBloomLight != null) { return; } var tubeBloomLight = _container.InstantiatePrefabForComponent <TubeBloomPrePassLight>(prefab); tubeBloomLight.name = "Tube Light " + z++; tl.tubeBloomLight = tubeBloomLight; tubeBloomLight.transform.SetParent(tl.transform); tubeBloomLight.transform.localRotation = Quaternion.identity; tubeBloomLight.transform.localPosition = Vector3.zero; tubeBloomLight.transform.localScale = new Vector3(1 / tl.transform.lossyScale.x, 1 / tl.transform.lossyScale.y, 1 / tl.transform.lossyScale.z); var withId = tubeBloomLight.GetComponent <TubeBloomPrePassLightWithId>(); if (tl.GetComponent <MeshFilter>().mesh.vertexCount == 0) { tl.GetComponent <MeshRenderer>().enabled = false; } else { // swap for MeshBloomPrePassLight tubeBloomLight.gameObject.SetActive(false); MeshBloomPrePassLight meshbloom = ReflectionUtil.CopyComponent(tubeBloomLight, typeof(TubeBloomPrePassLight), typeof(MeshBloomPrePassLight), tubeBloomLight.gameObject) as MeshBloomPrePassLight; meshbloom.Init(tl.GetComponent <Renderer>()); MeshBloomPrePassLightWithId meshbloomid = ReflectionUtil.CopyComponent(withId, typeof(TubeBloomPrePassLightWithId), typeof(MeshBloomPrePassLightWithId), withId.gameObject) as MeshBloomPrePassLightWithId; Destroy(withId); withId = meshbloomid; tubeBloomLight.gameObject.SetActive(true); Destroy(tubeBloomLight); tubeBloomLight = meshbloom; } var setColorToDefault = Bind(SetColorToDefault, tl, withId); tl.onEnable += () => { BSEvents.menuSceneLoaded += setColorToDefault; BSEvents.menuSceneLoadedFresh += setColorToDefault; setColorToDefault(); }; tl.onDisable += () => { BSEvents.menuSceneLoaded -= setColorToDefault; BSEvents.menuSceneLoadedFresh -= setColorToDefault; }; var lightType = tubeBloomLight.GetPrivateField <BloomPrePassLightTypeSO>("_lightType", typeof(BloomPrePassLight)); //tubeBloomLight.SetPrivateField("_lightType", lightType, typeof(BloomPrePassLight)); tubeBloomLight.SetPrivateField("_registeredWithLightType", lightType, typeof(BloomPrePassLight)); tubeBloomLight.SetPrivateField("_width", tl.width * 2); tubeBloomLight.SetPrivateField("_length", tl.length); tubeBloomLight.SetPrivateField("_center", tl.center); tubeBloomLight.SetPrivateField("_bloomFogIntensityMultiplier", 0.3f); tubeBloomLight.SetPrivateField("_transform", tubeBloomLight.transform); var parabox = tubeBloomLight.GetComponentInChildren <ParametricBoxController>(); tubeBloomLight.SetPrivateField("_parametricBoxController", parabox); var parasprite = tubeBloomLight.GetComponentInChildren <Parametric3SliceSpriteController>(); tubeBloomLight.SetPrivateField("_dynamic3SliceSprite", parasprite); parasprite.InvokeMethod("Init"); parasprite.GetComponent <MeshRenderer>().enabled = false; ReflectionUtil.SetPrivateField(withId, "_tubeBloomPrePassLight", tubeBloomLight); ReflectionUtil.SetPrivateField(withId, "_ID", (int)tl.lightsID, typeof(LightWithId)); withId.SetPrivateField("_lightManager", defaultLightWithIdManager, typeof(LightWithId)); tubeBloomLight.InvokeMethod("Refresh"); }