<commit_before>﻿#include "ParticleEmitter.h"
#include <GL/glew.h>
#include "Globals.h"
#include "IMGUI/imgui.h"
#include "Engine.h"
#include "ModuleEditor.h"
#include "CameraComponent.h"
#include "ModuleEditorCamera.h"

ParticleEmitter::ParticleEmitter(int MaxParticles, float2 EmitArea, float FallHeight, float FallSpeed, float LifeTime)
{
	Name = "Particle System";

	this->MaxParticles = MaxParticles;
	this->EmitArea = EmitArea;
	this->FallHeight = FallHeight;
	this->FallSpeed = FallSpeed;
	this->LifeTime = LifeTime;

	_controlMaxParticles = MaxParticles;
	_controlEmitArea = EmitArea;
	_controlFallHeight = FallHeight;
	_controlFallSpeed = FallSpeed;
	_controlLifeTime = LifeTime;

}

ParticleEmitter::~ParticleEmitter()
{
}

void ParticleEmitter::Update(float dt)
{
	checkValues();

	generateParticles();

	for (Particle* particle : ParticlePool)
	{
		if (particle->IsAlive)
		{
			drawParticle(particle);

			// Update particle position & time;
			particle->Position = particle->Position + particle->Velocity * dt;
			particle->LifeTime -= dt;

			// When lifetime finish, kill particle
			if (particle->LifeTime < dt)
			{
				particle->IsAlive = false;
			}
		}
	}
}

void ParticleEmitter::EditorUpdate(float dt)
{
	if (_editorSimulation && !App->editor->IsPlaying())
		Update(dt);
}

void ParticleEmitter::DrawUI()
{
	ImGui::Checkbox("Simulate On Editor", &_editorSimulation);

	ImGui::SameLine();
<commit_msg>Clean Up Update method<commit_after>﻿#include "ParticleEmitter.h"
#include <GL/glew.h>
#include "Globals.h"
#include "IMGUI/imgui.h"
#include "Engine.h"
#include "ModuleEditor.h"
#include "CameraComponent.h"
#include "ModuleEditorCamera.h"

ParticleEmitter::ParticleEmitter(int MaxParticles, float2 EmitArea, float FallHeight, float FallSpeed, float LifeTime)
{
	Name = "Particle System";

	this->MaxParticles = MaxParticles;
	this->EmitArea = EmitArea;
	this->FallHeight = FallHeight;
	this->FallSpeed = FallSpeed;
	this->LifeTime = LifeTime;

	_controlMaxParticles = MaxParticles;
	_controlEmitArea = EmitArea;
	_controlFallHeight = FallHeight;
	_controlFallSpeed = FallSpeed;
	_controlLifeTime = LifeTime;

}

ParticleEmitter::~ParticleEmitter()
{
}

void ParticleEmitter::Update(float dt)
{
	if (_editorSimulation || App->editor->IsPlaying())
	{
		checkValues();

		generateParticles();

		for (Particle* particle : ParticlePool)
		{
			if (particle->IsAlive)
			{
				drawParticle(particle);

				// Update particle position & time;
				particle->Position = particle->Position + particle->Velocity * dt;
				particle->LifeTime -= dt;

				// When lifetime finish, kill particle
				if (particle->LifeTime < dt)
				{
					particle->IsAlive = false;
				}
			}
		}
	}
	else
		restart();
}

void ParticleEmitter::EditorUpdate(float dt)
{
	Update(dt);
}

void ParticleEmitter::DrawUI()
{
	ImGui::Checkbox("Simulate On Editor", &_editorSimulation);

	ImGui::SameLine();

{'fraction_non_alphanumeric': 0.13135153819564466, 'fraction_numerical': 0.000691323885240235, 'mean_word_length': 4.918200408997955, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177606', 'n_tokens_mistral': 1056, 'n_tokens_neox': 986, 'n_words': 197}