void hitTech(AI* ai) { addLogic(ai, &getOffGroundLogic); addLogic(ai, &resetOnHitLogic); addLogic(&cpuPlayer, &recoveryLogic); addLogic(&cpuPlayer, &onLedgeLogic); if (chance(HIT_TECH_PROB)) { SET_TECH_DIR(getRandomTechDirection()); addMove(ai, &_mv_tech); addLogic(ai, &actAfterTechLogic); } }
MSTrafficLightLogic* MSTLLogicControl::TLSLogicVariants::getLogicInstantiatingOff(MSTLLogicControl& tlc, const std::string& programID) { if (myVariants.find(programID) == myVariants.end()) { if (programID == "off") { // build an off-tll if this switch indicates it if (!addLogic("off", new MSOffTrafficLightLogic(tlc, myCurrentProgram->getID()), true, true)) { // inform the user if this fails throw ProcessError("Could not build an off-state for tls '" + myCurrentProgram->getID() + "'."); } } else { // inform the user about a missing logic throw ProcessError("Can not switch tls '" + myCurrentProgram->getID() + "' to program '" + programID + "';\n The program is not known."); } } return getLogic(programID); }
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()); }
void MSTLLogicControl::TLSLogicVariants::setStateInstantiatingOnline(MSTLLogicControl& tlc, const std::string& state) { // build only once... MSTrafficLightLogic* logic = getLogic("online"); if (logic == nullptr) { MSPhaseDefinition* phase = new MSPhaseDefinition(DELTA_T, state, -1); std::vector<MSPhaseDefinition*> phases; phases.push_back(phase); logic = new MSSimpleTrafficLightLogic(tlc, myCurrentProgram->getID(), "online", TLTYPE_STATIC, phases, 0, MSNet::getInstance()->getCurrentTimeStep() + DELTA_T, std::map<std::string, std::string>()); addLogic("online", logic, true, true); MSNet::getInstance()->createTLWrapper(logic); } else { MSPhaseDefinition nphase(DELTA_T, state, -1); *(dynamic_cast<MSSimpleTrafficLightLogic*>(logic)->getPhases()[0]) = nphase; switchTo(tlc, "online"); } }