void TriggerSystem::Update(double pDeltaTime) { if (mCreateNextLevel) { mCurrentLevel++; //if we have enough maps if (mMapNames.size() - 1 >= mCurrentLevel) { LevelManager::GetInstance()->GenerateWorld(mMapNames[mCurrentLevel]); } mCreateNextLevel = false; } EntityManager* tEntMan = tEntMan->GetInstance(); ComponentTable* tCompTable = tCompTable->GetInstance(); int tMaxEnt = tEntMan->GetLastEntity(); mNumOfBallsActive = 0; mNumOfGoalBlocksActive = 0; //check how many balls we have active and goals cause why not for (int i = 0; i < tMaxEnt; i++) { if (tCompTable->HasComponent(i, LabelType)) { Label tLabel = GetComponent<LabelComponent>(i)->mLabel; if (tLabel == Label::Ball) { mNumOfBallsActive++; } else if (tLabel == Label::GoalBlock) { mNumOfGoalBlocksActive++; } } } //if no goal blocks, we go to next map, even if we can do this by event, we might explode or something that doesn't trigger, not sure how we want it if (mNumOfGoalBlocksActive == 0 && mNumOfBallsActive != 0) { //DEBUG #ifdef _DEBUG cout << "WARNING - MAP HAS NO GOAL LEFT, EITHER WRONG IN MAP OR SOME REALLY WIERD BUG" << endl; #endif //END DEBUG } }
void InputSystem::Update(double pDeltaTime) { mKeyState = SDL_GetKeyboardState(NULL); CheckKeyboard(); //HandleInput(); EntityManager* tEntManager = tEntManager->GetInstance(); ComponentTable* tCompTable = tCompTable->GetInstance(); int tMaxEnt = tEntManager->GetLastEntity(); for (int i = 0; i < tMaxEnt; i++) { if (tCompTable->HasComponent(i, ComponentType::LabelType)) { LabelComponent* tLabel = GetComponent<LabelComponent>(i); if (tLabel->mLabel == Label::Pad) { //find input we want to check for TODO:: maybe fix input into bit array? HandleInput(i); } } } //cout << "running input system"; //EventManager::Payload tPayload; //tPayload["test"] = MessageInt(5); // void* tDebugData = malloc(4); //void* tDebugData2 = malloc(4); //*(int*)tDebugData = 4; //*(int*)tDebugData2 = 5; ////memcpy(tDebugData, &data, 4); ////memcpy(tDebugData2, &data2, 4); //tPayload["Debugdata"] = tDebugData; //tPayload["Test"] = tDebugData2; //cout << "Sending event"; //mEventManager->BroadcastEvent("DebugTest", tPayload); //cout << "event sent, resuming input system update"; }
EntityID EntityFactory::CreateEntity(std::string pTemplateName) { EntityBlueprint tComponentMap = mEntityBlueprints[pTemplateName]; EntityManager* tEntityManager = tEntityManager->GetInstance(); ComponentTable* tComponentTable = tComponentTable->GetInstance(); //create a new ID EntityID tNewEntityID = tEntityManager->AddEntity(); //copy components for (EntityBlueprint::iterator iter = tComponentMap.begin(); iter != tComponentMap.end(); ++iter) { tComponentTable->AddComponent(tNewEntityID, iter->first); if (iter->first == ComponentType::PhysicType) { memcpy(GetComponent<PhysicComponent>(tNewEntityID), iter->second, sizeof(PhysicComponent)); } else if (iter->first == ComponentType::TransformType) { memcpy(GetComponent<TransformComponent>(tNewEntityID), iter->second, sizeof(TransformComponent)); } else if (iter->first == ComponentType::MeshType) { memcpy(GetComponent<MeshComponent>(tNewEntityID), iter->second, sizeof(MeshComponent)); } else if (iter->first == ComponentType::LabelType) { memcpy(GetComponent<LabelComponent>(tNewEntityID), iter->second, sizeof(LabelComponent)); } else if (iter->first == ComponentType::VelocityType) { memcpy(GetComponent<VelocityComponent>(tNewEntityID), iter->second, sizeof(VelocityComponent)); } else if (iter->first == ComponentType::CollisionType) { memcpy(GetComponent<CollisionComponent>(tNewEntityID), iter->second, sizeof(CollisionComponent)); } else if (iter->first == ComponentType::VelocityForceType) { memcpy(GetComponent<VelocityForceComponent>(tNewEntityID), iter->second, sizeof(VelocityForceComponent)); } else if (iter->first == ComponentType::SoundCollisionType) { memcpy(GetComponent<SoundCollisionComponent>(tNewEntityID), iter->second, sizeof(SoundCollisionComponent)); } else if (iter->first == ComponentType::AttachedType) { memcpy(GetComponent<AttachedComponent>(tNewEntityID), iter->second, sizeof(AttachedComponent)); } else if (iter->first == ComponentType::ScoreValueType) { memcpy(GetComponent<ScoreValueComponent>(tNewEntityID), iter->second, sizeof(ScoreValueComponent)); } else if (iter->first == ComponentType::MenyButtonType) { memcpy(GetComponent<MenyButtonComponent>(tNewEntityID), iter->second, sizeof(MenyButtonComponent)); } else if (iter->first == ComponentType::PowerUpType) { memcpy(GetComponent<PowerUpComponent>(tNewEntityID), iter->second, sizeof(PowerUpComponent)); } else if (iter->first == ComponentType::PowerUpContainType) { memcpy(GetComponent<PowerUpContainComponenet>(tNewEntityID), iter->second, sizeof(PowerUpContainComponenet)); } else if (iter->first == ComponentType::EmitterType) { memcpy(GetComponent<EmitterComponent>(tNewEntityID), iter->second, sizeof(EmitterComponent)); } } return tNewEntityID; }