1417 lines
50 KiB
C#
1417 lines
50 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Artngame.SKYMASTER
|
|
{
|
|
[ExecuteInEditMode]
|
|
public class ParticlePropagationSKYMASTER : MonoBehaviour
|
|
{
|
|
public enum PaintType
|
|
{
|
|
Painted = 0,
|
|
BrushPainted = 1,
|
|
SkinnedMesh = 2,
|
|
SimpleMesh = 3,
|
|
Propagated = 4,
|
|
Projected = 5,
|
|
Spline = 6,
|
|
ParticleCollision = 7,
|
|
ParticlePosition = 8
|
|
}
|
|
|
|
public List<GameObject> Systems_To_override;
|
|
|
|
private List<ParticlePropagationSKYMASTER> systems_To_override;
|
|
|
|
public float cut_off_dist = 0.1f;
|
|
|
|
public bool reset_overrides;
|
|
|
|
[HideInInspector]
|
|
public List<PaintType> PaintTypes;
|
|
|
|
public bool gameobject_mode;
|
|
|
|
public bool Scale_by_texture;
|
|
|
|
public bool Color_by_texture;
|
|
|
|
public bool Follow_scale;
|
|
|
|
public bool Grow_trees;
|
|
|
|
public float Grow_time = 1f;
|
|
|
|
private float Current_Grow_time;
|
|
|
|
public bool Preview_mode;
|
|
|
|
public int particle_count = 100;
|
|
|
|
[HideInInspector]
|
|
public List<Transform> Gameobj_instances;
|
|
|
|
public GameObject Gameobj;
|
|
|
|
public bool Gravity_Mode;
|
|
|
|
public float grav_factor = 0.1f;
|
|
|
|
public float Y_offset;
|
|
|
|
public float X_offset_factor = 0.005f;
|
|
|
|
public float Z_offset_factor = 0.007f;
|
|
|
|
public bool let_loose;
|
|
|
|
public GameObject Parent_OBJ;
|
|
|
|
public bool Angled;
|
|
|
|
public bool Asign_rot;
|
|
|
|
public Vector3 Local_rot = Vector3.zero;
|
|
|
|
private PerlinSKYMASTER noise;
|
|
|
|
public float Wind_speed = 1f;
|
|
|
|
public bool follow_particles;
|
|
|
|
public bool Remove_colliders;
|
|
|
|
public bool look_at_direction;
|
|
|
|
public bool look_at_normal;
|
|
|
|
private ControlCombineChildrenSKYMASTER Combiner;
|
|
|
|
public bool enable_combine;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Updated_gameobject_positions;
|
|
|
|
public float Release_Gravity = 0.05f;
|
|
|
|
public bool Use_stencil;
|
|
|
|
public Texture2D Stencil;
|
|
|
|
public Vector2 tex_scale = new Vector2(3f, 3f);
|
|
|
|
public float Coloration_ammount = 0.5f;
|
|
|
|
public bool Real_time_painting;
|
|
|
|
public bool Color_effects;
|
|
|
|
public bool Lerp_color;
|
|
|
|
public bool Keep_color;
|
|
|
|
[HideInInspector]
|
|
public List<Vector4> Particle_color;
|
|
|
|
public Vector2 Stencil_divisions = new Vector2(8f, 8f);
|
|
|
|
private GameObject[] Flammable_objects;
|
|
|
|
private GameObject[] Flamer_objects;
|
|
|
|
public bool propagation = true;
|
|
|
|
[HideInInspector]
|
|
public int maxemitter_count;
|
|
|
|
[HideInInspector]
|
|
public int current_emitters_count;
|
|
|
|
public float brush_size = 1f;
|
|
|
|
public bool Erase_mode;
|
|
|
|
public float Marker_size = 0.5f;
|
|
|
|
public ParticleSystem p11;
|
|
|
|
[HideInInspector]
|
|
public List<Transform> Emitter_objects;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Registered_paint_positions;
|
|
|
|
public float stay_time = 2f;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Registered_paint_rotations;
|
|
|
|
[HideInInspector]
|
|
public List<float> Registered_paint_times;
|
|
|
|
[HideInInspector]
|
|
public List<float> Registered_paint_size;
|
|
|
|
public List<GameObject> Projectors;
|
|
|
|
public float max_growth_size = 1f;
|
|
|
|
public float min_propagation_dist = 3f;
|
|
|
|
public float max_propagation_dist = 6f;
|
|
|
|
private List<Vector3> ray_dest_positions = new List<Vector3>();
|
|
|
|
private bool got_random_offsets;
|
|
|
|
public bool go_random;
|
|
|
|
private Vector2[] rand_offsets;
|
|
|
|
public float extend = 1f;
|
|
|
|
private bool randomize;
|
|
|
|
public bool follow_normals;
|
|
|
|
public float density_dist_factor = 3f;
|
|
|
|
public int propagation_chance_factor = 1;
|
|
|
|
public bool use_projection;
|
|
|
|
public bool use_particle_collisions;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Updated_Registered_paint_positions;
|
|
|
|
public bool By_layer;
|
|
|
|
public List<string> Layers;
|
|
|
|
public bool keep_alive;
|
|
|
|
public bool Grow_ice_mesh;
|
|
|
|
public bool variant_size;
|
|
|
|
public bool Vary_gameobj_size;
|
|
|
|
public float Random_size_upper_bound = 2f;
|
|
|
|
public float Random_size_lower_bound = 0.9f;
|
|
|
|
[HideInInspector]
|
|
public float Random_size_factor;
|
|
|
|
public float debug_rot;
|
|
|
|
public bool is_ice;
|
|
|
|
public bool is_fire;
|
|
|
|
public bool is_butterfly;
|
|
|
|
public bool enable_overides;
|
|
|
|
[HideInInspector]
|
|
public List<int> LocalOverrides;
|
|
|
|
public bool enable_melt;
|
|
|
|
public bool enable_freeze;
|
|
|
|
public bool enable_burn;
|
|
|
|
public float max_burn_ammount = 25f;
|
|
|
|
public float max_freeze_ammount = 25f;
|
|
|
|
public float Thaw_speed;
|
|
|
|
public float Freeze_speed = 0.15f;
|
|
|
|
public bool enable_flyaway;
|
|
|
|
public float melt_speed = 0.2f;
|
|
|
|
public float fast_melt_speed = 0.4f;
|
|
|
|
public bool enable_LocalWind;
|
|
|
|
public bool is_grass;
|
|
|
|
public float overide_GrassAngle;
|
|
|
|
public float overide_WindSpeed;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Registered_initial_positions;
|
|
|
|
[HideInInspector]
|
|
public List<Quaternion> Registered_initial_rotation;
|
|
|
|
[HideInInspector]
|
|
public List<Vector3> Registered_initial_scale;
|
|
|
|
private ParticleSystem.Particle[] ParticleList;
|
|
|
|
private float Grab_time;
|
|
|
|
public float Delay = 1f;
|
|
|
|
public bool Optimize;
|
|
|
|
public bool Use_Lerp;
|
|
|
|
private float Grab_time_calcs;
|
|
|
|
public float Delay_calcs = 1f;
|
|
|
|
public bool Optimize_calcs;
|
|
|
|
public bool relaxed = true;
|
|
|
|
public bool draw_in_sequence;
|
|
|
|
public bool Velocity_toward_normal;
|
|
|
|
public Vector3 Normal_Velocity = new Vector3(0f, 0f, 0f);
|
|
|
|
public float keep_in_position_factor = 0.9f;
|
|
|
|
public float keep_alive_factor = 0.1f;
|
|
|
|
private void Start()
|
|
{
|
|
systems_To_override = new List<ParticlePropagationSKYMASTER>();
|
|
if (Systems_To_override != null && Systems_To_override.Count > 0)
|
|
{
|
|
for (int i = 0; i < Systems_To_override.Count; i++)
|
|
{
|
|
systems_To_override.Add(Systems_To_override[i].GetComponent(typeof(ParticlePropagationSKYMASTER)) as ParticlePropagationSKYMASTER);
|
|
}
|
|
}
|
|
Grab_time = Time.fixedTime;
|
|
Grab_time_calcs = Time.fixedTime;
|
|
if (p11 == null)
|
|
{
|
|
p11 = base.gameObject.GetComponent<ParticleSystem>();
|
|
if ((p11 != null) & gameobject_mode)
|
|
{
|
|
ParticleSystem.MainModule main = p11.main;
|
|
main.maxParticles = particle_count;
|
|
p11.Emit(particle_count);
|
|
}
|
|
}
|
|
noise = new PerlinSKYMASTER();
|
|
Current_Grow_time = Time.fixedTime;
|
|
if (Particle_color == null)
|
|
{
|
|
Particle_color = new List<Vector4>();
|
|
for (int j = 0; j < Registered_paint_positions.Count; j++)
|
|
{
|
|
Particle_color.Add(new Vector4(0f, 0f, 0f, 999f));
|
|
}
|
|
}
|
|
else if (Particle_color.Count != Registered_paint_positions.Count)
|
|
{
|
|
Particle_color.Clear();
|
|
for (int k = 0; k < Registered_paint_positions.Count; k++)
|
|
{
|
|
Particle_color.Add(new Vector4(0f, 0f, 0f, 999f));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
p11 = base.gameObject.GetComponent("ParticleSystem") as ParticleSystem;
|
|
if (p11 == null)
|
|
{
|
|
Debug.Log("Please attach the script to a particle system");
|
|
}
|
|
Flammable_objects = GameObject.FindGameObjectsWithTag("Flammable");
|
|
Flamer_objects = GameObject.FindGameObjectsWithTag("Flamer");
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (p11 == null)
|
|
{
|
|
return;
|
|
}
|
|
if (Parent_OBJ != null && enable_combine && Combiner == null)
|
|
{
|
|
Combiner = Parent_OBJ.GetComponent(typeof(ControlCombineChildrenSKYMASTER)) as ControlCombineChildrenSKYMASTER;
|
|
if (Combiner != null)
|
|
{
|
|
Combiner.Auto_Disable = true;
|
|
}
|
|
else
|
|
{
|
|
Parent_OBJ.AddComponent(typeof(ControlCombineChildrenSKYMASTER));
|
|
Combiner = Parent_OBJ.GetComponent(typeof(ControlCombineChildrenSKYMASTER)) as ControlCombineChildrenSKYMASTER;
|
|
Combiner.Auto_Disable = true;
|
|
}
|
|
}
|
|
if (Gameobj_instances != null && ((Gameobj_instances.Count > 0) & (Updated_gameobject_positions != null)))
|
|
{
|
|
for (int i = 0; i < Gameobj_instances.Count; i++)
|
|
{
|
|
if ((Updated_gameobject_positions[i] - Gameobj_instances[i].position).magnitude > 0.1f)
|
|
{
|
|
Updated_gameobject_positions[i] = Gameobj_instances[i].position;
|
|
}
|
|
else
|
|
{
|
|
Gameobj_instances[i].position = Updated_gameobject_positions[i];
|
|
}
|
|
}
|
|
}
|
|
if ((Registered_paint_times == null) & Application.isPlaying)
|
|
{
|
|
for (int j = 0; j < Registered_paint_positions.Count; j++)
|
|
{
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
}
|
|
}
|
|
if ((Projectors != null) & Application.isPlaying)
|
|
{
|
|
for (int num = Projectors.Count - 1; num >= 0; num--)
|
|
{
|
|
if (Projectors[num] == null)
|
|
{
|
|
Projectors.RemoveAt(num);
|
|
}
|
|
}
|
|
}
|
|
Random_size_factor = 0f;
|
|
if (variant_size)
|
|
{
|
|
Random_size_factor = Random.Range(0f - Random_size_lower_bound, Random_size_upper_bound);
|
|
}
|
|
if (reset_overrides)
|
|
{
|
|
for (int k = 0; k < LocalOverrides.Count; k++)
|
|
{
|
|
LocalOverrides[k] = 0;
|
|
}
|
|
reset_overrides = false;
|
|
}
|
|
if (gameobject_mode)
|
|
{
|
|
if ((Preview_mode & !Application.isPlaying) && Gameobj_instances != null && Parent_OBJ.transform.childCount > Gameobj_instances.Count)
|
|
{
|
|
for (int num2 = Parent_OBJ.transform.childCount - 1; num2 >= 0; num2--)
|
|
{
|
|
Object.DestroyImmediate(Parent_OBJ.transform.GetChild(num2).gameObject);
|
|
}
|
|
}
|
|
if (Gameobj_instances == null)
|
|
{
|
|
Gameobj_instances = new List<Transform>();
|
|
}
|
|
if (!Preview_mode & !Application.isPlaying)
|
|
{
|
|
for (int num3 = Gameobj_instances.Count - 1; num3 >= 0; num3--)
|
|
{
|
|
Object.DestroyImmediate(Gameobj_instances[num3].gameObject);
|
|
}
|
|
}
|
|
if (Gameobj_instances != null)
|
|
{
|
|
for (int num4 = Gameobj_instances.Count - 1; num4 >= 0; num4--)
|
|
{
|
|
if (Gameobj_instances[num4] == null)
|
|
{
|
|
Gameobj_instances.RemoveAt(num4);
|
|
Updated_gameobject_positions.RemoveAt(num4);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((Time.fixedTime - Grab_time > Delay) | !Optimize)
|
|
{
|
|
Grab_time = Time.fixedTime;
|
|
if (Registered_paint_positions != null)
|
|
{
|
|
for (int num5 = Registered_paint_positions.Count - 1; num5 >= 0; num5--)
|
|
{
|
|
if (enable_melt)
|
|
{
|
|
for (int l = 0; l < systems_To_override.Count; l++)
|
|
{
|
|
if (!((systems_To_override[l].is_ice & is_fire) | (systems_To_override[l].is_fire & is_ice)))
|
|
{
|
|
continue;
|
|
}
|
|
for (int num6 = systems_To_override[l].Registered_paint_positions.Count - 1; num6 >= 0; num6--)
|
|
{
|
|
if (Vector3.Distance(Registered_paint_positions[num5], systems_To_override[l].Registered_paint_positions[num6]) < cut_off_dist)
|
|
{
|
|
LocalOverrides[num5] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Emitter_objects[num5] == null)
|
|
{
|
|
Updated_Registered_paint_positions.RemoveAt(num5);
|
|
Particle_color.RemoveAt(num5);
|
|
Registered_paint_rotations.RemoveAt(num5);
|
|
Registered_paint_times.RemoveAt(num5);
|
|
Registered_paint_size.RemoveAt(num5);
|
|
Registered_paint_positions.RemoveAt(num5);
|
|
Registered_initial_positions.RemoveAt(num5);
|
|
Registered_initial_rotation.RemoveAt(num5);
|
|
Registered_initial_scale.RemoveAt(num5);
|
|
Emitter_objects.RemoveAt(num5);
|
|
LocalOverrides.RemoveAt(num5);
|
|
PaintTypes.RemoveAt(num5);
|
|
if (gameobject_mode && num5 < Gameobj_instances.Count)
|
|
{
|
|
Object.Destroy(Gameobj_instances[num5].gameObject);
|
|
Gameobj_instances.RemoveAt(num5);
|
|
Updated_gameobject_positions.RemoveAt(num5);
|
|
}
|
|
}
|
|
else if (Application.isPlaying & (!keep_alive | (enable_overides & ((LocalOverrides[num5] == 1) | (LocalOverrides[num5] == 3)))) & (Emitter_objects[num5].gameObject.tag != "Flamer") & (Time.fixedTime - Registered_paint_times[num5] > stay_time))
|
|
{
|
|
if (enable_freeze & (Emitter_objects[num5].gameObject.tag == "Freezable"))
|
|
{
|
|
FreezeBurnControlSKYMASTER freezeBurnControlSKYMASTER = Emitter_objects[num5].gameObject.GetComponent(typeof(FreezeBurnControlSKYMASTER)) as FreezeBurnControlSKYMASTER;
|
|
if (freezeBurnControlSKYMASTER == null)
|
|
{
|
|
Emitter_objects[num5].gameObject.AddComponent(typeof(FreezeBurnControlSKYMASTER));
|
|
freezeBurnControlSKYMASTER = Emitter_objects[num5].gameObject.GetComponent(typeof(FreezeBurnControlSKYMASTER)) as FreezeBurnControlSKYMASTER;
|
|
freezeBurnControlSKYMASTER.max_burn_ammount = max_burn_ammount;
|
|
freezeBurnControlSKYMASTER.max_freeze_ammount = max_freeze_ammount;
|
|
freezeBurnControlSKYMASTER.Thaw_speed = Thaw_speed;
|
|
freezeBurnControlSKYMASTER.Freeze_speed = Freeze_speed;
|
|
}
|
|
if (freezeBurnControlSKYMASTER.freeze_ammount < freezeBurnControlSKYMASTER.max_freeze_ammount)
|
|
{
|
|
freezeBurnControlSKYMASTER.freeze_ammount += 1f;
|
|
}
|
|
}
|
|
if (enable_burn & (Emitter_objects[num5].gameObject.tag == "Flammable"))
|
|
{
|
|
FreezeBurnControlSKYMASTER freezeBurnControlSKYMASTER2 = Emitter_objects[num5].gameObject.GetComponent(typeof(FreezeBurnControlSKYMASTER)) as FreezeBurnControlSKYMASTER;
|
|
if (freezeBurnControlSKYMASTER2 == null)
|
|
{
|
|
Emitter_objects[num5].gameObject.AddComponent(typeof(FreezeBurnControlSKYMASTER));
|
|
freezeBurnControlSKYMASTER2 = Emitter_objects[num5].gameObject.GetComponent(typeof(FreezeBurnControlSKYMASTER)) as FreezeBurnControlSKYMASTER;
|
|
freezeBurnControlSKYMASTER2.max_burn_ammount = max_burn_ammount;
|
|
freezeBurnControlSKYMASTER2.max_freeze_ammount = max_freeze_ammount;
|
|
freezeBurnControlSKYMASTER2.Thaw_speed = Thaw_speed;
|
|
freezeBurnControlSKYMASTER2.Freeze_speed = Freeze_speed;
|
|
}
|
|
if (freezeBurnControlSKYMASTER2.burn_ammount < freezeBurnControlSKYMASTER2.max_burn_ammount)
|
|
{
|
|
freezeBurnControlSKYMASTER2.burn_ammount += 1f;
|
|
}
|
|
}
|
|
Updated_Registered_paint_positions.RemoveAt(num5);
|
|
Particle_color.RemoveAt(num5);
|
|
Registered_paint_rotations.RemoveAt(num5);
|
|
Registered_paint_times.RemoveAt(num5);
|
|
Registered_paint_size.RemoveAt(num5);
|
|
Registered_paint_positions.RemoveAt(num5);
|
|
Registered_initial_positions.RemoveAt(num5);
|
|
Registered_initial_rotation.RemoveAt(num5);
|
|
Registered_initial_scale.RemoveAt(num5);
|
|
Emitter_objects.RemoveAt(num5);
|
|
LocalOverrides.RemoveAt(num5);
|
|
PaintTypes.RemoveAt(num5);
|
|
if (gameobject_mode)
|
|
{
|
|
Object.Destroy(Gameobj_instances[num5].gameObject);
|
|
Gameobj_instances.RemoveAt(num5);
|
|
Updated_gameobject_positions.RemoveAt(num5);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Application.isPlaying & propagation)
|
|
{
|
|
Flamer_objects = GameObject.FindGameObjectsWithTag("Flamer");
|
|
Flammable_objects = GameObject.FindGameObjectsWithTag("Flammable");
|
|
for (int m = 0; m < Flammable_objects.Length; m++)
|
|
{
|
|
if (Emitter_objects != null)
|
|
{
|
|
for (int n = 0; n < Emitter_objects.Count; n++)
|
|
{
|
|
if (!((Emitter_objects[n] != null) & (Flammable_objects[m] != null)) || !((Vector3.Distance(Emitter_objects[n].position, Flammable_objects[m].transform.position) < max_propagation_dist) & (Vector3.Distance(Emitter_objects[n].position, Flammable_objects[m].transform.position) > min_propagation_dist)))
|
|
{
|
|
continue;
|
|
}
|
|
Vector3 position = Emitter_objects[n].position;
|
|
position = Flammable_objects[m].transform.InverseTransformPoint(position);
|
|
Vector3 vector = Vector3.zero;
|
|
Vector3 item = Vector3.zero;
|
|
RaycastHit hitInfo = default(RaycastHit);
|
|
if (Physics.Raycast(Emitter_objects[n].position, Flammable_objects[m].transform.position - Emitter_objects[n].position, out hitInfo, float.PositiveInfinity))
|
|
{
|
|
if (hitInfo.collider.gameObject.tag == "Flammable")
|
|
{
|
|
vector = hitInfo.point;
|
|
item = hitInfo.normal;
|
|
}
|
|
else
|
|
{
|
|
vector = Vector3.zero;
|
|
item = Vector3.zero;
|
|
}
|
|
}
|
|
Vector3 vector2 = Flammable_objects[m].transform.TransformPoint(vector);
|
|
vector2 = vector;
|
|
if (!(vector2 != Vector3.zero) || Emitter_objects.Count > p11.main.maxParticles / 2)
|
|
{
|
|
continue;
|
|
}
|
|
int num7 = 0;
|
|
for (int num8 = 0; num8 < Registered_paint_positions.Count; num8++)
|
|
{
|
|
if (Emitter_objects[num8].gameObject == Flammable_objects[m] && Vector3.Distance(Registered_paint_positions[num8], vector2) < density_dist_factor)
|
|
{
|
|
num7 = 1;
|
|
}
|
|
}
|
|
if (Random.Range(1, propagation_chance_factor + 1) != propagation_chance_factor)
|
|
{
|
|
num7 = 1;
|
|
}
|
|
if (num7 != 0)
|
|
{
|
|
continue;
|
|
}
|
|
Registered_paint_positions.Add(vector2);
|
|
Updated_Registered_paint_positions.Add(vector2);
|
|
Particle_color.Add(new Vector4(0f, 0f, 0f, 999f));
|
|
Registered_paint_rotations.Add(item);
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
if (!gameobject_mode)
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
Emitter_objects.Add(hitInfo.collider.gameObject.transform);
|
|
Registered_initial_positions.Add(hitInfo.collider.gameObject.transform.position);
|
|
Registered_initial_scale.Add(hitInfo.collider.gameObject.transform.localScale);
|
|
Registered_initial_rotation.Add(hitInfo.collider.gameObject.transform.rotation);
|
|
LocalOverrides.Add(0);
|
|
PaintTypes.Add(PaintType.Propagated);
|
|
if (!(gameobject_mode & Application.isPlaying))
|
|
{
|
|
continue;
|
|
}
|
|
if (Gameobj_instances.Count < particle_count)
|
|
{
|
|
GameObject gameObject = Object.Instantiate(Gameobj, Registered_paint_positions[Registered_paint_positions.Count - 1], Quaternion.identity);
|
|
if (gameObject.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
gameObject.GetComponent<Collider>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
gameObject.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
Gameobj_instances.Add(gameObject.transform);
|
|
gameObject.transform.position = Registered_paint_positions[Registered_paint_positions.Count - 1];
|
|
if (Angled)
|
|
{
|
|
gameObject.transform.localEulerAngles = Registered_paint_rotations[Registered_paint_positions.Count - 1];
|
|
}
|
|
gameObject.transform.parent = Parent_OBJ.transform;
|
|
Updated_gameobject_positions.Add(gameObject.transform.position);
|
|
Registered_paint_size.Add(Gameobj_instances[Gameobj_instances.Count - 1].localScale.x);
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
}
|
|
}
|
|
if (Flamer_objects != null)
|
|
{
|
|
for (int num9 = 0; num9 < Flamer_objects.Length; num9++)
|
|
{
|
|
if (!((Vector3.Distance(Flamer_objects[num9].transform.position, Flammable_objects[m].transform.position) < max_propagation_dist) & (Vector3.Distance(Flamer_objects[num9].transform.position, Flammable_objects[m].transform.position) > min_propagation_dist)))
|
|
{
|
|
continue;
|
|
}
|
|
Vector3 position2 = Flamer_objects[num9].transform.position;
|
|
position2 = Flammable_objects[m].transform.InverseTransformPoint(position2);
|
|
Vector3 vector3 = Vector3.zero;
|
|
Vector3 item2 = Vector3.zero;
|
|
RaycastHit hitInfo2 = default(RaycastHit);
|
|
if (Physics.Raycast(Flamer_objects[num9].transform.position, Flammable_objects[m].transform.position - Flamer_objects[num9].transform.position, out hitInfo2, float.PositiveInfinity))
|
|
{
|
|
if (hitInfo2.collider.gameObject.tag == "Flammable")
|
|
{
|
|
vector3 = hitInfo2.point;
|
|
item2 = hitInfo2.normal;
|
|
}
|
|
else
|
|
{
|
|
vector3 = Vector3.zero;
|
|
item2 = Vector3.zero;
|
|
}
|
|
}
|
|
Vector3 vector4 = Flammable_objects[m].transform.TransformPoint(vector3);
|
|
vector4 = vector3;
|
|
if (!(vector4 != Vector3.zero) || Emitter_objects.Count > p11.main.maxParticles / 2)
|
|
{
|
|
continue;
|
|
}
|
|
int num10 = 0;
|
|
for (int num11 = 0; num11 < Registered_paint_positions.Count; num11++)
|
|
{
|
|
if (Emitter_objects[num11].gameObject == Flammable_objects[m] && Vector3.Distance(Registered_paint_positions[num11], vector4) < density_dist_factor)
|
|
{
|
|
num10 = 1;
|
|
}
|
|
}
|
|
if (num10 != 0)
|
|
{
|
|
continue;
|
|
}
|
|
Registered_paint_positions.Add(vector4);
|
|
Updated_Registered_paint_positions.Add(vector4);
|
|
Particle_color.Add(new Vector4(0f, 0f, 0f, 999f));
|
|
Registered_paint_rotations.Add(item2);
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
if (!gameobject_mode)
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
Emitter_objects.Add(hitInfo2.collider.gameObject.transform);
|
|
Registered_initial_positions.Add(hitInfo2.collider.gameObject.transform.position);
|
|
Registered_initial_scale.Add(hitInfo2.collider.gameObject.transform.localScale);
|
|
Registered_initial_rotation.Add(hitInfo2.collider.gameObject.transform.rotation);
|
|
LocalOverrides.Add(0);
|
|
PaintTypes.Add(PaintType.Propagated);
|
|
if (!(gameobject_mode & Application.isPlaying))
|
|
{
|
|
continue;
|
|
}
|
|
if (Gameobj_instances.Count < particle_count)
|
|
{
|
|
GameObject gameObject2 = Object.Instantiate(Gameobj, Registered_paint_positions[Registered_paint_positions.Count - 1], Quaternion.identity);
|
|
if (gameObject2.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
gameObject2.GetComponent<Collider>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
gameObject2.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
Gameobj_instances.Add(gameObject2.transform);
|
|
gameObject2.transform.position = Registered_paint_positions[Registered_paint_positions.Count - 1];
|
|
if (Angled)
|
|
{
|
|
gameObject2.transform.localEulerAngles = Registered_paint_rotations[Registered_paint_positions.Count - 1];
|
|
}
|
|
gameObject2.transform.parent = Parent_OBJ.transform;
|
|
Updated_gameobject_positions.Add(gameObject2.transform.position);
|
|
Registered_paint_size.Add(Gameobj_instances[Gameobj_instances.Count - 1].localScale.x);
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
}
|
|
}
|
|
if (!use_projection)
|
|
{
|
|
continue;
|
|
}
|
|
for (int num12 = 0; num12 < Projectors.Count; num12++)
|
|
{
|
|
Vector3 position3 = Projectors[num12].transform.position;
|
|
Quaternion rotation = Projectors[num12].transform.rotation;
|
|
_ = p11.main.maxParticles / 2;
|
|
int maxParticles = p11.main.maxParticles;
|
|
int maxParticles2 = p11.main.maxParticles;
|
|
ray_dest_positions.Clear();
|
|
int num13 = (int)Mathf.Sqrt(maxParticles);
|
|
if (!got_random_offsets)
|
|
{
|
|
got_random_offsets = true;
|
|
rand_offsets = new Vector2[num13 * num13];
|
|
int num14 = 0;
|
|
for (int num15 = 0; num15 < num13; num15++)
|
|
{
|
|
for (int num16 = 0; num16 < num13; num16++)
|
|
{
|
|
rand_offsets[num14] = new Vector2(Random.Range(0f, extend * (float)(num13 / 2) * (float)num15) + 1.5f * (float)num14, Random.Range(0f, extend * (float)(num13 / 2) * (float)num16) + 1.1f * (float)num14);
|
|
num14++;
|
|
}
|
|
}
|
|
}
|
|
int num17 = 0;
|
|
for (int num18 = 0; num18 < num13; num18++)
|
|
{
|
|
for (int num19 = 0; num19 < num13; num19++)
|
|
{
|
|
float num20 = extend * (float)(num13 / 2) * (float)num18;
|
|
float num21 = extend * (float)(num13 / 2) * (float)num19;
|
|
if (randomize)
|
|
{
|
|
num20 += Random.Range(0f, extend * (float)(num13 / 2) * (float)num18);
|
|
num21 += Random.Range(0f, extend * (float)(num13 / 2) * (float)num19);
|
|
}
|
|
if (!go_random)
|
|
{
|
|
ray_dest_positions.Add(rotation * new Vector3(position3.x - num20, position3.y - 1000f, position3.z - num21));
|
|
ray_dest_positions.Add(rotation * new Vector3(position3.x + num20, position3.y - 1000f, position3.z - num21));
|
|
}
|
|
if (go_random)
|
|
{
|
|
ray_dest_positions.Add(rotation * new Vector3(position3.x - rand_offsets[num17].x, position3.y - 1000f, position3.z - rand_offsets[num17].y));
|
|
num17++;
|
|
}
|
|
}
|
|
}
|
|
if (Registered_paint_positions == null || Registered_paint_positions.Count > maxParticles2 / 2)
|
|
{
|
|
continue;
|
|
}
|
|
for (int num22 = 0; num22 < ray_dest_positions.Count; num22++)
|
|
{
|
|
Vector3 origin = position3;
|
|
Vector3 direction = ray_dest_positions[num22];
|
|
RaycastHit hitInfo3 = default(RaycastHit);
|
|
if (Physics.Raycast(origin, direction, out hitInfo3, float.PositiveInfinity) && Registered_paint_positions != null && Registered_paint_positions.Count <= maxParticles2 / 2)
|
|
{
|
|
Registered_paint_positions.Add(hitInfo3.point);
|
|
Updated_Registered_paint_positions.Add(hitInfo3.point);
|
|
Particle_color.Add(new Vector4(0f, 0f, 0f, 999f));
|
|
Registered_paint_rotations.Add(hitInfo3.normal);
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
if (!gameobject_mode)
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
Emitter_objects.Add(hitInfo3.collider.gameObject.transform);
|
|
Registered_initial_positions.Add(hitInfo3.collider.gameObject.transform.position);
|
|
Registered_initial_scale.Add(hitInfo3.collider.gameObject.transform.localScale);
|
|
Registered_initial_rotation.Add(hitInfo3.collider.gameObject.transform.rotation);
|
|
LocalOverrides.Add(0);
|
|
PaintTypes.Add(PaintType.Projected);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((!Use_stencil & Application.isPlaying & Real_time_painting) && Input.GetMouseButtonDown(1))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hitInfo4 = default(RaycastHit);
|
|
if (Physics.Raycast(ray, out hitInfo4, float.PositiveInfinity) && hitInfo4.collider.gameObject.tag == "PPaint" && Emitter_objects != null)
|
|
{
|
|
if (!Erase_mode)
|
|
{
|
|
if (Emitter_objects.Count <= p11.main.maxParticles / 2)
|
|
{
|
|
Emitter_objects.Add(hitInfo4.collider.gameObject.transform);
|
|
Registered_paint_positions.Add(hitInfo4.point);
|
|
Updated_Registered_paint_positions.Add(hitInfo4.point);
|
|
Particle_color.Add(new Vector4(p11.main.startColor.color.r, p11.main.startColor.color.g, p11.main.startColor.color.b, p11.main.startColor.color.a));
|
|
Registered_paint_rotations.Add(hitInfo4.normal);
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
if (!gameobject_mode)
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
Registered_initial_positions.Add(hitInfo4.collider.gameObject.transform.position);
|
|
Registered_initial_scale.Add(hitInfo4.collider.gameObject.transform.localScale);
|
|
Registered_initial_rotation.Add(hitInfo4.collider.gameObject.transform.rotation);
|
|
LocalOverrides.Add(0);
|
|
PaintTypes.Add(PaintType.Painted);
|
|
if (gameobject_mode & Application.isPlaying)
|
|
{
|
|
if (Gameobj_instances.Count < particle_count)
|
|
{
|
|
GameObject gameObject3 = Object.Instantiate(Gameobj, Registered_paint_positions[Registered_paint_positions.Count - 1], Quaternion.identity);
|
|
if (gameObject3.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
gameObject3.GetComponent<Collider>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
gameObject3.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
Gameobj_instances.Add(gameObject3.transform);
|
|
gameObject3.transform.position = Registered_paint_positions[Registered_paint_positions.Count - 1];
|
|
if (Angled)
|
|
{
|
|
gameObject3.transform.localEulerAngles = Registered_paint_rotations[Registered_paint_positions.Count - 1];
|
|
}
|
|
gameObject3.transform.parent = Parent_OBJ.transform;
|
|
Updated_gameobject_positions.Add(gameObject3.transform.position);
|
|
Registered_paint_size.Add(Gameobj_instances[Gameobj_instances.Count - 1].localScale.x);
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (Erase_mode)
|
|
{
|
|
for (int num23 = 0; num23 < Registered_paint_positions.Count; num23++)
|
|
{
|
|
if (Vector3.Distance(hitInfo4.point, Registered_paint_positions[num23]) < 0.5f * brush_size)
|
|
{
|
|
if (gameobject_mode & Application.isPlaying)
|
|
{
|
|
Object.Destroy(Gameobj_instances[num23].gameObject);
|
|
Gameobj_instances.RemoveAt(num23);
|
|
Updated_gameobject_positions.RemoveAt(num23);
|
|
}
|
|
LocalOverrides.RemoveAt(num23);
|
|
PaintTypes.RemoveAt(num23);
|
|
Emitter_objects.RemoveAt(num23);
|
|
Updated_Registered_paint_positions.RemoveAt(num23);
|
|
Particle_color.RemoveAt(num23);
|
|
Registered_paint_rotations.RemoveAt(num23);
|
|
Registered_paint_times.RemoveAt(num23);
|
|
Registered_paint_size.RemoveAt(num23);
|
|
Registered_paint_positions.RemoveAt(num23);
|
|
Registered_initial_positions.RemoveAt(num23);
|
|
Registered_initial_rotation.RemoveAt(num23);
|
|
Registered_initial_scale.RemoveAt(num23);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (Use_stencil & Application.isPlaying & Real_time_painting)
|
|
{
|
|
if (Stencil_divisions.x < 1f)
|
|
{
|
|
Stencil_divisions.x = 1f;
|
|
}
|
|
if (Stencil_divisions.y < 1f)
|
|
{
|
|
Stencil_divisions.y = 1f;
|
|
}
|
|
int num24 = 0;
|
|
for (int num25 = 0; num25 < Stencil.width; num25 += (int)Stencil_divisions.x)
|
|
{
|
|
for (int num26 = 0; num26 < Stencil.height; num26 += (int)Stencil_divisions.y)
|
|
{
|
|
Color pixel = Stencil.GetPixel(num25, num26);
|
|
if (pixel.a > 0.9f)
|
|
{
|
|
Ray ray2 = Camera.main.ScreenPointToRay(Input.mousePosition - new Vector3(tex_scale.x * (float)Stencil.width / 2f, tex_scale.y * (float)Stencil.height / 2f, 0f) + new Vector3(tex_scale.x * (float)num25, tex_scale.y * (float)num26, 0f));
|
|
RaycastHit hitInfo5 = default(RaycastHit);
|
|
if (Physics.Raycast(ray2, out hitInfo5, float.PositiveInfinity) && hitInfo5.collider.gameObject.tag == "PPaint" && Emitter_objects != null)
|
|
{
|
|
if (!Erase_mode)
|
|
{
|
|
if (Emitter_objects.Count <= p11.main.maxParticles / 2 && Input.GetMouseButtonDown(0))
|
|
{
|
|
Emitter_objects.Add(hitInfo5.collider.gameObject.transform);
|
|
Registered_paint_positions.Add(hitInfo5.point);
|
|
Updated_Registered_paint_positions.Add(hitInfo5.point);
|
|
Particle_color.Add(new Vector4(pixel.r, pixel.g, pixel.b, pixel.a));
|
|
Registered_paint_rotations.Add(hitInfo5.normal);
|
|
Registered_paint_times.Add(Time.fixedTime);
|
|
if (!gameobject_mode)
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
Registered_initial_positions.Add(hitInfo5.collider.gameObject.transform.position);
|
|
Registered_initial_scale.Add(hitInfo5.collider.gameObject.transform.localScale);
|
|
Registered_initial_rotation.Add(hitInfo5.collider.gameObject.transform.rotation);
|
|
LocalOverrides.Add(0);
|
|
PaintTypes.Add(PaintType.BrushPainted);
|
|
if (gameobject_mode & Application.isPlaying)
|
|
{
|
|
if (Gameobj_instances.Count < particle_count)
|
|
{
|
|
GameObject gameObject4 = Object.Instantiate(Gameobj, Registered_paint_positions[Registered_paint_positions.Count - 1], Quaternion.identity);
|
|
if (gameObject4.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
gameObject4.GetComponent<Collider>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
gameObject4.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
Gameobj_instances.Add(gameObject4.transform);
|
|
gameObject4.transform.position = Registered_paint_positions[Registered_paint_positions.Count - 1];
|
|
if (Angled)
|
|
{
|
|
gameObject4.transform.localEulerAngles = Registered_paint_rotations[Registered_paint_positions.Count - 1];
|
|
}
|
|
if (Scale_by_texture)
|
|
{
|
|
gameObject4.transform.localScale = new Vector3(600f * pixel.b / 255f, 600f * pixel.b / 255f, 600f * pixel.b / 255f);
|
|
}
|
|
if (Color_by_texture)
|
|
{
|
|
Renderer[] componentsInChildren = gameObject4.GetComponentsInChildren<Renderer>();
|
|
if (!Application.isPlaying)
|
|
{
|
|
componentsInChildren[0].sharedMaterial.color = Color.Lerp(componentsInChildren[0].sharedMaterial.color, pixel, 0.5f);
|
|
componentsInChildren[1].sharedMaterial.color = Color.Lerp(componentsInChildren[0].sharedMaterial.color, pixel, 0.5f);
|
|
}
|
|
else
|
|
{
|
|
componentsInChildren[0].material.color = Color.Lerp(componentsInChildren[0].material.color, pixel, Coloration_ammount);
|
|
componentsInChildren[1].material.color = Color.Lerp(componentsInChildren[0].material.color, pixel, Coloration_ammount);
|
|
}
|
|
}
|
|
gameObject4.transform.parent = Parent_OBJ.transform;
|
|
Updated_gameobject_positions.Add(gameObject4.transform.position);
|
|
Registered_paint_size.Add(Gameobj_instances[Gameobj_instances.Count - 1].localScale.x);
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size.Add(p11.main.startSizeMultiplier + Random_size_factor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (Erase_mode)
|
|
{
|
|
for (int num27 = 0; num27 < Updated_Registered_paint_positions.Count; num27++)
|
|
{
|
|
if (Vector3.Distance(hitInfo5.point, Updated_Registered_paint_positions[num27]) < 0.5f * brush_size)
|
|
{
|
|
if (gameobject_mode & Application.isPlaying)
|
|
{
|
|
Object.Destroy(Gameobj_instances[num27].gameObject);
|
|
Gameobj_instances.RemoveAt(num27);
|
|
Updated_gameobject_positions.RemoveAt(num27);
|
|
}
|
|
LocalOverrides.RemoveAt(num27);
|
|
PaintTypes.RemoveAt(num27);
|
|
Emitter_objects.RemoveAt(num27);
|
|
Updated_Registered_paint_positions.RemoveAt(num27);
|
|
Particle_color.RemoveAt(num27);
|
|
Registered_paint_rotations.RemoveAt(num27);
|
|
Registered_paint_times.RemoveAt(num27);
|
|
Registered_paint_size.RemoveAt(num27);
|
|
Registered_paint_positions.RemoveAt(num27);
|
|
Registered_initial_positions.RemoveAt(num27);
|
|
Registered_initial_rotation.RemoveAt(num27);
|
|
Registered_initial_scale.RemoveAt(num27);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
maxemitter_count = p11.main.maxParticles / 2 + 1;
|
|
if (Emitter_objects != null)
|
|
{
|
|
current_emitters_count = Emitter_objects.Count;
|
|
}
|
|
}
|
|
num24++;
|
|
}
|
|
}
|
|
}
|
|
if (gameobject_mode && (Preview_mode | Application.isPlaying) && Registered_paint_positions != null)
|
|
{
|
|
for (int num28 = 0; num28 < Registered_paint_positions.Count; num28++)
|
|
{
|
|
if (Gameobj_instances.Count >= Registered_paint_positions.Count)
|
|
{
|
|
continue;
|
|
}
|
|
GameObject gameObject5 = Object.Instantiate(Gameobj, Registered_paint_positions[num28], Quaternion.identity);
|
|
if (gameObject5.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
gameObject5.GetComponent<Collider>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
gameObject5.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
Gameobj_instances.Add(gameObject5.transform);
|
|
gameObject5.transform.position = Registered_paint_positions[num28];
|
|
if (Angled)
|
|
{
|
|
gameObject5.transform.localEulerAngles = Registered_paint_rotations[num28];
|
|
}
|
|
gameObject5.transform.parent = Parent_OBJ.transform;
|
|
Updated_gameobject_positions.Add(gameObject5.transform.position);
|
|
}
|
|
}
|
|
ParticleList = new ParticleSystem.Particle[p11.particleCount];
|
|
p11.GetParticles(ParticleList);
|
|
int num29 = 0;
|
|
for (int num30 = 0; num30 < ParticleList.Length; num30++)
|
|
{
|
|
if (!((Registered_paint_positions != null) & (Registered_paint_positions.Count > 0)) || !(Emitter_objects[num29] != null))
|
|
{
|
|
continue;
|
|
}
|
|
if (((Registered_paint_positions != null) & (Registered_paint_positions.Count > 0) & draw_in_sequence) && Emitter_objects[num29].gameObject.activeInHierarchy)
|
|
{
|
|
if ((num29 + 1) * (ParticleList.Length / Registered_paint_positions.Count) <= num30)
|
|
{
|
|
num29 = ((num29 < Registered_paint_positions.Count - 1) ? (num29 + 1) : 0);
|
|
}
|
|
else
|
|
{
|
|
Vector3 vector5 = Registered_paint_positions[num29] - Registered_initial_positions[num29];
|
|
Quaternion quaternion = Quaternion.Euler(Emitter_objects[num29].eulerAngles) * Quaternion.Inverse(Registered_initial_rotation[num29]);
|
|
Vector3 vector6 = quaternion * vector5;
|
|
Vector3 value = new Vector3(vector6.x * (Emitter_objects[num29].localScale.x / Registered_initial_scale[num29].x), vector6.y * (Emitter_objects[num29].localScale.y / Registered_initial_scale[num29].y), vector6.z * (Emitter_objects[num29].localScale.z / Registered_initial_scale[num29].z)) + Emitter_objects[num29].position;
|
|
Vector3 vector7 = Registered_paint_rotations[num29];
|
|
Vector3 vector8 = quaternion * vector7;
|
|
float y = ParticleList[num30].position.y;
|
|
y = Updated_Registered_paint_positions[num29].y;
|
|
if (!relaxed)
|
|
{
|
|
if (Emitter_objects[num29].gameObject.activeInHierarchy)
|
|
{
|
|
ParticleList[num30].position = new Vector3(value.x, y, value.z);
|
|
}
|
|
if (follow_normals)
|
|
{
|
|
ParticleList[num30].rotation = 90f;
|
|
float num31 = 90f;
|
|
Vector3 rhs = vector8;
|
|
if ((rhs.z >= 0f) & (rhs.x >= 0f))
|
|
{
|
|
num31 -= Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs.x, 0f, rhs.z));
|
|
}
|
|
if ((rhs.z < 0f) & (rhs.x >= 0f))
|
|
{
|
|
num31 += Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs.x, 0f, rhs.z));
|
|
}
|
|
if ((rhs.z >= 0f) & (rhs.x < 0f))
|
|
{
|
|
num31 = num31 + Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs.x, 0f, rhs.z)) + 180f;
|
|
}
|
|
if ((rhs.z < 0f) & (rhs.x < 0f))
|
|
{
|
|
num31 = num31 - Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs.x, 0f, rhs.z)) + 180f;
|
|
}
|
|
float num32 = Vector3.Dot(new Vector3(1E-07f, 1E-07f, 1f), rhs);
|
|
float num33 = 0f;
|
|
if (!(num32 > 1f || num32 < -1f))
|
|
{
|
|
num33 = Mathf.Acos(num32);
|
|
}
|
|
ParticleList[num30].rotation = num33 + num31;
|
|
ParticleList[num30].axisOfRotation = Vector3.Cross(new Vector3(1E-08f, 1E-08f, 1f), rhs);
|
|
}
|
|
}
|
|
if (relaxed && Emitter_objects[num29].gameObject.activeInHierarchy && ParticleList[num30].remainingLifetime > keep_in_position_factor * ParticleList[num30].startLifetime)
|
|
{
|
|
ParticleList[num30].position = new Vector3(value.x, y, value.z);
|
|
}
|
|
Updated_Registered_paint_positions[num29] = value;
|
|
}
|
|
}
|
|
if (!((Registered_paint_positions != null) & (Registered_paint_positions.Count > 0) & !draw_in_sequence))
|
|
{
|
|
continue;
|
|
}
|
|
Vector3 vector9 = Registered_paint_positions[num29] - Registered_initial_positions[num29];
|
|
Quaternion quaternion2 = Quaternion.Euler(Emitter_objects[num29].eulerAngles) * Quaternion.Inverse(Registered_initial_rotation[num29]);
|
|
Vector3 vector10 = quaternion2 * vector9;
|
|
Vector3 vector11 = new Vector3(vector10.x * (Emitter_objects[num29].localScale.x / Registered_initial_scale[num29].x), vector10.y * (Emitter_objects[num29].localScale.y / Registered_initial_scale[num29].y), vector10.z * (Emitter_objects[num29].localScale.z / Registered_initial_scale[num29].z)) + Emitter_objects[num29].position;
|
|
Vector3 vector12 = Registered_paint_rotations[num29];
|
|
Vector3 vector13 = quaternion2 * vector12;
|
|
if ((gameobject_mode & (Application.isPlaying | Preview_mode)) && ((num29 < Gameobj_instances.Count) & !follow_particles))
|
|
{
|
|
Gameobj_instances[num29].position = vector11;
|
|
if (!look_at_direction)
|
|
{
|
|
Gameobj_instances[num29].rotation = quaternion2 * Quaternion.FromToRotation(Vector3.up, vector12);
|
|
}
|
|
else
|
|
{
|
|
Vector3 vector14 = vector11 - Updated_Registered_paint_positions[num29];
|
|
Quaternion identity = Quaternion.identity;
|
|
if (vector14 != Vector3.zero)
|
|
{
|
|
identity = Quaternion.LookRotation(1f * vector14);
|
|
Gameobj_instances[num29].rotation = Quaternion.Slerp(Gameobj_instances[num29].rotation, identity, Time.deltaTime * 16f);
|
|
}
|
|
}
|
|
if (Angled)
|
|
{
|
|
float num34 = 0f;
|
|
float num35 = 0f;
|
|
if (enable_overides && LocalOverrides[num29] == 4)
|
|
{
|
|
num34 = overide_WindSpeed;
|
|
num35 = overide_GrassAngle;
|
|
}
|
|
if ((Time.fixedTime - Grab_time_calcs > Delay_calcs) | !Optimize_calcs)
|
|
{
|
|
Grab_time_calcs = Time.fixedTime;
|
|
Quaternion quaternion3 = Quaternion.FromToRotation(Gameobj_instances[num29].up, Gameobj_instances[num29].right);
|
|
if (Asign_rot)
|
|
{
|
|
if ((Wind_speed > 0f) & Application.isPlaying)
|
|
{
|
|
float num36 = Time.time * (Wind_speed + num34) + 1.3651431f * (float)num30;
|
|
Local_rot.y = noise.Noise(num36 + 10f, num36 + 20f, num36) + num35;
|
|
}
|
|
Gameobj_instances[num29].localRotation *= quaternion3 * new Quaternion(Local_rot.x, Local_rot.y, Local_rot.z, 1f);
|
|
}
|
|
}
|
|
}
|
|
if (Grow_trees && Emitter_objects[num29].localScale != Registered_initial_scale[num29] && Time.fixedTime - Current_Grow_time < Grow_time)
|
|
{
|
|
Gameobj_instances[num29].localScale = new Vector3(Gameobj_instances[num29].localScale.x * (Emitter_objects[num29].localScale.x / Registered_initial_scale[num29].x), Gameobj_instances[num29].localScale.y * (Emitter_objects[num29].localScale.y / Registered_initial_scale[num29].y), Gameobj_instances[num29].localScale.z * (Emitter_objects[num29].localScale.z / Registered_initial_scale[num29].z));
|
|
}
|
|
}
|
|
float y2 = ParticleList[num30].position.y;
|
|
y2 = Updated_Registered_paint_positions[num29].y;
|
|
if (!relaxed)
|
|
{
|
|
if (Emitter_objects[num29].gameObject.activeInHierarchy)
|
|
{
|
|
ParticleList[num30].position = new Vector3(vector11.x, y2, vector11.z);
|
|
}
|
|
if (follow_normals)
|
|
{
|
|
ParticleList[num30].rotation = 90f;
|
|
float num37 = 90f;
|
|
Vector3 rhs2 = vector13;
|
|
if ((rhs2.z >= 0f) & (rhs2.x >= 0f))
|
|
{
|
|
num37 = Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs2.x, 0f, rhs2.z));
|
|
}
|
|
if ((rhs2.z == 0f) & (rhs2.x == 0f))
|
|
{
|
|
num37 = 90f;
|
|
}
|
|
if ((rhs2.z < 0f) & (rhs2.x >= 0f))
|
|
{
|
|
num37 += Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs2.x, 0f, rhs2.z));
|
|
}
|
|
if ((rhs2.z >= 0f) & (rhs2.x < 0f))
|
|
{
|
|
num37 = -90f + Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs2.x, 0f, rhs2.z)) + 180f;
|
|
}
|
|
if ((rhs2.z < 0f) & (rhs2.x < 0f))
|
|
{
|
|
num37 = num37 - Vector3.Angle(new Vector3(1f, 0f, 0f), new Vector3(rhs2.x, 0f, rhs2.z)) + 180f;
|
|
}
|
|
float num38 = Vector3.Dot(new Vector3(1E-07f, 1E-07f, 1f), rhs2);
|
|
float num39 = 0f;
|
|
if (!(num38 > 1f || num38 < -1f))
|
|
{
|
|
num39 = Mathf.Acos(num38);
|
|
}
|
|
num37 = 90f - 360f * num38 / 6.28f;
|
|
ParticleList[num30].rotation = num39 + num37;
|
|
ParticleList[num30].rotation = num37;
|
|
if (debug_rot != 0f)
|
|
{
|
|
ParticleList[num30].rotation = debug_rot;
|
|
}
|
|
ParticleList[num30].axisOfRotation = Vector3.Cross(new Vector3(1E-07f, 1E-07f, 1f), rhs2);
|
|
}
|
|
}
|
|
if (relaxed)
|
|
{
|
|
if ((!let_loose & !(enable_overides & ((LocalOverrides[num29] == 2) | (LocalOverrides[num29] == 3)))) && Emitter_objects[num29].gameObject.activeInHierarchy && ParticleList[num30].remainingLifetime > keep_in_position_factor * ParticleList[num30].startLifetime)
|
|
{
|
|
ParticleList[num30].position = new Vector3(vector11.x, y2, vector11.z);
|
|
}
|
|
if (ParticleList[num30].remainingLifetime > ParticleList[num30].startLifetime * keep_in_position_factor && Velocity_toward_normal)
|
|
{
|
|
ParticleList[num30].velocity = 1f * new Vector3(vector13.x * Normal_Velocity.x, vector13.y * Normal_Velocity.y, vector13.z * Normal_Velocity.z);
|
|
}
|
|
if (Gravity_Mode & let_loose)
|
|
{
|
|
float release_Gravity = grav_factor;
|
|
if (enable_overides & ((LocalOverrides[num29] == 2) | (LocalOverrides[num29] == 3)))
|
|
{
|
|
release_Gravity = Release_Gravity;
|
|
}
|
|
if (Registered_paint_positions.Count > num29)
|
|
{
|
|
if (!Use_Lerp)
|
|
{
|
|
ParticleList[num30].position = Vector3.Slerp(ParticleList[num30].position, Registered_paint_positions[num29] + new Vector3((float)num30 * X_offset_factor, Y_offset, (float)num30 * Z_offset_factor), release_Gravity);
|
|
}
|
|
else
|
|
{
|
|
ParticleList[num30].position = Vector3.Lerp(ParticleList[num30].position, Registered_paint_positions[num29] + new Vector3((float)num30 * X_offset_factor, Y_offset, (float)num30 * Z_offset_factor), release_Gravity);
|
|
}
|
|
}
|
|
if (!Use_Lerp)
|
|
{
|
|
ParticleList[num30].velocity = Vector3.Slerp(ParticleList[num30].velocity, Vector3.zero, 0.05f);
|
|
}
|
|
else
|
|
{
|
|
ParticleList[num30].velocity = Vector3.Lerp(ParticleList[num30].velocity, Vector3.zero, 0.05f);
|
|
}
|
|
}
|
|
if ((gameobject_mode & (Application.isPlaying | Preview_mode)) && follow_particles && (((Gameobj_instances.Count > num30) ? 1u : 0u) | 1u) != 0)
|
|
{
|
|
Gameobj_instances[num29].position = ParticleList[num30].position;
|
|
Vector3 vector15 = Gameobj_instances[num29].position - Updated_gameobject_positions[num29];
|
|
Quaternion identity2 = Quaternion.identity;
|
|
if ((vector15.magnitude > 0.1f) & (vector15.magnitude < 99999f))
|
|
{
|
|
identity2 = Quaternion.LookRotation(1f * vector15);
|
|
if (!Use_Lerp)
|
|
{
|
|
Gameobj_instances[num29].rotation = Quaternion.Slerp(Gameobj_instances[num29].rotation, identity2, Time.deltaTime * 16f);
|
|
}
|
|
else
|
|
{
|
|
Gameobj_instances[num29].rotation = Quaternion.Lerp(Gameobj_instances[num29].rotation, identity2, Time.deltaTime * 16f);
|
|
}
|
|
}
|
|
if (Gameobj_instances[num29].gameObject.GetComponent<Collider>() != null)
|
|
{
|
|
if (Remove_colliders)
|
|
{
|
|
if (Gameobj_instances[num29].gameObject.GetComponent<Collider>().enabled)
|
|
{
|
|
Gameobj_instances[num29].gameObject.GetComponent<Collider>().enabled = false;
|
|
}
|
|
}
|
|
else if (!Remove_colliders && !Gameobj_instances[num29].gameObject.GetComponent<Collider>().enabled)
|
|
{
|
|
Gameobj_instances[num29].gameObject.GetComponent<Collider>().enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (keep_alive & !(enable_overides & ((LocalOverrides[num29] == 1) | (LocalOverrides[num29] == 3))) & let_loose)
|
|
{
|
|
ParticleList[num30].startLifetime = 16f;
|
|
ParticleList[num30].remainingLifetime = 15f;
|
|
}
|
|
if (Color_effects && Particle_color[num29].w < 257f)
|
|
{
|
|
if (Keep_color)
|
|
{
|
|
ParticleList[num30].startColor = new Color(Particle_color[num29].x, Particle_color[num29].y, Particle_color[num29].z, Particle_color[num29].w);
|
|
}
|
|
else if (ParticleList[num30].remainingLifetime > keep_in_position_factor * ParticleList[num30].startLifetime)
|
|
{
|
|
if (Lerp_color)
|
|
{
|
|
ParticleList[num30].startColor = Color.Lerp(ParticleList[num30].startColor, new Color(Particle_color[num29].x, Particle_color[num29].y, Particle_color[num29].z, Particle_color[num29].w), 0.5f);
|
|
}
|
|
else
|
|
{
|
|
ParticleList[num30].startColor = new Color(Particle_color[num29].x, Particle_color[num29].y, Particle_color[num29].z, Particle_color[num29].w);
|
|
}
|
|
}
|
|
}
|
|
if (variant_size)
|
|
{
|
|
if (gameobject_mode & Vary_gameobj_size)
|
|
{
|
|
Gameobj_instances[num29].localScale = new Vector3(1f, 1f, 1f) * Registered_paint_size[num29];
|
|
}
|
|
else
|
|
{
|
|
ParticleList[num30].startSize = Registered_paint_size[num29];
|
|
}
|
|
ParticleList[num30].startLifetime = 16f;
|
|
if (ParticleList[num30].remainingLifetime < keep_alive_factor * ParticleList[num30].startLifetime)
|
|
{
|
|
ParticleList[num30].remainingLifetime = 15f;
|
|
}
|
|
if (!is_ice)
|
|
{
|
|
ParticleList[num30].startSize = Registered_paint_size[num29];
|
|
}
|
|
else if ((!keep_alive & is_ice) | (enable_overides & (LocalOverrides[num29] == 1)))
|
|
{
|
|
if ((gameobject_mode & Vary_gameobj_size) && ((Gameobj_instances[num29].localScale.x > 0.001f) | (Gameobj_instances[num29].localScale.y > 0.001f) | (Gameobj_instances[num29].localScale.z > 0.001f)))
|
|
{
|
|
if (Gameobj_instances[num29].localScale.x > 0f)
|
|
{
|
|
if (enable_overides & (LocalOverrides[num29] == 1))
|
|
{
|
|
Gameobj_instances[num29].localScale = new Vector3(Registered_paint_size[num29] - fast_melt_speed, Registered_paint_size[num29] - fast_melt_speed, Registered_paint_size[num29] - fast_melt_speed);
|
|
}
|
|
else
|
|
{
|
|
Gameobj_instances[num29].localScale = new Vector3(Registered_paint_size[num29] - melt_speed, Registered_paint_size[num29] - melt_speed, Registered_paint_size[num29] - melt_speed);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Gameobj_instances[num29].localScale = new Vector3(0.001f, 0.001f, 0.001f);
|
|
}
|
|
}
|
|
if (ParticleList[num30].startSize > 0f)
|
|
{
|
|
if (enable_overides & (LocalOverrides[num29] == 1))
|
|
{
|
|
ParticleList[num30].startSize = Registered_paint_size[num29] - fast_melt_speed;
|
|
}
|
|
else
|
|
{
|
|
ParticleList[num30].startSize = Registered_paint_size[num29] - melt_speed;
|
|
}
|
|
}
|
|
if (gameobject_mode & Vary_gameobj_size)
|
|
{
|
|
if (Parent_OBJ != null && enable_combine && Mathf.Abs(Gameobj_instances[num29].localScale.x - Registered_paint_size[num29]) > 0f)
|
|
{
|
|
Combiner.MakeActive = true;
|
|
}
|
|
if (Gameobj_instances[num29].localScale.x > 0f)
|
|
{
|
|
Registered_paint_size[num29] = Gameobj_instances[num29].localScale.x;
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size[num29] = 0.001f;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Registered_paint_size[num29] = ParticleList[num30].startSize;
|
|
}
|
|
}
|
|
}
|
|
if (Parent_OBJ != null && enable_combine && (Updated_Registered_paint_positions[num29] - vector11).magnitude > 0f)
|
|
{
|
|
Combiner.MakeActive = true;
|
|
}
|
|
Updated_Registered_paint_positions[num29] = vector11;
|
|
num29++;
|
|
if (num29 > Registered_paint_positions.Count - 1)
|
|
{
|
|
num29 = 0;
|
|
}
|
|
}
|
|
p11.SetParticles(ParticleList, p11.particleCount);
|
|
}
|
|
}
|
|
}
|