Skip to content

Commit

Permalink
Fixes for 1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Nov 13, 2020
1 parent 8b7ec72 commit dd14c57
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
24 changes: 15 additions & 9 deletions Source/CustomAvatar/Lighting/DynamicLightingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void OnDestroy()

private void CreateLights()
{
List<LightWithId>[] lightsWithId = _lightManager.GetPrivateField<List<LightWithId>[]>("_lights");
List<ILightWithId>[] lightsWithId = _lightManager.GetPrivateField<List<ILightWithId>[]>("_lights");
int maxLightId = _lightManager.GetPrivateField<int>("kMaxLightId");

_lights = new List<DynamicLight>[maxLightId + 1];
Expand All @@ -79,10 +79,12 @@ private void CreateLights()
{
if (lightsWithId[id] == null) continue;

foreach (LightWithId lightWithId in lightsWithId[id])
foreach (ILightWithId lightWithId in lightsWithId[id])
{
foreach (DirectionalLight directionalLight in lightWithId.GetComponentsInChildren<DirectionalLight>())
if (lightWithId is DirectionalLightWithId directionalLightWithId)
{
DirectionalLight directionalLight = directionalLightWithId.GetPrivateField<DirectionalLight>("_light");

Light light = new GameObject("DynamicDirectionalLight").AddComponent<Light>();

light.type = LightType.Directional;
Expand All @@ -104,8 +106,10 @@ private void CreateLights()
_directionalLights[id].Add(light);
}

foreach (TubeBloomPrePassLight tubeLight in lightWithId.GetComponentsInChildren<TubeBloomPrePassLight>())
if (lightWithId is TubeBloomPrePassLightWithId tubeLightWithId)
{
TubeBloomPrePassLight tubeLight = tubeLightWithId.GetPrivateField<TubeBloomPrePassLight>("_tubeBloomPrePassLight");

Light light = new GameObject("DynamicTubeBloomPrePassLight").AddComponent<Light>();

light.type = LightType.Directional;
Expand Down Expand Up @@ -246,6 +250,7 @@ public Quaternion rotation

private readonly Light _unityLight;
private readonly float _colorAlphaMultiplier;
private readonly float _lightWidthMultiplier;
private readonly float _bloomFogIntensityMultiplier;

private float _intensity;
Expand All @@ -256,22 +261,23 @@ public DynamicLight(TubeBloomPrePassLight tubeLight, Light unityLight)
this.tubeLight = tubeLight;
this._unityLight = unityLight;

width = tubeLight.GetPrivateField<float>("_width");
length = tubeLight.GetPrivateField<float>("_length");
width = tubeLight.width;
length = tubeLight.length;
center = tubeLight.GetPrivateField<float>("_center");

_colorAlphaMultiplier = tubeLight.GetPrivateField<float>("_colorAlphaMultiplier");
_bloomFogIntensityMultiplier = tubeLight.GetPrivateField<float>("_bloomFogIntensityMultiplier");
_lightWidthMultiplier = tubeLight.lightWidthMultiplier;
_bloomFogIntensityMultiplier = tubeLight.bloomFogIntensityMultiplier;

offset = (0.5f - center) * length * Vector3.up;
}

private void UpdateLight()
{
_unityLight.color = _color;
_unityLight.intensity = _intensity * width * _colorAlphaMultiplier * _bloomFogIntensityMultiplier * _color.a * 5f;
_unityLight.intensity = _intensity * width * _colorAlphaMultiplier * _lightWidthMultiplier * _bloomFogIntensityMultiplier * _color.a * 5f;

_unityLight.enabled = _unityLight.intensity > 0.01f;
_unityLight.enabled = _unityLight.intensity > 0.001f;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/CustomAvatar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.0.2")]
[assembly: AssemblyFileVersion("5.0.2")]
[assembly: AssemblyVersion("5.0.3")]
[assembly: AssemblyFileVersion("5.0.3")]
4 changes: 2 additions & 2 deletions Source/CustomAvatar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json",
"author": "Custom Avatars Contributors",
"description": "A plugin to let you use custom avatars in Beat Saber.",
"gameVersion": "1.12.2",
"gameVersion": "1.13.0",
"id": "CustomAvatar",
"icon": "CustomAvatar.Resources.icon.png",
"name": "Custom Avatars",
"version": "5.0.2+dev",
"version": "5.0.3+dev",
"dependsOn": {
"BSIPA": "^4.0.0",
"BeatSaberMarkupLanguage": "^1.4.0",
Expand Down

0 comments on commit dd14c57

Please sign in to comment.