Added ParticleSystem skeleton plus basic temporary implementation.
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ void GameWorld::AddSystems()
|
||||
//AddSystem("LevelGenerationSystem");
|
||||
AddSystem("InputSystem");
|
||||
//AddSystem("CollisionSystem");
|
||||
////AddSystem("ParticleSystem");
|
||||
//AddSystem("ParticleSystem");
|
||||
//AddSystem("PlayerSystem");
|
||||
AddSystem("FreeSteeringSystem");
|
||||
AddSystem("SoundSystem");
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "ParticleSystem.h"
|
||||
#include "PrecompiledHeader.h"
|
||||
|
||||
#include "World.h"
|
||||
void Systems::ParticleSystem::Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
|
||||
if(!transformComponent)
|
||||
return;
|
||||
|
||||
transformComponent->Position.y --;
|
||||
|
||||
timeLived[entity] += dt;
|
||||
|
||||
auto emitterComponent = m_World->GetComponent<Components::ParticleEmitter>(entity, "ParticleEmitter");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::RegisterComponents(ComponentFactory* cf)
|
||||
{
|
||||
cf->Register("ParticleEmitter", []() { return new Components::ParticleEmitter(); });
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::SpawnParticles()
|
||||
{
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
auto particle = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(particle, "Transform");
|
||||
transform->Position = glm::vec3(0);
|
||||
particles.push_back(particle);
|
||||
}
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::Draw(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef ParticleSystem_h__
|
||||
#define ParticleSystem_h__
|
||||
|
||||
#include "System.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/ParticleEmitter.h"
|
||||
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
|
||||
class ParticleSystem : public System
|
||||
{
|
||||
public:
|
||||
ParticleSystem(World* world);
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
private:
|
||||
void SpawnParticles();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // ParticleSystem_h__
|
||||
Reference in New Issue
Block a user