Changed System to take World through constructor and store it instead, cause it makes more sense.
This commit is contained in:
+2
-2
@@ -71,7 +71,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_OctreeCollision = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
m_OctreeFrustrumCulling = new Octree(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
// Create system pipeline
|
||||
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
||||
m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker);
|
||||
|
||||
// All systems with orderlevel 0 will be updated first.
|
||||
unsigned int updateOrderLevel = 0;
|
||||
@@ -143,7 +143,7 @@ void Game::Tick()
|
||||
m_ClientOrServer->Update();
|
||||
}
|
||||
// Iterate through systems and update world!
|
||||
m_SystemPipeline->Update(m_World, dt);
|
||||
m_SystemPipeline->Update(dt);
|
||||
debugTick(dt);
|
||||
m_Renderer->Update(dt);
|
||||
m_EventBroker->Process<Client>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Systems/HealthSystem.h"
|
||||
|
||||
HealthSystem::HealthSystem(EventBroker* eventBroker)
|
||||
: System(eventBroker)
|
||||
HealthSystem::HealthSystem(World* m_World, EventBroker* eventBroker)
|
||||
: System(m_World, eventBroker)
|
||||
, PureSystem("Health")
|
||||
{
|
||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||
@@ -9,10 +9,10 @@ HealthSystem::HealthSystem(EventBroker* eventBroker)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &HealthSystem::OnPlayerHealthPickup);
|
||||
}
|
||||
|
||||
void HealthSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
//if entityID of health is 9 then the players ID is also 9 (player,health are connected to the same entity)
|
||||
ComponentWrapper player = world->GetComponent(component.EntityID, "Player");
|
||||
ComponentWrapper player = m_World->GetComponent(component.EntityID, "Player");
|
||||
double maxHealth = (double)component["MaxHealth"];
|
||||
|
||||
//process the DeltaHealthVector and change the entitys health accordingly
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Systems/PlayerMovementSystem.h"
|
||||
|
||||
void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
void PlayerMovementSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
ComponentWrapper& cTransform = entity["Transform"];
|
||||
if (!entity.HasComponent("Physics")) {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include "Systems/PlayerSpawnSystem.h"
|
||||
|
||||
PlayerSpawnSystem::PlayerSpawnSystem(EventBroker* eventBroker)
|
||||
: System(eventBroker)
|
||||
PlayerSpawnSystem::PlayerSpawnSystem(World* m_World, EventBroker* eventBroker)
|
||||
: System(m_World, eventBroker)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand);
|
||||
}
|
||||
|
||||
void PlayerSpawnSystem::Update(World* world, double dt)
|
||||
void PlayerSpawnSystem::Update(double dt)
|
||||
{
|
||||
auto playerSpawns = world->GetComponents("PlayerSpawn");
|
||||
auto playerSpawns = m_World->GetComponents("PlayerSpawn");
|
||||
if (playerSpawns == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& team : m_SpawnRequests) {
|
||||
for (auto& cPlayerSpawn : *playerSpawns) {
|
||||
EntityWrapper spawner(world, cPlayerSpawn.EntityID);
|
||||
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
|
||||
if (!spawner.HasComponent("Spawner")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Systems/PlayerSystem.h"
|
||||
|
||||
void PlayerSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
void PlayerSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
component["Velocity"] = glm::vec3(0.f, 0.f, 0.f);
|
||||
if ((bool&)component["Forward"] == true) {
|
||||
@@ -18,7 +18,7 @@ void PlayerSystem::UpdateComponent(World* world, EntityWrapper& entity, Componen
|
||||
}
|
||||
|
||||
if ((glm::vec3)component["Velocity"] != glm::vec3(0.f)) {
|
||||
ComponentWrapper& transform = world->GetComponent(component.EntityID, "Transform");
|
||||
ComponentWrapper& transform = m_World->GetComponent(component.EntityID, "Transform");
|
||||
(glm::vec3&)transform["Position"] += (glm::vec3)component["Velocity"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Systems/SpawnerSystem.h"
|
||||
|
||||
SpawnerSystem::SpawnerSystem(EventBroker* eventBroker) : System(eventBroker)
|
||||
SpawnerSystem::SpawnerSystem(World* world, EventBroker* eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_OnSpawnerSpawn, &SpawnerSystem::OnSpawnerSpawn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user