1980 lines
68 KiB
C#
1980 lines
68 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
public class VolumeClouds_SM : MonoBehaviour
|
|
{
|
|
private ParticleSystem ShurikenParticle;
|
|
|
|
private bool useShuriken = true;
|
|
|
|
private ParticleSystemRenderer PrenderS;
|
|
|
|
public float renewHeightPercent = 99.2f;
|
|
|
|
public float renewFadeOutSpeed = 1f;
|
|
|
|
public float renewFadeInSpeed = 1f;
|
|
|
|
public bool boxClouds;
|
|
|
|
public GameObject BoxesHolder;
|
|
|
|
public bool renewAboveHeight;
|
|
|
|
public float renewHeight = 500f;
|
|
|
|
public bool shadows_created;
|
|
|
|
public bool DecoupledWind;
|
|
|
|
public bool DecoupledColor;
|
|
|
|
public bool DifferentialMotion;
|
|
|
|
public float MaxDiffSpeed = 0.02f;
|
|
|
|
public float MaxDiffOffset;
|
|
|
|
public float LightShaderModifier;
|
|
|
|
public float minLightShaderModifier;
|
|
|
|
public float GlowShaderModifier;
|
|
|
|
public float IntensityShaderModifier;
|
|
|
|
public float ModifierApplicationSpeed = 0.1f;
|
|
|
|
public float ModifierApplMinSpeed = 0.1f;
|
|
|
|
[HideInInspector]
|
|
public GameObject Quad;
|
|
|
|
[HideInInspector]
|
|
public List<Transform> Quads;
|
|
|
|
public Light SunLight;
|
|
|
|
public Light MoonLight;
|
|
|
|
public bool Accumulate;
|
|
|
|
public float AccumPercent = 0.04f;
|
|
|
|
public float AccumFactor = 1f;
|
|
|
|
public bool StabilizeRoll;
|
|
|
|
public bool StableRollMethod2;
|
|
|
|
public bool StableRollAllAxis;
|
|
|
|
private Vector3 prev_cam_for;
|
|
|
|
private bool sortedInit;
|
|
|
|
public float angle1 = 35f;
|
|
|
|
public float angle2 = 18f;
|
|
|
|
public float NearCloudDist = 50f;
|
|
|
|
public float CloudBedToThisDist;
|
|
|
|
public bool Divide_lightning;
|
|
|
|
public int LightningDivider = 5;
|
|
|
|
public bool AutoScale;
|
|
|
|
public bool DestroyOnfadeOut;
|
|
|
|
public bool FadeOutOnBoundary;
|
|
|
|
public bool ScatterShaderUpdate;
|
|
|
|
public Material ScatterMat;
|
|
|
|
public float fog_depth = 0.29f;
|
|
|
|
public float reileigh = 1.3f;
|
|
|
|
public float mieCoefficient = 1f;
|
|
|
|
public float mieDirectionalG = 0.1f;
|
|
|
|
public float ExposureBias = 0.11f;
|
|
|
|
private const float n = 1.0003f;
|
|
|
|
private const float N = 2.545E+25f;
|
|
|
|
private const float pn = 0.035f;
|
|
|
|
public Vector3 lambda = new Vector3(6.8E-07f, 5.5E-07f, 4.5E-07f);
|
|
|
|
public Vector3 K = new Vector3(0.9f, 0.5f, 0.5f);
|
|
|
|
public bool VerticalForm;
|
|
|
|
public float YScaleDiff = 0.6f;
|
|
|
|
public Vector3 MaxCloudDist = new Vector3(10f, 20f, 0f);
|
|
|
|
public float Yspread = 2f;
|
|
|
|
public Color HeightTint;
|
|
|
|
public bool SmoothIn;
|
|
|
|
public bool SmoothOut;
|
|
|
|
public float SmoothInSpeed;
|
|
|
|
public float SmoothoutSpeed;
|
|
|
|
public float SmoothInRate = 0.15f;
|
|
|
|
public float SmoothOutRate = 0.15f;
|
|
|
|
public float max_fade_speed = 2.5f;
|
|
|
|
public float max_smooth_out_time = 1f;
|
|
|
|
private float current_smooth_out_time;
|
|
|
|
public float fade_in_time = 2.5f;
|
|
|
|
public float current_fadein_time;
|
|
|
|
public bool EnableLOD;
|
|
|
|
public float LOD_send_height = -10000f;
|
|
|
|
public int[] ParticlesLODed;
|
|
|
|
public float LodMaxYDiff = 240f;
|
|
|
|
public float LodMaxHDiff = 1700f;
|
|
|
|
public float LODFadeInSpeed = 5f;
|
|
|
|
public float LODFadeOutSpeed = 5f;
|
|
|
|
public float LODMinDist = 80f;
|
|
|
|
public bool CloudWaves;
|
|
|
|
public float WaveFreq = 0.22f;
|
|
|
|
public bool Moon_light;
|
|
|
|
public Color Moon_light_color = Color.gray;
|
|
|
|
public Color Moon_dark_color = Color.gray * 0.9f;
|
|
|
|
public bool Override_init_color;
|
|
|
|
public Color Override_color = Color.gray;
|
|
|
|
public bool Day_cycle;
|
|
|
|
public SkyMasterManager SkyManager;
|
|
|
|
public Color Day_base_col = Color.grey;
|
|
|
|
public Color Day_sun_col = Color.white;
|
|
|
|
public Color Dawn_base_col = new Color(31f / 51f, 23f / 51f, 26f / 51f, 1f);
|
|
|
|
public Color Dawn_sun_col = new Color(49f / 51f, 0.7647059f, 41f / 51f, 1f);
|
|
|
|
public Color Dusk_base_col = new Color(22f / 85f, 0f, 3f / 85f, 1f);
|
|
|
|
public Color Dusk_sun_col = new Color(0.9137255f, 0.2901961f, 39f / 85f, 1f);
|
|
|
|
public Color Night_base_col = Color.grey;
|
|
|
|
public Color Night_moon_col = Color.white;
|
|
|
|
public bool Add_shadows;
|
|
|
|
private List<Transform> Shadow_planes = new List<Transform>();
|
|
|
|
private int alternate = 1;
|
|
|
|
public bool Use2DCheck;
|
|
|
|
public int max_divider = 1;
|
|
|
|
private float Cloud_update_current;
|
|
|
|
public float Cloud_spread_delay = 1f;
|
|
|
|
public int method = 3;
|
|
|
|
public bool Turbulent;
|
|
|
|
public bool Flatten_below;
|
|
|
|
public List<Vector3> ShaftCenters;
|
|
|
|
public List<Transform> SunShafts;
|
|
|
|
public bool Beam_Occlusion;
|
|
|
|
public bool Smooth_mat_trans;
|
|
|
|
public float Appear_Beam_speed = 2f;
|
|
|
|
public float Disappear_Beam_speed = 2f;
|
|
|
|
public List<Vector3> ShaftScale;
|
|
|
|
public float Beam_length = 300f;
|
|
|
|
public bool Scale_beams;
|
|
|
|
public bool Scale_on_collision;
|
|
|
|
public float Offset_col_factor = 1f;
|
|
|
|
public bool Diminish_beams;
|
|
|
|
public bool Override_sun;
|
|
|
|
public float Cut_height;
|
|
|
|
public bool Restore_on_bound;
|
|
|
|
public bool Disable_on_bound;
|
|
|
|
public float Bound = 9000f;
|
|
|
|
public bool destroy_on_end;
|
|
|
|
public bool clone_on_end;
|
|
|
|
public bool cloned;
|
|
|
|
public List<Vector3> Centers;
|
|
|
|
public List<Vector3> Centers_Init;
|
|
|
|
public float speed = 0.5f;
|
|
|
|
public float multiplier = 5f;
|
|
|
|
public Vector3 wind = new Vector3(1f, 1f, 1f);
|
|
|
|
public bool Get_wind_direction;
|
|
|
|
public GameObject Wind_holder;
|
|
|
|
public GameObject Rain_holder;
|
|
|
|
public GameObject Lightning_holder;
|
|
|
|
public GameObject Shadow_holder;
|
|
|
|
public float max_bed_corner = 1000f;
|
|
|
|
public float min_bed_corner;
|
|
|
|
public float cloud_bed_heigh = 500f;
|
|
|
|
public Color MainColor;
|
|
|
|
public Color SunColor;
|
|
|
|
public int divider = 10;
|
|
|
|
public float Sun_exposure = 2f;
|
|
|
|
public Transform sun_transf;
|
|
|
|
private Transform keep_sun_transf;
|
|
|
|
public Transform moon_transf;
|
|
|
|
private Transform Cam_transf;
|
|
|
|
private Transform This_transf;
|
|
|
|
private Color MainColor_init;
|
|
|
|
private float start_beam_transp = 0.27f;
|
|
|
|
private float Prev_time;
|
|
|
|
public float UpdateInterval = 1f;
|
|
|
|
private bool init_centers;
|
|
|
|
private Vector3 Prev_cam_rot;
|
|
|
|
public float color_speed = 0.5f;
|
|
|
|
public float cloud_scale = 50f;
|
|
|
|
public float global_cloud_scale = 1000f;
|
|
|
|
public Color Global_tint = new Color(0f, 0f, 0f, 0f);
|
|
|
|
public bool Variant_cloud_size;
|
|
|
|
private List<float> Scale_per_cloud;
|
|
|
|
public float cloud_min_scale = 0.8f;
|
|
|
|
public float cloud_max_scale = 2f;
|
|
|
|
public bool Sorted;
|
|
|
|
private bool Init;
|
|
|
|
private int Init_color;
|
|
|
|
public float Delay_lerp = 10000f;
|
|
|
|
public bool Sun_dist_on;
|
|
|
|
private Light Sun_Light;
|
|
|
|
public bool Grab_sun_color;
|
|
|
|
public bool Grab_sun_intensity;
|
|
|
|
public bool Grab_sun_angle;
|
|
|
|
public float Day_light_Intensity = 3f;
|
|
|
|
public float Sun_angle_influence = 0.01f;
|
|
|
|
public bool Look_at_camera;
|
|
|
|
public Vector3 Beams_camera_target_offset = new Vector3(0f, 0f, 0f);
|
|
|
|
private float prev_intensity;
|
|
|
|
private bool Got_shaft_items;
|
|
|
|
private List<Renderer> Shafts_renderes;
|
|
|
|
private float Shaft_update_current;
|
|
|
|
public float Occlusion_sort_delay = 1f;
|
|
|
|
private Quaternion prev_Rot;
|
|
|
|
public bool Debug_mode;
|
|
|
|
public bool Use_audio;
|
|
|
|
public AudioClip RainSound;
|
|
|
|
public AudioSource CloudAudioSource;
|
|
|
|
public float AudiofadeSpeed = 0.025f;
|
|
|
|
public float MaxSoundVol = 0.1f;
|
|
|
|
private ParticleSystem.Particle[] particles;
|
|
|
|
public List<int> CenterIDs = new List<int>();
|
|
|
|
public int DecoupledCounter;
|
|
|
|
public void convertToShuriken()
|
|
{
|
|
}
|
|
|
|
public void ScaleClouds(float WorldScale, float VCloudCoverFac, float VCloudSizeFac, float VCloudCSizeFac)
|
|
{
|
|
ParticleSystem component = base.gameObject.GetComponent<ParticleSystem>();
|
|
if (component != null)
|
|
{
|
|
ParticleSystem.MainModule main = component.main;
|
|
main.startSizeMultiplier = main.startSizeMultiplier * (WorldScale / 20f) * VCloudSizeFac;
|
|
}
|
|
if (VCloudCoverFac > 0f && (int)((float)divider * VCloudCoverFac) > 10)
|
|
{
|
|
divider = (int)((float)divider * VCloudCoverFac);
|
|
}
|
|
min_bed_corner *= WorldScale / 20f;
|
|
max_bed_corner *= WorldScale / 20f;
|
|
cloud_bed_heigh *= WorldScale / 20f;
|
|
cloud_scale *= WorldScale / 20f;
|
|
global_cloud_scale *= WorldScale / 20f;
|
|
YScaleDiff *= WorldScale / 20f;
|
|
Yspread *= WorldScale / 20f;
|
|
LODMinDist *= WorldScale / 20f;
|
|
LodMaxHDiff *= WorldScale / 20f;
|
|
LodMaxYDiff *= WorldScale / 20f;
|
|
cloud_min_scale *= WorldScale / 20f;
|
|
cloud_max_scale = cloud_max_scale * (WorldScale / 20f) * VCloudCSizeFac;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (SkyManager != null)
|
|
{
|
|
SunLight = SkyManager.SUN_LIGHT.GetComponent<Light>();
|
|
MoonLight = SkyManager.MOON_LIGHT.GetComponent<Light>();
|
|
}
|
|
if (SkyManager != null && ScatterMat != null)
|
|
{
|
|
if ((SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 0f) | (!SkyManager.AutoSunPosition && ((SkyManager.Current_Time > 9f + SkyManager.Shift_dawn) & (SkyManager.Current_Time <= 21.9f + SkyManager.Shift_dawn))))
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.SunObj.transform.forward.normalized);
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), SunLight.color, 0.5f * Time.deltaTime));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.MoonObj.transform.forward.normalized);
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), MoonLight.color, 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
if (GetComponent<ParticleSystem>() != null)
|
|
{
|
|
ScatterMat = GetComponent<ParticleSystemRenderer>().material;
|
|
PrenderS = base.gameObject.GetComponent<ParticleSystemRenderer>();
|
|
ShurikenParticle = GetComponent<ParticleSystem>();
|
|
}
|
|
if (PrenderS != null)
|
|
{
|
|
PrenderS.sortMode = ParticleSystemSortMode.Distance;
|
|
}
|
|
prev_cam_for = Camera.main.transform.forward;
|
|
if (divider % 2 == 1)
|
|
{
|
|
divider++;
|
|
}
|
|
This_transf = base.transform;
|
|
Cam_transf = Camera.main.transform;
|
|
Prev_cam_rot = Cam_transf.eulerAngles;
|
|
Centers = new List<Vector3>();
|
|
if (cloned)
|
|
{
|
|
cloned = false;
|
|
Centers = Centers_Init;
|
|
Debug.Log("ppp");
|
|
}
|
|
Centers_Init = new List<Vector3>();
|
|
Centers.Add(This_transf.position);
|
|
Centers_Init.Add(This_transf.position);
|
|
Scale_per_cloud = new List<float>();
|
|
if (Variant_cloud_size)
|
|
{
|
|
Scale_per_cloud.Add(UnityEngine.Random.Range(cloud_min_scale, cloud_max_scale));
|
|
}
|
|
else
|
|
{
|
|
Scale_per_cloud.Add(1f);
|
|
}
|
|
Collider[] array = null;
|
|
if (boxClouds && BoxesHolder != null && BoxesHolder.transform.childCount > 0)
|
|
{
|
|
array = BoxesHolder.GetComponentsInChildren<Collider>();
|
|
}
|
|
int num = 0;
|
|
for (int i = 0; i < divider - 1; i++)
|
|
{
|
|
if (Accumulate)
|
|
{
|
|
if (num == 0)
|
|
{
|
|
Centers.Add(new Vector3(UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.x, UnityEngine.Random.Range(This_transf.position.y, This_transf.position.y + cloud_bed_heigh), UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.z));
|
|
num++;
|
|
}
|
|
else
|
|
{
|
|
Centers.Add(new Vector3(UnityEngine.Random.Range(cloud_min_scale * cloud_scale * AccumFactor, cloud_max_scale * cloud_scale * AccumFactor) + Centers[i - 1].x, UnityEngine.Random.Range(This_transf.position.y, Centers[i - 1].y + cloud_bed_heigh), UnityEngine.Random.Range(cloud_min_scale * cloud_scale * AccumFactor, cloud_max_scale * cloud_scale * AccumFactor) + Centers[i - 1].z));
|
|
num++;
|
|
if ((float)num > (float)divider * AccumPercent)
|
|
{
|
|
num = 0;
|
|
}
|
|
}
|
|
}
|
|
else if (boxClouds && BoxesHolder != null && BoxesHolder.transform.childCount > 0)
|
|
{
|
|
if (array.Length - 1 < i)
|
|
{
|
|
Centers.Add(new Vector3(UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.x, UnityEngine.Random.Range(This_transf.position.y, This_transf.position.y + cloud_bed_heigh), UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.z));
|
|
}
|
|
else
|
|
{
|
|
Centers.Add(array[i].transform.position);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Centers.Add(new Vector3(UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.x, UnityEngine.Random.Range(This_transf.position.y, This_transf.position.y + cloud_bed_heigh), UnityEngine.Random.Range(min_bed_corner, max_bed_corner) + This_transf.position.z));
|
|
}
|
|
Centers_Init.Add(Centers[i]);
|
|
if (Variant_cloud_size)
|
|
{
|
|
Scale_per_cloud.Add(UnityEngine.Random.Range(cloud_min_scale, cloud_max_scale));
|
|
}
|
|
else
|
|
{
|
|
Scale_per_cloud.Add(1f);
|
|
}
|
|
}
|
|
if (boxClouds && BoxesHolder != null && BoxesHolder.transform.childCount > 0)
|
|
{
|
|
BoxesHolder.SetActive(value: false);
|
|
}
|
|
Prev_time = Time.fixedTime;
|
|
if (sun_transf != null)
|
|
{
|
|
Sun_Light = sun_transf.gameObject.GetComponent<Light>();
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Please add the sun object to Sun_Trasf script parameter");
|
|
}
|
|
if (Grab_sun_color)
|
|
{
|
|
SunColor = Sun_Light.color;
|
|
}
|
|
prev_intensity = Sun_Light.intensity;
|
|
MainColor_init = MainColor;
|
|
Shafts_renderes = new List<Renderer>();
|
|
ShaftScale = new List<Vector3>();
|
|
Shaft_update_current = Time.fixedTime;
|
|
Cloud_update_current = Time.fixedTime;
|
|
Vector3 forward = Cam_transf.forward;
|
|
forward.x = 0f;
|
|
forward.y = 0f;
|
|
Quaternion identity = Quaternion.identity;
|
|
if (forward != Vector3.zero)
|
|
{
|
|
identity = Quaternion.LookRotation(forward);
|
|
prev_Rot = identity;
|
|
}
|
|
else
|
|
{
|
|
identity = Quaternion.LookRotation(forward + 0.0001f * new Vector3(1f, 1f, 1f));
|
|
prev_Rot = identity;
|
|
}
|
|
keep_sun_transf = sun_transf;
|
|
if (useShuriken)
|
|
{
|
|
ParticleSystem.MainModule main = GetComponent<ParticleSystem>().main;
|
|
int num2 = (main.maxParticles = (main.maxParticles = main.maxParticles / divider * divider));
|
|
GetComponent<ParticleSystem>().Emit(num2);
|
|
ParticleSystem.Particle[] array2 = new ParticleSystem.Particle[num2];
|
|
GetComponent<ParticleSystem>().GetParticles(array2);
|
|
if (GetComponent<ParticleSystem>() != null && Sorted)
|
|
{
|
|
int num5 = array2.Length / divider;
|
|
if (!init_centers)
|
|
{
|
|
int num6 = 0;
|
|
if (VerticalForm)
|
|
{
|
|
int num7 = 0;
|
|
for (int j = 0; j < divider / 2; j++)
|
|
{
|
|
for (int k = j * num5; k < (j + 1) * num5; k++)
|
|
{
|
|
array2[k].position = (array2[k].position - This_transf.position) * Scale_per_cloud[j] + Centers[j];
|
|
array2[k].startColor = Global_tint + MainColor;
|
|
int num8 = k + divider / 2 * num5;
|
|
array2[num8].position = (array2[num8].position + new Vector3(0f, Yspread, 0f) - This_transf.position) * Scale_per_cloud[j] * YScaleDiff + Centers[j] + MaxCloudDist;
|
|
array2[num8].startColor = Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a);
|
|
num6++;
|
|
if (SmoothIn)
|
|
{
|
|
array2[k].startColor = new Color((int)array2[k].startColor.r, (int)array2[k].startColor.g, (int)array2[k].startColor.b, 0f);
|
|
array2[num8].startColor = new Color((int)array2[num8].startColor.r, (int)array2[num8].startColor.g, (int)array2[num8].startColor.b, 0f);
|
|
}
|
|
}
|
|
if (Add_shadows & !shadows_created)
|
|
{
|
|
if (!Divide_lightning || (Divide_lightning & (num7 == LightningDivider)))
|
|
{
|
|
GameObject gameObject = UnityEngine.Object.Instantiate(Shadow_holder, Centers[j], Quaternion.identity);
|
|
gameObject.transform.parent = base.gameObject.transform;
|
|
gameObject.SetActive(value: true);
|
|
Shadow_planes.Add(gameObject.transform);
|
|
num7 = 0;
|
|
}
|
|
else
|
|
{
|
|
num7++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int num9 = 0;
|
|
for (int l = 0; l < divider; l++)
|
|
{
|
|
for (int m = l * num5; m < (l + 1) * num5; m++)
|
|
{
|
|
array2[m].position = (array2[m].position - This_transf.position) * Scale_per_cloud[l] + Centers[l];
|
|
array2[m].startColor = Global_tint + MainColor;
|
|
num6++;
|
|
if (SmoothIn)
|
|
{
|
|
array2[m].startColor = new Color((int)array2[m].startColor.r, (int)array2[m].startColor.g, (int)array2[m].startColor.b, 0f);
|
|
}
|
|
}
|
|
if (Add_shadows & !shadows_created)
|
|
{
|
|
if (!Divide_lightning || (Divide_lightning & (num9 == LightningDivider)))
|
|
{
|
|
GameObject gameObject2 = UnityEngine.Object.Instantiate(Shadow_holder, Centers[l], Quaternion.identity);
|
|
gameObject2.transform.parent = base.gameObject.transform;
|
|
gameObject2.SetActive(value: true);
|
|
Shadow_planes.Add(gameObject2.transform);
|
|
num9 = 0;
|
|
}
|
|
else
|
|
{
|
|
num9++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (num6 > 0)
|
|
{
|
|
init_centers = true;
|
|
Init = true;
|
|
GetComponent<ParticleSystem>().SetParticles(array2, array2.Length);
|
|
}
|
|
}
|
|
}
|
|
ParticlesLODed = new int[array2.Length];
|
|
}
|
|
if (ScatterMat != null && ScatterMat.HasProperty("_Glow"))
|
|
{
|
|
IntensityShaderModifier = ScatterMat.GetFloat("_Intensity");
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (StabilizeRoll)
|
|
{
|
|
if ((Vector3.Angle(prev_cam_for, Cam_transf.forward) > 11f) & ((Cam_transf.eulerAngles.z < 5f) | (Cam_transf.eulerAngles.z > 355f)))
|
|
{
|
|
prev_cam_for = Cam_transf.forward;
|
|
sortedInit = false;
|
|
}
|
|
if (PrenderS != null)
|
|
{
|
|
float num = Vector3.Angle(Cam_transf.forward, new Vector3(Cam_transf.forward.x, 0f, Cam_transf.forward.z));
|
|
float num2 = Vector3.Angle(Cam_transf.right, new Vector3(Cam_transf.right.x, 0f, Cam_transf.right.z));
|
|
if (!sortedInit)
|
|
{
|
|
sortedInit = true;
|
|
if (PrenderS.sortMode != ParticleSystemSortMode.Distance)
|
|
{
|
|
PrenderS.sortMode = ParticleSystemSortMode.Distance;
|
|
}
|
|
}
|
|
else if ((Mathf.Abs(Cam_transf.position.y - (This_transf.position.y + CloudBedToThisDist)) < NearCloudDist) | ((num > angle1) & (num2 < angle2)))
|
|
{
|
|
if (PrenderS.sortMode != ParticleSystemSortMode.Distance)
|
|
{
|
|
PrenderS.sortMode = ParticleSystemSortMode.Distance;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_ = PrenderS.renderMode;
|
|
_ = 3;
|
|
}
|
|
}
|
|
}
|
|
if (Use_audio)
|
|
{
|
|
if (CloudAudioSource == null)
|
|
{
|
|
CloudAudioSource = GetComponent<AudioSource>();
|
|
}
|
|
if (CloudAudioSource != null)
|
|
{
|
|
if ((CloudAudioSource.clip == null) & (RainSound != null))
|
|
{
|
|
CloudAudioSource.clip = RainSound;
|
|
}
|
|
if (SmoothIn && CloudAudioSource.volume < MaxSoundVol)
|
|
{
|
|
CloudAudioSource.volume += AudiofadeSpeed * Time.deltaTime;
|
|
}
|
|
if (SmoothOut && CloudAudioSource.volume > 0f)
|
|
{
|
|
CloudAudioSource.volume -= AudiofadeSpeed * Time.deltaTime;
|
|
}
|
|
}
|
|
}
|
|
if ((SmoothInSpeed < max_fade_speed) & SmoothIn)
|
|
{
|
|
SmoothInSpeed += SmoothInRate * Time.deltaTime;
|
|
SmoothOut = false;
|
|
SmoothoutSpeed = 0f;
|
|
}
|
|
if (SmoothOut & (SmoothoutSpeed < max_fade_speed))
|
|
{
|
|
SmoothIn = false;
|
|
SmoothInSpeed = 0f;
|
|
SmoothoutSpeed += SmoothOutRate * Time.deltaTime;
|
|
}
|
|
if ((SmoothOut & (SmoothoutSpeed >= max_fade_speed)) && (DestroyOnfadeOut & cloned))
|
|
{
|
|
UnityEngine.Object.Destroy(base.transform.gameObject);
|
|
}
|
|
if (Override_init_color && Override_color != MainColor_init)
|
|
{
|
|
MainColor_init = Override_color;
|
|
}
|
|
if (Day_cycle && SkyManager != null)
|
|
{
|
|
bool num3 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 0f) | (!SkyManager.AutoSunPosition && ((SkyManager.Current_Time > 9f + SkyManager.Shift_dawn) & (SkyManager.Current_Time <= SkyManager.NightTimeMax + SkyManager.Shift_dawn)));
|
|
bool flag = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 5f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time > SkyManager.NightTimeMax - 0.3f + SkyManager.Shift_dawn);
|
|
bool flag2 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 65f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time > 17.1f + SkyManager.Shift_dawn);
|
|
bool flag3 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 10f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time < 10f + SkyManager.Shift_dawn);
|
|
bool flag4 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 15f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time < 11f + SkyManager.Shift_dawn);
|
|
bool flag5 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 60f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time < 16.1f + SkyManager.Shift_dawn);
|
|
bool flag6 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 5f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time < 8.5f + SkyManager.Shift_dawn);
|
|
bool flag7 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 3f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time > 23f + SkyManager.Shift_dawn);
|
|
bool flag8 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 5f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time > SkyManager.NightTimeMax + SkyManager.Shift_dawn);
|
|
float num4 = Time.deltaTime * color_speed;
|
|
MainColor = MainColor_init;
|
|
if (num3)
|
|
{
|
|
if (flag)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Dusk_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Dusk_sun_col, num4);
|
|
}
|
|
}
|
|
else if (flag2)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Dusk_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Dusk_sun_col, num4);
|
|
}
|
|
}
|
|
else if (flag3)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Dawn_base_col, num4 * SkyManager.DawnAppearSpeed);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Dawn_sun_col, num4 * SkyManager.DawnAppearSpeed);
|
|
}
|
|
}
|
|
else if (flag4)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Day_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Day_sun_col, num4);
|
|
}
|
|
}
|
|
else if (flag5)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Day_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Day_sun_col, num4);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Dusk_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Dusk_sun_col, num4);
|
|
}
|
|
}
|
|
}
|
|
else if (flag6)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Night_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Night_moon_col, num4);
|
|
}
|
|
}
|
|
else if (flag7)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Night_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Night_moon_col, num4);
|
|
}
|
|
}
|
|
else if (flag8)
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Night_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Night_moon_col, num4);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MainColor_init = Color.Lerp(MainColor_init, Night_base_col, num4);
|
|
if (!Grab_sun_color)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Night_moon_col, num4);
|
|
}
|
|
}
|
|
if (Override_sun)
|
|
{
|
|
if (sun_transf.position.y < Cut_height)
|
|
{
|
|
if (Moon_light && sun_transf.position.y < Cut_height - 10f && keep_sun_transf != moon_transf)
|
|
{
|
|
keep_sun_transf = moon_transf;
|
|
}
|
|
}
|
|
else if (keep_sun_transf != sun_transf)
|
|
{
|
|
keep_sun_transf = sun_transf;
|
|
}
|
|
}
|
|
if (SkyManager.VolCloudGradients)
|
|
{
|
|
SunColor = SkyManager.gradCloudLitColor;
|
|
SunColor.a = SkyManager.VolCloudTransp;
|
|
MainColor = SkyManager.gradCloudShadeColor;
|
|
minLightShaderModifier = SkyManager.VcloudLightDiff - 0.5f;
|
|
IntensityShaderModifier = SkyManager.VcloudSunIntensity * 8f;
|
|
GlowShaderModifier = SkyManager.VcloudFog;
|
|
Global_tint = SkyManager.gradCloudFogColor;
|
|
}
|
|
}
|
|
if (SkyManager != null)
|
|
{
|
|
if (ScatterMat != null && ScatterMat.HasProperty("_Glow"))
|
|
{
|
|
ScatterMat.SetFloat("_Intensity", IntensityShaderModifier);
|
|
}
|
|
if (AutoScale)
|
|
{
|
|
if ((SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 15f && SkyManager.Rot_Sun_X < 45f) | (!SkyManager.AutoSunPosition && ((SkyManager.Current_Time < 17.9f + SkyManager.Shift_dawn) & (SkyManager.Current_Time > 11f + SkyManager.Shift_dawn))))
|
|
{
|
|
if (ScatterMat != null && ScatterMat.HasProperty("_Glow"))
|
|
{
|
|
if (SkyManager.currentWeatherName == SkyMasterManager.Volume_Weather_types.HeavyStorm)
|
|
{
|
|
ScatterMat.SetFloat("_MinLight", Mathf.Lerp(ScatterMat.GetFloat("_MinLight"), -0.55f + minLightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
ScatterMat.SetFloat("_LightIntensity", Mathf.Lerp(ScatterMat.GetFloat("_LightIntensity"), 4f + LightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
ScatterMat.SetFloat("_Glow", Mathf.Lerp(ScatterMat.GetFloat("_Glow"), 5.2f + GlowShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetFloat("_MinLight", Mathf.Lerp(ScatterMat.GetFloat("_MinLight"), -0.55f + minLightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed * 0.1f + ModifierApplMinSpeed * 0.02f));
|
|
ScatterMat.SetFloat("_LightIntensity", Mathf.Lerp(ScatterMat.GetFloat("_LightIntensity"), 1f + LightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed * 0.1f + ModifierApplMinSpeed * 0.02f));
|
|
ScatterMat.SetFloat("_Glow", Mathf.Lerp(ScatterMat.GetFloat("_Glow"), 3.5f + GlowShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed * 0.1f + ModifierApplMinSpeed * 0.02f));
|
|
}
|
|
}
|
|
if (useShuriken)
|
|
{
|
|
cloud_scale = Mathf.Lerp(cloud_scale, 0.4f, Time.deltaTime * SkyManager.SPEED);
|
|
global_cloud_scale = Mathf.Lerp(global_cloud_scale, 1.5f, Time.deltaTime * SkyManager.SPEED);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ScatterMat != null && ScatterMat.HasProperty("_Glow"))
|
|
{
|
|
if (SkyManager.currentWeatherName == SkyMasterManager.Volume_Weather_types.HeavyStorm)
|
|
{
|
|
ScatterMat.SetFloat("_MinLight", Mathf.Lerp(ScatterMat.GetFloat("_MinLight"), -0.55f + minLightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
ScatterMat.SetFloat("_LightIntensity", Mathf.Lerp(ScatterMat.GetFloat("_LightIntensity"), 3.2f + LightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
ScatterMat.SetFloat("_Glow", Mathf.Lerp(ScatterMat.GetFloat("_Glow"), 6.6f + GlowShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetFloat("_MinLight", Mathf.Lerp(ScatterMat.GetFloat("_MinLight"), -0.8f + minLightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
ScatterMat.SetFloat("_LightIntensity", Mathf.Lerp(ScatterMat.GetFloat("_LightIntensity"), 0.2f + LightShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
if (useShuriken)
|
|
{
|
|
ScatterMat.SetFloat("_Glow", Mathf.Lerp(ScatterMat.GetFloat("_Glow"), 3f + GlowShaderModifier, Time.deltaTime * SkyManager.SPEED * ModifierApplicationSpeed + ModifierApplMinSpeed));
|
|
}
|
|
}
|
|
}
|
|
if (useShuriken)
|
|
{
|
|
cloud_scale = Mathf.Lerp(cloud_scale, 0.2f, Time.deltaTime * SkyManager.SPEED);
|
|
global_cloud_scale = Mathf.Lerp(global_cloud_scale, 1f, Time.deltaTime * SkyManager.SPEED);
|
|
}
|
|
}
|
|
}
|
|
if ((ScatterMat != null) & !SmoothOut)
|
|
{
|
|
bool flag9 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 0f) | (!SkyManager.AutoSunPosition && ((SkyManager.Current_Time > 9f + SkyManager.Shift_dawn) & (SkyManager.Current_Time <= 21.9f + SkyManager.Shift_dawn)));
|
|
bool flag10 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X > 65f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time > 17.1f + SkyManager.Shift_dawn);
|
|
bool flag11 = (SkyManager.AutoSunPosition && SkyManager.Rot_Sun_X < 10f) | (!SkyManager.AutoSunPosition && SkyManager.Current_Time < 10f + SkyManager.Shift_dawn);
|
|
if (ScatterShaderUpdate)
|
|
{
|
|
reileigh = SkyManager.m_fRayleighScaleDepth;
|
|
reileigh = SkyManager.m_Kr;
|
|
mieCoefficient = SkyManager.m_Km;
|
|
if (flag9 | (SkyManager.currentWeatherName == SkyMasterManager.Volume_Weather_types.HeavyStorm))
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.SunObj.transform.forward.normalized);
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), SunColor, 0.5f * Time.deltaTime));
|
|
if (flag10)
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Dusk_sun_col, 0.5f), 0.5f * Time.deltaTime));
|
|
}
|
|
else if (flag11)
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Dawn_sun_col, 0.5f), 0.5f * Time.deltaTime * 0.2f * SkyManager.DawnAppearSpeed));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Day_sun_col, 0.5f), 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.MoonObj.transform.forward.normalized);
|
|
if (!Moon_light)
|
|
{
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), MoonLight.color, 0.5f * Time.deltaTime));
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), MoonLight.color, 0.5f * Time.deltaTime));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), Moon_light_color, 0.5f * Time.deltaTime));
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Moon_light_color, 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
ScatterMat.SetVector("betaR", totalRayleigh(lambda) * reileigh);
|
|
ScatterMat.SetVector("betaM", totalMie(lambda, K, fog_depth) * mieCoefficient);
|
|
ScatterMat.SetFloat("fog_depth", fog_depth);
|
|
ScatterMat.SetFloat("mieCoefficient", mieCoefficient);
|
|
ScatterMat.SetFloat("mieDirectionalG", mieDirectionalG);
|
|
ScatterMat.SetFloat("ExposureBias", ExposureBias);
|
|
}
|
|
else if (ScatterMat.HasProperty("_SunColor"))
|
|
{
|
|
if (flag9 | (SkyManager.currentWeatherName == SkyMasterManager.Volume_Weather_types.HeavyStorm))
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.SunObj.transform.forward.normalized);
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), SunColor, 0.5f * Time.deltaTime));
|
|
if (flag10)
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Dusk_sun_col, 0.5f), 0.5f * Time.deltaTime));
|
|
}
|
|
else if (flag11)
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Dawn_sun_col, 0.5f), 0.5f * Time.deltaTime * 0.2f * SkyManager.DawnAppearSpeed));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Color.Lerp(SunColor, Day_sun_col, 0.5f), 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("sunPosition", -SkyManager.MoonObj.transform.forward.normalized);
|
|
if (!Moon_light)
|
|
{
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), MoonLight.color, 0.5f * Time.deltaTime));
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), MoonLight.color, 0.5f * Time.deltaTime));
|
|
}
|
|
else
|
|
{
|
|
ScatterMat.SetVector("_SunColor", Color.Lerp(ScatterMat.GetVector("_SunColor"), Moon_light_color, 0.5f * Time.deltaTime));
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(ScatterMat.GetVector("_TintColor"), Moon_light_color, 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
ScatterMat.SetVector("betaR", totalRayleigh(lambda) * reileigh);
|
|
ScatterMat.SetVector("betaM", totalMie(lambda, K, fog_depth) * mieCoefficient);
|
|
ScatterMat.SetFloat("fog_depth", fog_depth);
|
|
ScatterMat.SetFloat("mieCoefficient", mieCoefficient);
|
|
ScatterMat.SetFloat("mieDirectionalG", mieDirectionalG);
|
|
ScatterMat.SetFloat("ExposureBias", ExposureBias);
|
|
}
|
|
}
|
|
}
|
|
if (SunShafts != null && ((SunShafts.Count > 0) & !Got_shaft_items))
|
|
{
|
|
for (int i = 0; i < SunShafts.Count; i++)
|
|
{
|
|
Component[] componentsInChildren = SunShafts[i].GetComponentsInChildren(typeof(Renderer));
|
|
for (int j = 0; j < componentsInChildren.Length; j++)
|
|
{
|
|
Shafts_renderes.Add(componentsInChildren[j].GetComponent<Renderer>());
|
|
}
|
|
ShaftScale.Add(SunShafts[i].localScale);
|
|
}
|
|
Got_shaft_items = true;
|
|
}
|
|
List<Vector3> centers = Centers;
|
|
List<Vector3> centers2 = Centers;
|
|
List<float> scale_per_cloud = Scale_per_cloud;
|
|
List<float> scale_per_cloud2 = Scale_per_cloud;
|
|
if (Beam_Occlusion & (Time.fixedTime - Shaft_update_current > Occlusion_sort_delay))
|
|
{
|
|
Shaft_update_current = Time.fixedTime;
|
|
if (init_centers)
|
|
{
|
|
if (Scale_beams)
|
|
{
|
|
for (int k = 0; k < centers2.Count - 1; k++)
|
|
{
|
|
float sqrMagnitude = (centers2[k] - sun_transf.position).sqrMagnitude;
|
|
if ((centers2[k + 1] - sun_transf.position).sqrMagnitude < sqrMagnitude)
|
|
{
|
|
Vector3 value = centers2[k];
|
|
centers2[k] = centers2[k + 1];
|
|
centers2[k + 1] = value;
|
|
float value2 = scale_per_cloud2[k];
|
|
scale_per_cloud2[k] = scale_per_cloud2[k + 1];
|
|
scale_per_cloud2[k + 1] = value2;
|
|
k = 0;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int l = 0; l < centers.Count - 1; l++)
|
|
{
|
|
float sqrMagnitude2 = (centers[l] - Cam_transf.position).sqrMagnitude;
|
|
if ((centers[l + 1] - Cam_transf.position).sqrMagnitude < sqrMagnitude2)
|
|
{
|
|
Vector3 value3 = centers[l];
|
|
centers[l] = centers[l + 1];
|
|
centers[l + 1] = value3;
|
|
float value4 = scale_per_cloud[l];
|
|
scale_per_cloud[l] = scale_per_cloud[l + 1];
|
|
scale_per_cloud[l + 1] = value4;
|
|
l = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (int m = 0; m < SunShafts.Count; m++)
|
|
{
|
|
Vector3 forward = Cam_transf.forward;
|
|
forward.x = 0f;
|
|
forward.y = 0f;
|
|
Quaternion identity = Quaternion.identity;
|
|
if (forward != Vector3.zero)
|
|
{
|
|
identity = Quaternion.LookRotation(forward);
|
|
prev_Rot = identity;
|
|
}
|
|
else
|
|
{
|
|
identity = prev_Rot;
|
|
}
|
|
float num5 = Vector3.Dot(Cam_transf.forward, SunShafts[m].right) * 2f * 180f / MathF.PI;
|
|
num5 = Vector3.Angle(SunShafts[m].position - Cam_transf.position, SunShafts[m].right) * 1f;
|
|
float num6 = Vector3.Angle(-SunShafts[m].up, Cam_transf.forward);
|
|
if (num5 == 90f)
|
|
{
|
|
num5 = 89.9f;
|
|
}
|
|
num5 -= num6;
|
|
Quaternion identity2 = Quaternion.identity;
|
|
identity2 = sun_transf.rotation * Quaternion.Euler(UnityEngine.Random.Range(-9, 9), UnityEngine.Random.Range(-9, 9), UnityEngine.Random.Range(-9, 9));
|
|
if (Look_at_camera)
|
|
{
|
|
identity2 = Quaternion.LookRotation(-Cam_transf.forward) * Quaternion.Euler(UnityEngine.Random.Range(-9, 9), UnityEngine.Random.Range(-9, 9), UnityEngine.Random.Range(-9, 9));
|
|
}
|
|
Quaternion quaternion = Quaternion.LookRotation((SunShafts[m].position - Cam_transf.position).normalized, Vector3.forward);
|
|
quaternion.x = 0f;
|
|
quaternion.y = 0f;
|
|
SunShafts[m].rotation = identity2 * quaternion;
|
|
if (m > 5)
|
|
{
|
|
SunShafts[m].rotation = identity2;
|
|
}
|
|
if (!Beam_Occlusion || !init_centers)
|
|
{
|
|
continue;
|
|
}
|
|
bool flag12 = false;
|
|
if (Diminish_beams && sun_transf.position.y < Cut_height)
|
|
{
|
|
for (int n = 3 * m; n < 3 * (m + 1); n++)
|
|
{
|
|
Color a = Shafts_renderes[n].material.GetVector("_TintColor");
|
|
Shafts_renderes[n].material.SetVector("_TintColor", Color.Lerp(a, new Color(a.r, a.g, a.b, 0f), Disappear_Beam_speed * 2.5f * Time.deltaTime));
|
|
}
|
|
flag12 = true;
|
|
}
|
|
if (flag12)
|
|
{
|
|
continue;
|
|
}
|
|
if (Scale_on_collision && Got_shaft_items)
|
|
{
|
|
float num7 = 9999990f;
|
|
RaycastHit hitInfo = default(RaycastHit);
|
|
if (Physics.Raycast(SunShafts[m].position, SunShafts[m].forward, out hitInfo))
|
|
{
|
|
num7 = hitInfo.distance;
|
|
}
|
|
if (Beam_length > num7)
|
|
{
|
|
float num8 = Offset_col_factor * (num7 * ShaftScale[m].z) / Beam_length;
|
|
if (SunShafts[m].localScale.z > num8 + 0.1f)
|
|
{
|
|
SunShafts[m].localScale = new Vector3(SunShafts[m].localScale.x, SunShafts[m].localScale.y, num8);
|
|
}
|
|
}
|
|
else if (SunShafts[m].localScale.z != ShaftScale[m].z)
|
|
{
|
|
SunShafts[m].localScale = new Vector3(SunShafts[m].localScale.x, SunShafts[m].localScale.y, ShaftScale[m].z);
|
|
}
|
|
}
|
|
if (Scale_beams)
|
|
{
|
|
if (!Got_shaft_items)
|
|
{
|
|
continue;
|
|
}
|
|
for (int num9 = 0; num9 < divider; num9++)
|
|
{
|
|
Vector3 vector = centers2[num9] - sun_transf.position;
|
|
Vector3 forward2 = SunShafts[m].forward;
|
|
if (Vector3.Angle(vector, forward2) > 20f)
|
|
{
|
|
float num10 = vector.magnitude * ShaftScale[m].z / Beam_length;
|
|
if (SunShafts[m].localScale.z > num10 + 0.1f)
|
|
{
|
|
SunShafts[m].localScale = new Vector3(SunShafts[m].localScale.x, SunShafts[m].localScale.y, num10);
|
|
}
|
|
break;
|
|
}
|
|
if (SunShafts[m].localScale.z != ShaftScale[m].z)
|
|
{
|
|
SunShafts[m].localScale = new Vector3(SunShafts[m].localScale.x, SunShafts[m].localScale.y, ShaftScale[m].z);
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
for (int num11 = 0; num11 < divider; num11++)
|
|
{
|
|
if (!Got_shaft_items)
|
|
{
|
|
continue;
|
|
}
|
|
if (Debug_mode)
|
|
{
|
|
Debug.DrawLine(This_transf.position, centers[num11], new Color(1f / (0.1f * (float)(num11 + 1)), 0f, 0f, 1f));
|
|
}
|
|
Vector3 vector2 = centers[num11] + Quaternion.LookRotation(Cam_transf.forward) * new Vector3(cloud_scale * scale_per_cloud[num11], cloud_scale * scale_per_cloud[num11] / 2f, 0f);
|
|
Vector3 vector3 = centers[num11] - Quaternion.LookRotation(Cam_transf.forward) * new Vector3(cloud_scale * scale_per_cloud[num11], cloud_scale * scale_per_cloud[num11] / 2f, 0f);
|
|
Vector3 vector4 = Camera.main.WorldToScreenPoint(vector2);
|
|
Vector3 vector5 = Camera.main.WorldToScreenPoint(vector3);
|
|
Vector3 vector6 = Camera.main.WorldToScreenPoint(SunShafts[m].position);
|
|
bool flag13 = true;
|
|
if (vector4.x > vector5.x)
|
|
{
|
|
flag13 = false;
|
|
}
|
|
if ((((flag13 & ((vector6.x > vector4.x) & (vector6.x < vector5.x) & (vector6.y < vector4.y) & (vector6.y > vector5.y))) | (!flag13 & ((vector6.x < vector4.x) & (vector6.x > vector5.x) & (vector6.y < vector4.y) & (vector6.y > vector5.y)))) & ((vector4.z > 0f) & (vector5.z > 0f))) | ((Cam_transf.position - Centers[num11]).magnitude < cloud_scale * Scale_per_cloud[num11]))
|
|
{
|
|
if (Smooth_mat_trans)
|
|
{
|
|
for (int num12 = 3 * m; num12 < 3 * (m + 1); num12++)
|
|
{
|
|
Color a2 = Shafts_renderes[num12].material.GetVector("_TintColor");
|
|
Shafts_renderes[num12].material.SetVector("_TintColor", Color.Lerp(a2, new Color(a2.r, a2.g, a2.b, 0f), Disappear_Beam_speed * 2.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
else if (SunShafts[m].gameObject.activeInHierarchy)
|
|
{
|
|
SunShafts[m].gameObject.SetActive(value: false);
|
|
}
|
|
if (Debug_mode)
|
|
{
|
|
Debug.DrawLine(This_transf.position, centers[num11]);
|
|
Debug.DrawLine(This_transf.position, vector2, Color.blue);
|
|
Debug.DrawLine(This_transf.position, vector3, Color.blue);
|
|
}
|
|
break;
|
|
}
|
|
if (Smooth_mat_trans)
|
|
{
|
|
for (int num13 = 3 * m; num13 < 3 * (m + 1); num13++)
|
|
{
|
|
Color a3 = Shafts_renderes[num13].material.GetVector("_TintColor");
|
|
Shafts_renderes[num13].material.SetVector("_TintColor", Color.Lerp(a3, new Color(a3.r, a3.g, a3.b, start_beam_transp), Appear_Beam_speed * 0.5f * Time.deltaTime));
|
|
}
|
|
}
|
|
else if (!SunShafts[m].gameObject.activeInHierarchy)
|
|
{
|
|
SunShafts[m].gameObject.SetActive(value: true);
|
|
}
|
|
}
|
|
}
|
|
if (!(ShurikenParticle != null))
|
|
{
|
|
return;
|
|
}
|
|
if (particles == null)
|
|
{
|
|
particles = new ParticleSystem.Particle[ShurikenParticle.main.maxParticles];
|
|
}
|
|
if (DecoupledWind)
|
|
{
|
|
ShurikenParticle.GetParticles(particles);
|
|
}
|
|
if ((Time.fixedTime - Prev_time > UpdateInterval) | !Init)
|
|
{
|
|
Prev_time = Time.fixedTime;
|
|
if (!DecoupledWind)
|
|
{
|
|
ShurikenParticle.GetParticles(particles);
|
|
}
|
|
if (Grab_sun_color)
|
|
{
|
|
if (Override_sun)
|
|
{
|
|
if (sun_transf.position.y < Cut_height)
|
|
{
|
|
MainColor = Color.Lerp(MainColor, Moon_dark_color, 2.5f * Time.deltaTime);
|
|
if (Moon_light)
|
|
{
|
|
if (sun_transf.position.y < Cut_height - 10f)
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Moon_light_color, 2.5f * Time.deltaTime);
|
|
if (keep_sun_transf != moon_transf)
|
|
{
|
|
keep_sun_transf = moon_transf;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Moon_dark_color, 2.5f * Time.deltaTime);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SunColor = Color.Lerp(SunColor, Color.black, 2.5f * Time.deltaTime);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MainColor = Color.Lerp(MainColor, MainColor_init, 2.5f * Time.deltaTime);
|
|
SunColor = Color.Lerp(SunColor, Sun_Light.color, 2.5f * Time.deltaTime);
|
|
if (keep_sun_transf != sun_transf)
|
|
{
|
|
keep_sun_transf = sun_transf;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SunColor = Sun_Light.color;
|
|
}
|
|
if (prev_intensity != Sun_Light.intensity)
|
|
{
|
|
MainColor = Color.Lerp(MainColor, Sun_Light.intensity * (MainColor_init / 3f), 2.5f * Time.deltaTime);
|
|
prev_intensity = Sun_Light.intensity;
|
|
}
|
|
}
|
|
if (!Sorted)
|
|
{
|
|
int num14 = particles.Length / divider;
|
|
if (!init_centers)
|
|
{
|
|
int num15 = 0;
|
|
if (VerticalForm)
|
|
{
|
|
for (int num16 = 0; num16 < divider / 2; num16++)
|
|
{
|
|
for (int num17 = num16 * num14; num17 < (num16 + 1) * num14; num17++)
|
|
{
|
|
particles[num17].position = (particles[num17].position - This_transf.position) * Scale_per_cloud[num16] + Centers[num16];
|
|
particles[num17].startColor = Global_tint + MainColor;
|
|
int num18 = num17 + divider / 2 * num14;
|
|
particles[num18].position = (particles[num18].position + new Vector3(0f, Yspread, 0f) - This_transf.position) * Scale_per_cloud[num16] * YScaleDiff + Centers[num16] + MaxCloudDist;
|
|
particles[num18].startColor = Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a);
|
|
if (SmoothIn)
|
|
{
|
|
particles[num17].startColor = Color.Lerp(particles[num17].startColor, Global_tint + MainColor, Time.deltaTime * SmoothInSpeed);
|
|
particles[num18].startColor = Color.Lerp(particles[num17].startColor, Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else
|
|
{
|
|
particles[num17].startColor = Global_tint + MainColor;
|
|
particles[num18].startColor = Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a);
|
|
}
|
|
num15++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int num19 = 0; num19 < divider; num19++)
|
|
{
|
|
for (int num20 = num19 * num14; num20 < (num19 + 1) * num14; num20++)
|
|
{
|
|
particles[num20].position = (particles[num20].position - This_transf.position) * Scale_per_cloud[num19] + Centers[num19];
|
|
num15++;
|
|
}
|
|
}
|
|
}
|
|
if (num15 > 0)
|
|
{
|
|
init_centers = true;
|
|
Init = true;
|
|
ShurikenParticle.SetParticles(particles, particles.Length);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int num21 = 0; num21 < divider; num21++)
|
|
{
|
|
float num22 = speed;
|
|
num22 = multiplier * speed * (float)(num21 + 1);
|
|
if (!DecoupledWind)
|
|
{
|
|
Centers[num21] += wind * num22 * Time.deltaTime;
|
|
}
|
|
float magnitude = (Centers[num21] - keep_sun_transf.position).magnitude;
|
|
for (int num23 = num21 * num14; num23 < (num21 + 1) * num14; num23++)
|
|
{
|
|
Vector3 vector7 = Centers[num21];
|
|
int num24 = num21;
|
|
for (int num25 = 0; num25 < Centers.Count; num25++)
|
|
{
|
|
if (Vector3.Distance(Centers[num25], particles[num23].position) < Vector3.Distance(vector7, particles[num23].position))
|
|
{
|
|
vector7 = Centers[num25];
|
|
num24 = num25;
|
|
}
|
|
}
|
|
magnitude = (vector7 - keep_sun_transf.position).magnitude;
|
|
particles[num23].position = particles[num23].position + wind * (multiplier * speed * (float)(num24 + 1)) * Time.deltaTime;
|
|
float t = ((particles[num23].position - keep_sun_transf.position).magnitude - magnitude) / 1.38f;
|
|
if (Prev_cam_rot == Cam_transf.eulerAngles)
|
|
{
|
|
particles[num23].startColor = Color.Lerp(SunColor, MainColor, t);
|
|
}
|
|
else
|
|
{
|
|
Prev_cam_rot = Cam_transf.eulerAngles;
|
|
}
|
|
}
|
|
}
|
|
if (!DecoupledWind)
|
|
{
|
|
ShurikenParticle.SetParticles(particles, particles.Length);
|
|
}
|
|
}
|
|
}
|
|
else if (Sorted)
|
|
{
|
|
int num26 = particles.Length / divider;
|
|
if (!init_centers)
|
|
{
|
|
int num27 = 0;
|
|
if (VerticalForm)
|
|
{
|
|
for (int num28 = 0; num28 < divider / 2; num28++)
|
|
{
|
|
for (int num29 = num28 * num26; num29 < (num28 + 1) * num26; num29++)
|
|
{
|
|
particles[num29].position = (particles[num29].position - This_transf.position) * Scale_per_cloud[num28] + Centers[num28];
|
|
int num30 = num29 + divider / 2 * num26;
|
|
particles[num30].position = (particles[num30].position + new Vector3(0f, Yspread, 0f) - This_transf.position) * Scale_per_cloud[num28] * YScaleDiff + Centers[num28] + MaxCloudDist;
|
|
if (SmoothIn)
|
|
{
|
|
particles[num29].startColor = Color.Lerp(particles[num29].startColor, Global_tint + MainColor, Time.deltaTime * SmoothInSpeed);
|
|
particles[num30].startColor = Color.Lerp(particles[num29].startColor, Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else
|
|
{
|
|
particles[num29].startColor = Global_tint + MainColor;
|
|
particles[num30].startColor = Color.Lerp(Global_tint + MainColor, HeightTint, HeightTint.a);
|
|
}
|
|
particles[num29].remainingLifetime = 100000f;
|
|
particles[num29].startLifetime = 100000f;
|
|
particles[num30].remainingLifetime = 100000f;
|
|
particles[num30].startLifetime = 100000f;
|
|
num27++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int num31 = 0; num31 < divider; num31++)
|
|
{
|
|
for (int num32 = num31 * num26; num32 < (num31 + 1) * num26; num32++)
|
|
{
|
|
particles[num32].position = (particles[num32].position - This_transf.position) * Scale_per_cloud[num31] + Centers[num31];
|
|
particles[num32].remainingLifetime = 100000f;
|
|
particles[num32].startLifetime = 100000f;
|
|
num27++;
|
|
}
|
|
}
|
|
}
|
|
if (num27 > 0)
|
|
{
|
|
init_centers = true;
|
|
Init = true;
|
|
ShurikenParticle.SetParticles(particles, particles.Length);
|
|
}
|
|
}
|
|
if (init_centers)
|
|
{
|
|
bool flag14 = false;
|
|
int num33 = 0;
|
|
int num34 = 0;
|
|
int num35 = 0;
|
|
for (int num36 = 0; num36 < divider; num36++)
|
|
{
|
|
float num37 = speed;
|
|
num37 = multiplier * speed * (float)(num36 + 1);
|
|
if (!DecoupledWind)
|
|
{
|
|
Centers[num36] += wind * num37 * Time.deltaTime;
|
|
}
|
|
if (EnableLOD && Vector3.Distance(Cam_transf.position, Centers[num36] + new Vector3(0f, 120f, 0f)) < LodMaxYDiff)
|
|
{
|
|
flag14 = true;
|
|
}
|
|
if (!DecoupledWind && (Add_shadows & !shadows_created))
|
|
{
|
|
if (!Divide_lightning || (Divide_lightning & (num34 == LightningDivider)))
|
|
{
|
|
if (num35 < Shadow_planes.Count)
|
|
{
|
|
Shadow_planes[num35].position = Centers[num36];
|
|
}
|
|
num34 = 0;
|
|
num35++;
|
|
}
|
|
else
|
|
{
|
|
num34++;
|
|
}
|
|
}
|
|
if (!Restore_on_bound)
|
|
{
|
|
continue;
|
|
}
|
|
if (Vector3.Distance(Centers[num36], This_transf.position) > Bound)
|
|
{
|
|
num33++;
|
|
}
|
|
if (!Disable_on_bound)
|
|
{
|
|
continue;
|
|
}
|
|
if (!SmoothOut && FadeOutOnBoundary && num33 >= Centers.Count - 4)
|
|
{
|
|
SmoothIn = false;
|
|
SmoothOut = true;
|
|
SmoothoutSpeed = 0f;
|
|
SmoothInSpeed = 0f;
|
|
}
|
|
if (num33 < Centers.Count)
|
|
{
|
|
continue;
|
|
}
|
|
if (clone_on_end & !cloned)
|
|
{
|
|
shadows_created = true;
|
|
GameObject gameObject = UnityEngine.Object.Instantiate(base.transform.gameObject);
|
|
gameObject.GetComponent<VolumeClouds_SM>().SmoothIn = true;
|
|
gameObject.GetComponent<VolumeClouds_SM>().SmoothOut = false;
|
|
gameObject.GetComponent<VolumeClouds_SM>().current_fadein_time = Time.fixedTime;
|
|
SkyManager.currentWeather.VolumeScript = gameObject.GetComponent<VolumeClouds_SM>();
|
|
cloned = true;
|
|
}
|
|
if (!DestroyOnfadeOut)
|
|
{
|
|
This_transf.gameObject.SetActive(value: false);
|
|
if (destroy_on_end)
|
|
{
|
|
UnityEngine.Object.Destroy(base.transform.gameObject);
|
|
}
|
|
}
|
|
}
|
|
int num38 = max_divider;
|
|
if (Time.fixedTime - Cloud_update_current < Cloud_spread_delay)
|
|
{
|
|
alternate = 2;
|
|
num38 = 1;
|
|
}
|
|
else if (Time.fixedTime - Cloud_update_current == Cloud_spread_delay)
|
|
{
|
|
alternate = 2;
|
|
num38 = 1;
|
|
}
|
|
else if (alternate > max_divider)
|
|
{
|
|
alternate = 2;
|
|
}
|
|
else
|
|
{
|
|
alternate++;
|
|
}
|
|
for (int num39 = alternate - 2; num39 < particles.Length; num39 += num38)
|
|
{
|
|
particles[num39].remainingLifetime = 100000f;
|
|
particles[num39].startLifetime = 100000f;
|
|
if (!DecoupledColor)
|
|
{
|
|
int num40 = 0;
|
|
Vector3 vector8 = Centers[0];
|
|
for (int num41 = 0; num41 < Centers.Count; num41++)
|
|
{
|
|
if (Use2DCheck)
|
|
{
|
|
if (Vector2.Distance(new Vector2(Centers[num41].x, Centers[num41].z), new Vector2(particles[num39].position.x, particles[num39].position.z)) < Vector3.Distance(new Vector2(vector8.x, vector8.z), new Vector2(particles[num39].position.x, particles[num39].position.z)))
|
|
{
|
|
vector8 = Centers[num41];
|
|
num40 = num41;
|
|
}
|
|
}
|
|
else if (Vector3.Distance(Centers[num41], particles[num39].position) < Vector3.Distance(vector8, particles[num39].position))
|
|
{
|
|
vector8 = Centers[num41];
|
|
num40 = num41;
|
|
}
|
|
}
|
|
float magnitude2 = (vector8 - keep_sun_transf.position).magnitude;
|
|
if (Flatten_below && vector8.y - particles[num39].position.y > 0f)
|
|
{
|
|
particles[num39].position = new Vector3(particles[num39].position.x, particles[num39].position.y + 500f * Time.deltaTime, particles[num39].position.z);
|
|
}
|
|
float num42 = (keep_sun_transf.position - particles[num39].position).magnitude / 10f;
|
|
if (Turbulent)
|
|
{
|
|
if (method == 1)
|
|
{
|
|
particles[num39].startSize = Mathf.Abs(750f * Mathf.Cos(Time.fixedTime + (float)num39 * Time.fixedTime * 0.0005f));
|
|
if (particles[num39].startSize < 330f)
|
|
{
|
|
particles[num39].startSize = 330f;
|
|
}
|
|
else if (particles[num39].startSize > 600f)
|
|
{
|
|
particles[num39].startSize = 600f;
|
|
}
|
|
}
|
|
else if (method == 2)
|
|
{
|
|
if ((((particles[num39].startSize < 300f) ? 1u : 0u) | 1u) != 0)
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 800f * Mathf.Cos(Time.fixedTime + num42 * Time.fixedTime * 0.0005f) * Time.deltaTime;
|
|
}
|
|
if (particles[num39].startSize < 300f)
|
|
{
|
|
particles[num39].startSize = 300f;
|
|
}
|
|
else if (particles[num39].startSize > 500f)
|
|
{
|
|
particles[num39].startSize = 500f;
|
|
}
|
|
}
|
|
else if (method == 3)
|
|
{
|
|
float num43 = Time.fixedTime + num42 * Time.fixedTime * 0.0005f;
|
|
num43 = Time.fixedTime + num42 * 0.115f;
|
|
if ((particles[num39].startSize < 500f) & (particles[num39].startSize > 200f))
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 800f * Mathf.Cos(num43) * Time.deltaTime;
|
|
}
|
|
if (particles[num39].startSize < 200f)
|
|
{
|
|
if (Mathf.Cos(num43) < 0f)
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 80f * Mathf.Cos(num43) * Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 880f * Mathf.Cos(num43) * Time.deltaTime;
|
|
}
|
|
}
|
|
else if (particles[num39].startSize > 500f)
|
|
{
|
|
if (Mathf.Cos(num43) > 0f)
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 80f * Mathf.Cos(num43) * Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
particles[num39].startSize = particles[num39].startSize + 880f * Mathf.Cos(num43) * Time.deltaTime;
|
|
}
|
|
}
|
|
}
|
|
particles[num39].position = particles[num39].position + wind * (multiplier * speed * (num42 + 1f)) * Time.deltaTime;
|
|
}
|
|
else if (!DecoupledWind)
|
|
{
|
|
particles[num39].position = particles[num39].position + wind * (multiplier * speed * (float)(num40 + 1)) * Time.deltaTime;
|
|
}
|
|
if (EnableLOD & (Prev_cam_rot == Cam_transf.eulerAngles))
|
|
{
|
|
float num44 = Vector2.Distance(new Vector2(Cam_transf.position.x, Cam_transf.position.z), new Vector2(particles[num39].position.x, particles[num39].position.z));
|
|
if (((num44 > LodMaxHDiff) | (num44 < LODMinDist)) && flag14)
|
|
{
|
|
if (ParticlesLODed[num39] == 0)
|
|
{
|
|
ParticlesLODed[num39] = (int)particles[num39].startSize;
|
|
}
|
|
if (ParticlesLODed[num39] > 0)
|
|
{
|
|
particles[num39].startSize = Mathf.Lerp(particles[num39].startSize, 0f, Time.deltaTime * LODFadeOutSpeed);
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, new Color((int)particles[num39].startColor.r, (int)particles[num39].startColor.g, (int)particles[num39].startColor.b, 0f), Time.deltaTime * LODFadeOutSpeed * 2f);
|
|
}
|
|
}
|
|
else if (ParticlesLODed[num39] > 0)
|
|
{
|
|
if (particles[num39].startSize < (float)ParticlesLODed[num39])
|
|
{
|
|
particles[num39].startSize = Mathf.Lerp(particles[num39].startSize, ParticlesLODed[num39], Time.deltaTime * LODFadeInSpeed * 2f);
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, new Color((int)particles[num39].startColor.r, (int)particles[num39].startColor.g, (int)particles[num39].startColor.b, 1f), Time.deltaTime * LODFadeInSpeed);
|
|
}
|
|
else
|
|
{
|
|
ParticlesLODed[num39] = 0;
|
|
}
|
|
}
|
|
}
|
|
float magnitude3 = (particles[num39].position - keep_sun_transf.position).magnitude;
|
|
float num45 = (magnitude3 - magnitude2 + cloud_scale / Sun_exposure * Scale_per_cloud[num40]) / (cloud_scale / Sun_exposure * Scale_per_cloud[num40]);
|
|
float num46 = 0f;
|
|
if (Sun_dist_on)
|
|
{
|
|
float magnitude4 = (This_transf.position - keep_sun_transf.position).magnitude;
|
|
num46 = (magnitude3 - magnitude4 + global_cloud_scale) / global_cloud_scale;
|
|
num45 = Mathf.Lerp(num45, num46, 0.5f);
|
|
}
|
|
Color sunColor = SunColor;
|
|
if (Grab_sun_angle)
|
|
{
|
|
float f = Vector3.Angle(particles[num39].position - keep_sun_transf.position, This_transf.position - keep_sun_transf.position);
|
|
sunColor.a = SunColor.a / (Mathf.Abs(f) * Sun_angle_influence);
|
|
}
|
|
if (Prev_cam_rot == Cam_transf.eulerAngles)
|
|
{
|
|
if ((float)Init_color < Delay_lerp)
|
|
{
|
|
if (SmoothIn)
|
|
{
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, Global_tint + Color.Lerp(sunColor, MainColor, num45), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else
|
|
{
|
|
particles[num39].startColor = Global_tint + Color.Lerp(sunColor, MainColor, num45);
|
|
}
|
|
Init_color++;
|
|
}
|
|
else if (SmoothIn)
|
|
{
|
|
if (!DecoupledColor)
|
|
{
|
|
if (VerticalForm & (particles[num39].position.y - vector8.y > YScaleDiff))
|
|
{
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, Color.Lerp(particles[num39].startColor, Color.Lerp(Global_tint + Color.Lerp(sunColor, MainColor, num45), HeightTint, HeightTint.a), color_speed * Time.deltaTime), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else if (!DecoupledWind)
|
|
{
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, Color.Lerp(particles[num39].startColor, Global_tint + Color.Lerp(sunColor, MainColor, num45), color_speed * Time.deltaTime), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
}
|
|
}
|
|
else if (SmoothOut)
|
|
{
|
|
if (!DecoupledColor)
|
|
{
|
|
_ = VerticalForm & (particles[num39].position.y - vector8.y > YScaleDiff);
|
|
if (ScatterMat != null && ScatterMat.HasProperty("_TintColor"))
|
|
{
|
|
Color a4 = ScatterMat.GetVector("_TintColor");
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(a4, new Color(a4.r, a4.g, a4.b, 0f), 0.01f * Time.deltaTime * SmoothoutSpeed));
|
|
}
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, new Color((int)particles[num39].startColor.r, (int)particles[num39].startColor.g, (int)particles[num39].startColor.b, 0f), Time.deltaTime * SmoothoutSpeed * 0.5f);
|
|
}
|
|
}
|
|
else if (VerticalForm & (particles[num39].position.y - vector8.y > YScaleDiff))
|
|
{
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, Color.Lerp(Global_tint + Color.Lerp(sunColor, MainColor, num45), HeightTint, HeightTint.a), color_speed * Time.deltaTime * 0.005f);
|
|
}
|
|
else
|
|
{
|
|
particles[num39].startColor = Color.Lerp(particles[num39].startColor, Global_tint + Color.Lerp(sunColor, MainColor, num45), color_speed * Time.deltaTime * 0.005f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Prev_cam_rot = Cam_transf.eulerAngles;
|
|
}
|
|
}
|
|
if (CloudWaves && ((ParticlesLODed[num39] == 0) & !SmoothIn))
|
|
{
|
|
particles[num39].startColor = new Color((int)particles[num39].startColor.r, (int)particles[num39].startColor.g, (int)particles[num39].startColor.b, Mathf.Abs(Mathf.Cos(WaveFreq * Time.fixedTime + 0.005f * Vector3.Distance(particles[num39].position, This_transf.position))));
|
|
}
|
|
}
|
|
if (!DecoupledWind)
|
|
{
|
|
ShurikenParticle.SetParticles(particles, particles.Length);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!DecoupledWind)
|
|
{
|
|
return;
|
|
}
|
|
int num47 = 0;
|
|
int num48 = 0;
|
|
for (int num49 = 0; num49 < divider; num49++)
|
|
{
|
|
if (!DifferentialMotion)
|
|
{
|
|
Centers[num49] += wind * (multiplier * speed * 5f) * Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
Centers[num49] += wind * (multiplier * speed * 5f) * Time.deltaTime * (MaxDiffSpeed * (((float)num49 + MaxDiffOffset) / (float)divider));
|
|
}
|
|
if (!Add_shadows)
|
|
{
|
|
continue;
|
|
}
|
|
if (!Divide_lightning || (Divide_lightning & (num47 == LightningDivider)))
|
|
{
|
|
if (num48 < Shadow_planes.Count)
|
|
{
|
|
Shadow_planes[num48].position = Centers[num49];
|
|
}
|
|
num47 = 0;
|
|
num48++;
|
|
}
|
|
else
|
|
{
|
|
num47++;
|
|
}
|
|
}
|
|
if (Sorted && init_centers)
|
|
{
|
|
float num50 = Cam_transf.eulerAngles.z - Prev_cam_rot.z;
|
|
float y = Cam_transf.eulerAngles.y;
|
|
float num51 = y - Prev_cam_rot.y;
|
|
if (Mathf.Abs(num51) > 180f)
|
|
{
|
|
num51 = 360f - Mathf.Abs(num51);
|
|
}
|
|
float num52 = 0f;
|
|
float num53 = 0f;
|
|
if (StableRollMethod2)
|
|
{
|
|
num52 = Mathf.Abs(Vector3.Angle(Cam_transf.forward, Mathf.Sign(Cam_transf.forward.y) * Vector3.up));
|
|
num53 = (0f - Mathf.Sign(Cam_transf.forward.y)) * Vector3.Dot(Cam_transf.forward, Mathf.Sign(Cam_transf.forward.y) * Vector3.up);
|
|
}
|
|
for (int num54 = 0; num54 < particles.Length; num54++)
|
|
{
|
|
particles[num54].remainingLifetime = 100000f;
|
|
particles[num54].startLifetime = 100000f;
|
|
if (!DifferentialMotion)
|
|
{
|
|
particles[num54].position = particles[num54].position + wind * (multiplier * speed * 5f) * Time.deltaTime;
|
|
}
|
|
else
|
|
{
|
|
particles[num54].position = particles[num54].position + wind * (multiplier * speed * 5f) * Time.deltaTime * (MaxDiffSpeed * (((float)num54 + MaxDiffOffset) / (float)particles.Length));
|
|
}
|
|
if (renewAboveHeight)
|
|
{
|
|
if (particles[num54].position.y > renewHeight)
|
|
{
|
|
particles[num54].position = new Vector3(particles[num54].position.x, This_transf.position.y, particles[num54].position.z);
|
|
}
|
|
if (particles[num54].position.y > renewHeightPercent / 100f * renewHeight)
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, new Color((int)particles[num54].startColor.r, (int)particles[num54].startColor.g, (int)particles[num54].startColor.b, 0f), Time.deltaTime * renewFadeOutSpeed * 5.5f);
|
|
}
|
|
else
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, new Color((int)particles[num54].startColor.r, (int)particles[num54].startColor.g, (int)particles[num54].startColor.b, (Global_tint + Color.Lerp(SunColor, MainColor, 0.8f)).a), Time.deltaTime * renewFadeInSpeed * 10.5f);
|
|
}
|
|
if ((double)particles[num54].position.y < (double)This_transf.position.y + 0.1 * (double)This_transf.position.y)
|
|
{
|
|
particles[num54].startColor = new Color((int)particles[num54].startColor.r, (int)particles[num54].startColor.g, (int)particles[num54].startColor.b, 0f);
|
|
}
|
|
}
|
|
if (DecoupledColor)
|
|
{
|
|
int num55 = 0;
|
|
Vector3 vector9 = Centers[0];
|
|
if (DecoupledCounter == num54 || CenterIDs.Count < particles.Length)
|
|
{
|
|
for (int num56 = 0; num56 < Centers.Count; num56++)
|
|
{
|
|
if (Use2DCheck)
|
|
{
|
|
if (Vector2.Distance(new Vector2(Centers[num56].x, Centers[num56].z), new Vector2(particles[num54].position.x, particles[num54].position.z)) < Vector3.Distance(new Vector2(vector9.x, vector9.z), new Vector2(particles[num54].position.x, particles[num54].position.z)))
|
|
{
|
|
vector9 = Centers[num56];
|
|
num55 = num56;
|
|
}
|
|
}
|
|
else if (Vector3.Distance(Centers[num56], particles[num54].position) < Vector3.Distance(vector9, particles[num54].position))
|
|
{
|
|
vector9 = Centers[num56];
|
|
num55 = num56;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
num55 = CenterIDs[num54];
|
|
vector9 = Centers[num55];
|
|
}
|
|
if (CenterIDs.Count < particles.Length)
|
|
{
|
|
CenterIDs.Add(num55);
|
|
}
|
|
float magnitude5 = (vector9 - keep_sun_transf.position).magnitude;
|
|
if (Flatten_below && vector9.y - particles[num54].position.y > 0f)
|
|
{
|
|
particles[num54].position = new Vector3(particles[num54].position.x, particles[num54].position.y + 500f * Time.deltaTime, particles[num54].position.z);
|
|
}
|
|
float magnitude6 = (particles[num54].position - keep_sun_transf.position).magnitude;
|
|
float num57 = (magnitude6 - magnitude5 + cloud_scale / Sun_exposure * Scale_per_cloud[num55]) / (cloud_scale / Sun_exposure * Scale_per_cloud[num55]);
|
|
float num58 = 0f;
|
|
if (Sun_dist_on)
|
|
{
|
|
float magnitude7 = (This_transf.position - keep_sun_transf.position).magnitude;
|
|
num58 = (magnitude6 - magnitude7 + global_cloud_scale) / global_cloud_scale;
|
|
num57 = Mathf.Lerp(num57, num58, 0.5f);
|
|
}
|
|
Color sunColor2 = SunColor;
|
|
if (Grab_sun_angle)
|
|
{
|
|
float f2 = Vector3.Angle(particles[num54].position - keep_sun_transf.position, This_transf.position - keep_sun_transf.position);
|
|
sunColor2.a = SunColor.a / (Mathf.Abs(f2) * Sun_angle_influence);
|
|
}
|
|
if (Prev_cam_rot == Cam_transf.eulerAngles)
|
|
{
|
|
if ((float)Init_color < Delay_lerp)
|
|
{
|
|
if (SmoothIn)
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Global_tint + Color.Lerp(sunColor2, MainColor, num57), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else
|
|
{
|
|
particles[num54].startColor = Global_tint + Color.Lerp(sunColor2, MainColor, num57);
|
|
}
|
|
Init_color++;
|
|
}
|
|
else if (SmoothIn)
|
|
{
|
|
if (VerticalForm & (particles[num54].position.y - vector9.y > YScaleDiff))
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Color.Lerp(particles[num54].startColor, Color.Lerp(Global_tint + Color.Lerp(sunColor2, MainColor, num57), HeightTint, HeightTint.a), color_speed * Time.deltaTime), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
else
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Color.Lerp(particles[num54].startColor, Global_tint + Color.Lerp(sunColor2, MainColor, num57), color_speed * Time.deltaTime), Time.deltaTime * SmoothInSpeed);
|
|
}
|
|
if (Time.fixedTime - current_fadein_time > fade_in_time)
|
|
{
|
|
SmoothIn = false;
|
|
}
|
|
}
|
|
else if (SmoothOut)
|
|
{
|
|
_ = VerticalForm & (particles[num54].position.y - vector9.y > YScaleDiff);
|
|
if (ScatterMat != null)
|
|
{
|
|
Color a5 = ScatterMat.GetVector("_TintColor");
|
|
ScatterMat.SetVector("_TintColor", Color.Lerp(a5, new Color(a5.r, a5.g, a5.b, 0f), 0.2f * Time.deltaTime * SmoothoutSpeed));
|
|
}
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, new Color((int)particles[num54].startColor.r, (int)particles[num54].startColor.g, (int)particles[num54].startColor.b, 0f), Time.deltaTime * SmoothoutSpeed * 100f);
|
|
}
|
|
else if (VerticalForm & (particles[num54].position.y - vector9.y > YScaleDiff))
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Color.Lerp(Global_tint + Color.Lerp(sunColor2, MainColor, num57), HeightTint, HeightTint.a), color_speed * Time.deltaTime);
|
|
}
|
|
else
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Global_tint + Color.Lerp(sunColor2, MainColor, num57), color_speed * Time.deltaTime);
|
|
}
|
|
}
|
|
}
|
|
else if (SmoothIn)
|
|
{
|
|
particles[num54].startColor = Color.Lerp(particles[num54].startColor, Color.Lerp(particles[num54].startColor, Global_tint + Color.Lerp(SunColor, MainColor, 0.8f), color_speed * Time.deltaTime), Time.deltaTime * SmoothInSpeed * 0.5f);
|
|
if (Time.fixedTime - current_fadein_time > fade_in_time)
|
|
{
|
|
SmoothIn = false;
|
|
}
|
|
}
|
|
if (!StableRollMethod2)
|
|
{
|
|
continue;
|
|
}
|
|
if (!StableRollAllAxis)
|
|
{
|
|
float num59 = Cam_transf.eulerAngles.z - Prev_cam_rot.z;
|
|
float y2 = Cam_transf.eulerAngles.y;
|
|
if (num59 == 0f && y2 != Prev_cam_rot.y && Mathf.Abs(Vector3.Angle(Cam_transf.forward, Vector3.up)) < 65f)
|
|
{
|
|
float num60 = y2 - Prev_cam_rot.y;
|
|
particles[num54].rotation = particles[num54].rotation + num60;
|
|
}
|
|
else if (!(Mathf.Abs(Vector3.Angle(Cam_transf.forward, Vector3.up)) < 45f))
|
|
{
|
|
particles[num54].rotation = particles[num54].rotation + num59;
|
|
}
|
|
}
|
|
else if (num50 == 0f && y != Prev_cam_rot.y && num52 < 65f)
|
|
{
|
|
particles[num54].rotation = particles[num54].rotation - num51 * num53;
|
|
}
|
|
else
|
|
{
|
|
Mathf.Abs(Vector3.Angle(Cam_transf.forward, Vector3.up));
|
|
_ = 45f;
|
|
particles[num54].rotation = particles[num54].rotation + num50 - num51 * num53;
|
|
}
|
|
}
|
|
if (Prev_cam_rot != Cam_transf.eulerAngles)
|
|
{
|
|
Prev_cam_rot = Cam_transf.eulerAngles;
|
|
}
|
|
DecoupledCounter++;
|
|
if (DecoupledCounter == particles.Length)
|
|
{
|
|
DecoupledCounter = 0;
|
|
}
|
|
}
|
|
ShurikenParticle.SetParticles(particles, particles.Length);
|
|
}
|
|
|
|
private static Vector3 totalRayleigh(Vector3 lambda)
|
|
{
|
|
return new Vector3(8f * Mathf.Pow(MathF.PI, 3f) * Mathf.Pow(Mathf.Pow(1.0003f, 2f) - 1f, 2f) * 6.105f / (7.635E+25f * Mathf.Pow(lambda.x, 4f) * 5.755f), 8f * Mathf.Pow(MathF.PI, 3f) * Mathf.Pow(Mathf.Pow(1.0003f, 2f) - 1f, 2f) * 6.105f / (7.635E+25f * Mathf.Pow(lambda.y, 4f) * 5.755f), 8f * Mathf.Pow(MathF.PI, 3f) * Mathf.Pow(Mathf.Pow(1.0003f, 2f) - 1f, 2f) * 6.105f / (7.635E+25f * Mathf.Pow(lambda.z, 4f) * 5.755f));
|
|
}
|
|
|
|
private static Vector3 totalMie(Vector3 lambda, Vector3 K, float T)
|
|
{
|
|
float num = 0.2f * T * 1E-16f;
|
|
return new Vector3(0.434f * num * MathF.PI * Mathf.Pow(MathF.PI * 2f / lambda.x, 2f) * K.x, 0.434f * num * MathF.PI * Mathf.Pow(MathF.PI * 2f / lambda.y, 2f) * K.y, 0.434f * num * MathF.PI * Mathf.Pow(MathF.PI * 2f / lambda.z, 2f) * K.z);
|
|
}
|
|
}
|
|
}
|