269 lines
6.8 KiB
C#
269 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// Token: 0x02000068 RID: 104
|
|
public class InteriorLights : MonoBehaviour
|
|
{
|
|
// Token: 0x06000B6D RID: 2925 RVA: 0x000DEC34 File Offset: 0x000DCE34
|
|
private void Start()
|
|
{
|
|
foreach (object obj in base.transform)
|
|
{
|
|
Transform transform = (Transform)obj;
|
|
if (transform.gameObject.name.Contains("ompanion"))
|
|
{
|
|
this.companionPoints.Add(transform);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000B6E RID: 2926 RVA: 0x000DECAC File Offset: 0x000DCEAC
|
|
public void LoadScene()
|
|
{
|
|
this.lightCount = this.lightTransforms.Count;
|
|
}
|
|
|
|
// Token: 0x06000B6F RID: 2927 RVA: 0x000DECC0 File Offset: 0x000DCEC0
|
|
public void TurnOnLights()
|
|
{
|
|
foreach (Light light in this.lights)
|
|
{
|
|
light.enabled = true;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000B70 RID: 2928 RVA: 0x000DED14 File Offset: 0x000DCF14
|
|
public void TurnOffLights()
|
|
{
|
|
foreach (Light light in this.lights)
|
|
{
|
|
light.enabled = false;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000B71 RID: 2929 RVA: 0x000DED68 File Offset: 0x000DCF68
|
|
public void SetUpCompanionNodes()
|
|
{
|
|
if (this.companionPoints.Count > 0)
|
|
{
|
|
int num = -1;
|
|
float num2 = 20f;
|
|
Vector3 vector = Vector3.zero;
|
|
int count = this.companionPoints.Count;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
Transform transform = this.companionPoints[i];
|
|
int num3 = 0;
|
|
foreach (object obj in transform)
|
|
{
|
|
Transform transform2 = (Transform)obj;
|
|
if (transform != transform2)
|
|
{
|
|
vector += transform2.position;
|
|
num3++;
|
|
}
|
|
}
|
|
if (num3 > 0)
|
|
{
|
|
vector /= (float)num3;
|
|
}
|
|
float num4 = Vector3.Distance(Links.x.main.tr.position, vector);
|
|
if (num4 < num2)
|
|
{
|
|
num2 = num4;
|
|
num = i;
|
|
}
|
|
}
|
|
if (num <= -1)
|
|
{
|
|
Links.x.fellowship.ClearCompanionNodes();
|
|
return;
|
|
}
|
|
Transform transform3 = this.companionPoints[num];
|
|
int num5 = 0;
|
|
foreach (object obj2 in transform3)
|
|
{
|
|
Transform transform4 = (Transform)obj2;
|
|
if (transform3 != transform4)
|
|
{
|
|
num5++;
|
|
}
|
|
}
|
|
if (num5 == 1)
|
|
{
|
|
Links.x.fellowship.SetUpCompanionNodes(transform3.GetChild(0), null, null, null);
|
|
}
|
|
if (num5 == 2)
|
|
{
|
|
Links.x.fellowship.SetUpCompanionNodes(transform3.GetChild(0), transform3.GetChild(1), null, null);
|
|
}
|
|
if (num5 == 3)
|
|
{
|
|
Links.x.fellowship.SetUpCompanionNodes(transform3.GetChild(0), transform3.GetChild(1), transform3.GetChild(2), null);
|
|
}
|
|
if (num5 == 4)
|
|
{
|
|
Links.x.fellowship.SetUpCompanionNodes(transform3.GetChild(0), transform3.GetChild(1), transform3.GetChild(2), transform3.GetChild(3));
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Links.x.fellowship.ClearCompanionNodes();
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000B72 RID: 2930 RVA: 0x000DEF9C File Offset: 0x000DD19C
|
|
public void ActiveLights()
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
Vector3 vector = Vector3.zero;
|
|
Color color = Color.black;
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
if (i < this.lights.Count)
|
|
{
|
|
num = this.lights[i].range;
|
|
color = this.lights[i].color;
|
|
vector = this.lightTransforms[i].position;
|
|
num2 = this.lights[i].intensity / 2f;
|
|
}
|
|
if (i == 0)
|
|
{
|
|
Shader.SetGlobalVector("_InteriorLightPosition0", vector);
|
|
Shader.SetGlobalVector("_InteriorLightColor0", color * num2);
|
|
Shader.SetGlobalFloat("_InteriorLightRange0", num);
|
|
}
|
|
if (i == 1)
|
|
{
|
|
Shader.SetGlobalVector("_InteriorLightPosition1", vector);
|
|
Shader.SetGlobalVector("_InteriorLightColor1", color * num2);
|
|
Shader.SetGlobalFloat("_InteriorLightRange1", num);
|
|
}
|
|
if (i == 2)
|
|
{
|
|
Shader.SetGlobalVector("_InteriorLightPosition2", vector);
|
|
Shader.SetGlobalVector("_InteriorLightColor2", color * num2);
|
|
Shader.SetGlobalFloat("_InteriorLightRange2", num);
|
|
}
|
|
if (i == 3)
|
|
{
|
|
Shader.SetGlobalVector("_InteriorLightPosition3", vector);
|
|
Shader.SetGlobalVector("_InteriorLightColor3", color * num2);
|
|
Shader.SetGlobalFloat("_InteriorLightRange3", num);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000B73 RID: 2931 RVA: 0x000DF108 File Offset: 0x000DD308
|
|
public void InactiveLights()
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
Color black = Color.black;
|
|
float num = 0f;
|
|
Shader.SetGlobalVector("_InteriorLightPosition0", zero);
|
|
Shader.SetGlobalVector("_InteriorLightColor0", black);
|
|
Shader.SetGlobalFloat("_InteriorLightRange0", num);
|
|
Shader.SetGlobalVector("_InteriorLightPosition1", zero);
|
|
Shader.SetGlobalVector("_InteriorLightColor1", black);
|
|
Shader.SetGlobalFloat("_InteriorLightRange1", num);
|
|
Shader.SetGlobalVector("_InteriorLightPosition2", zero);
|
|
Shader.SetGlobalVector("_InteriorLightColor2", black);
|
|
Shader.SetGlobalFloat("_InteriorLightRange2", num);
|
|
Shader.SetGlobalVector("_InteriorLightPosition3", zero);
|
|
Shader.SetGlobalVector("_InteriorLightColor3", black);
|
|
Shader.SetGlobalFloat("_InteriorLightRange3", num);
|
|
}
|
|
|
|
// Token: 0x06000B74 RID: 2932 RVA: 0x000DF1D4 File Offset: 0x000DD3D4
|
|
public void GetNearest(Vector3 center, out Vector3 position, out int index, out int index1, out int index2, out int index3, out Light nearestLight)
|
|
{
|
|
position = Vector3.zero;
|
|
index = -1;
|
|
index1 = -1;
|
|
index2 = -1;
|
|
index3 = -1;
|
|
nearestLight = null;
|
|
if (this.lightCount == 0)
|
|
{
|
|
return;
|
|
}
|
|
if (this.lightCount == 1)
|
|
{
|
|
position = this.lightTransforms[0].position;
|
|
nearestLight = this.lights[0];
|
|
index = 0;
|
|
return;
|
|
}
|
|
if (this.lightCount > 4)
|
|
{
|
|
this.lightCount = 4;
|
|
}
|
|
float num = float.PositiveInfinity;
|
|
for (int i = 0; i < this.lightCount; i++)
|
|
{
|
|
float sqrMagnitude = (this.lightTransforms[i].position - center).sqrMagnitude;
|
|
if (sqrMagnitude < num)
|
|
{
|
|
num = sqrMagnitude;
|
|
position = this.lightTransforms[i].position;
|
|
index = i;
|
|
nearestLight = this.lights[i];
|
|
}
|
|
}
|
|
num = float.PositiveInfinity;
|
|
for (int j = 0; j < this.lightCount; j++)
|
|
{
|
|
if (index != j)
|
|
{
|
|
float sqrMagnitude2 = (this.lightTransforms[j].position - center).sqrMagnitude;
|
|
if (sqrMagnitude2 < num)
|
|
{
|
|
num = sqrMagnitude2;
|
|
index1 = j;
|
|
}
|
|
}
|
|
}
|
|
num = float.PositiveInfinity;
|
|
for (int k = 0; k < this.lightCount; k++)
|
|
{
|
|
if (index != k && index1 != k)
|
|
{
|
|
float sqrMagnitude3 = (this.lightTransforms[k].position - center).sqrMagnitude;
|
|
if (sqrMagnitude3 < num)
|
|
{
|
|
num = sqrMagnitude3;
|
|
index2 = k;
|
|
}
|
|
}
|
|
}
|
|
num = float.PositiveInfinity;
|
|
for (int l = 0; l < this.lightCount; l++)
|
|
{
|
|
if (index != l && index1 != l && index2 != l)
|
|
{
|
|
float sqrMagnitude4 = (this.lightTransforms[l].position - center).sqrMagnitude;
|
|
if (sqrMagnitude4 < num)
|
|
{
|
|
num = sqrMagnitude4;
|
|
index3 = l;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x040010F6 RID: 4342
|
|
public List<Transform> lightTransforms = new List<Transform>();
|
|
|
|
// Token: 0x040010F7 RID: 4343
|
|
public List<Light> lights = new List<Light>();
|
|
|
|
// Token: 0x040010F8 RID: 4344
|
|
public int lightCount = -1;
|
|
|
|
// Token: 0x040010F9 RID: 4345
|
|
public List<Transform> companionPoints = new List<Transform>();
|
|
}
|