void WorldState::beforeLoad(ska::State* lastState) { m_firstState = lastState == nullptr; auto cameraSystem = std::make_unique<ska::CameraSystem>(m_entityManager, m_eventDispatcher, std::make_unique<ska::CameraFollowStrategy>(m_entityManager), m_screenSize.x, m_screenSize.y); m_cameraSystem = cameraSystem.get(); addLogic(std::move(cameraSystem)); auto graphicSystem = std::make_unique<ska::GraphicSystem>(m_entityManager, m_eventDispatcher, *m_cameraSystem); m_graphicSystem = graphicSystem.get(); addGraphic(std::move(graphicSystem)); auto shadowSystem = std::make_unique<ska::ShadowSystem>(m_entityManager, *m_cameraSystem); m_shadowSystem = shadowSystem.get(); addGraphic(std::move(shadowSystem)); auto spaceSystem = std::make_unique<ska::cp::SpaceSystem>(m_entityManager); m_spaceSystem = spaceSystem.get(); addLogic(std::move(spaceSystem)); addLogic(std::make_unique<ska::cp::MovementSystem>(m_entityManager, m_spaceSystem->getSpace())); addLogic(std::make_unique<ska::InputSystem>(m_entityManager, m_eventDispatcher)); addLogic(std::make_unique<ska::DeleterSystem>(m_entityManager)); addLogic(std::make_unique<ska::ZGravityForceSystem>(m_entityManager, 0.90F)); auto animSystemPtr = std::make_unique<PokemonAnimationSystem>(m_entityManager); auto& animSystem = *animSystemPtr.get(); addLogic(std::move(animSystemPtr)); m_walkASM = &animSystem.setup(true, std::make_unique<ska::WalkAnimationStateMachine>(m_entityManager)); animSystem.setup<ska::JumpAnimationStateMachine>(false, std::make_unique<ska::JumpAnimationStateMachine>(m_entityManager)); animSystem.link<ska::WalkAnimationStateMachine, ska::JumpAnimationStateMachine>([&](const ska::EntityId& e) { const auto& pc = m_entityManager.getComponent<ska::PositionComponent>(e); return pc.z > 1; }); animSystem.link<ska::JumpAnimationStateMachine, ska::WalkAnimationStateMachine>([&](const ska::EntityId& e) { const auto& pc = m_entityManager.getComponent<ska::PositionComponent>(e); return pc.z <= 1; }); SettingsChangeEvent sce(SettingsChangeEventType::ALL, m_settings); m_eventDispatcher.ska::Observable<SettingsChangeEvent>::notifyObservers(sce); m_collisionEventSender = std::make_unique<ska::cp::SpaceCollisionEventSender>(m_entityManager, m_spaceSystem->getSpace(), m_eventDispatcher, m_tileset->getTileSize()); }
CharacterGraphic::CharacterGraphic(Character* c) : c_(c), bodyFixture_(&c->body_), headFixture_(&c->head_), footBackFixture_(&c->footBack_), footFrontFixture_(&c->footFront_), handBackFixture_(&c->handBack_), handFrontFixture_(&c->handFront_), bodyColor_(COL_BODY), body_(0.2, 16), head_(0.15, 16), footBack_(0.05, 8), footFront_(0.05, 8), handBack_(0.075, 8), handFront_(0.075, 8) { body_.addModifier(&bodyFixture_); body_.getDisk()->addModifier(&bodyColor_); head_.addModifier(&headFixture_); head_.getDisk()->addModifier(&bodyColor_); footBack_.addModifier(&footBackFixture_); footBack_.getDisk()->addModifier(&bodyColor_); footFront_.addModifier(&footFrontFixture_); footFront_.getDisk()->addModifier(&bodyColor_); handBack_.addModifier(&handBackFixture_); handBack_.getDisk()->addModifier(&bodyColor_); handFront_.addModifier(&handFrontFixture_); handFront_.getDisk()->addModifier(&bodyColor_); addGraphic(&handBack_); addGraphic(&footBack_); addGraphic(&body_); addGraphic(&head_); addGraphic(&footFront_); addGraphic(&handFront_); }
void SubmenuGraphic::addButton(GuiElement* logic, Label* label, bool selected) { // Create a ButtonGraphic buttonGraphics_.push_back(new ButtonGraphic(label->getWidth(), label->getHeight(), logic, label, selected)); // Create a PositionModifier positionModifiers_.push_back(new PositionModifier( buttonGraphics_.back()->getLogic()->getPosition(), submenu_->buttons.size())); // Add the ButtonGraphic to graphics_ addGraphic(buttonGraphics_.back()); // Pair up the ButtonGraphic with the PositionModifier buttonGraphics_.back()->addModifier(positionModifiers_.back()); }
TestDisk::TestDisk(GLfloat r, int n) : disk_(r, n), square_(r, 4) { addGraphic(&disk_); addGraphic(&square_); }