예제 #1
0
void Garage::doOnStartClosingEvent() {
    auto player = engine->getPlayer();
    auto plyChar = player->getCharacter();
    auto playerPosition = plyChar->getPosition();
    auto playerVehicle = plyChar->getCurrentVehicle();
    bool playerIsInVehicle = playerVehicle != nullptr;
    RW_UNUSED(playerPosition);
    RW_UNUSED(playerIsInVehicle);

    switch (type) {
        case Type::Mission:
        case Type::CollectCars1:
        case Type::CollectCars2: {
            player->setInputEnabled(false);
            break;
        }

        case Type::BombShop1:
        case Type::BombShop2:
        case Type::BombShop3:
        case Type::Respray: {
            player->setInputEnabled(false);
            playerVehicle->setHandbraking(true);
            break;
        }

        case Type::MissionForCarToComeOut: {
            break;
        }

        case Type::Crusher: {
            break;
        }

        case Type::MissionKeepCar: {
            break;
        }

        case Type::MissionToOpenAndClose: {
            break;
        }

        case Type::MissionForSpecificCar: {
            break;
        }

        case Type::MissionKeepCarAndRemainClosed: {
            break;
        }

        default: { break; }
    }
}
예제 #2
0
bool Activities::ExitVehicle::update(CharacterObject *character,
                                     CharacterController *controller) {
    RW_UNUSED(controller);

    if (jacked) {
        const auto jacked_lhs = AnimCycle::CarJackedLHS;
        const auto jacked_rhs = AnimCycle::CarJackedRHS;
        const auto cycle_current = character->getCurrentCycle();

        if (cycle_current == jacked_lhs || cycle_current == jacked_rhs) {
            if (character->animator->isCompleted(AnimIndexAction)) {
                return true;
            }
        } else {
            if (character->getCurrentVehicle() == nullptr) return true;

            auto vehicle = character->getCurrentVehicle();
            auto seat = character->getCurrentSeat();
            auto door = vehicle->getSeatEntryDoor(seat);
            RW_UNUSED(door);
            auto exitPos = vehicle->getSeatEntryPositionWorld(seat);
            auto exitPosLocal = vehicle->getSeatEntryPosition(seat);

            character->rotation = vehicle->getRotation();

            // Exit the vehicle immediatley
            character->enterVehicle(nullptr, seat);
            character->setPosition(exitPos);

            if (exitPosLocal.x > 0.f) {
                character->playCycle(jacked_rhs);
            } else {
                character->playCycle(jacked_lhs);
            }
            // No need to open the door, it should already be open.
        }
        return false;
    }

    if (character->getCurrentVehicle() == nullptr) return true;

    auto vehicle = character->getCurrentVehicle();
    auto seat = character->getCurrentSeat();
    auto door = vehicle->getSeatEntryDoor(seat);
    auto exitPos = vehicle->getSeatEntryPositionWorld(seat);
    auto exitPosLocal = vehicle->getSeatEntryPosition(seat);

    auto cycle_exit = AnimCycle::CarGetOutLHS;

    if (exitPosLocal.x > 0.f) {
        cycle_exit = AnimCycle::CarGetOutRHS;
    }

    if (vehicle->getVehicle()->vehicletype_ == VehicleModelInfo::BOAT) {
        auto ppos = character->getPosition();
        character->enterVehicle(nullptr, seat);
        character->setPosition(ppos);
        return true;
    }

    bool isDriver = vehicle->isOccupantDriver(character->getCurrentSeat());

    // If the vehicle is going too fast, slow down
    if (isDriver) {
        if (!vehicle->canOccupantExit()) {
            vehicle->setBraking(1.f);
            return false;
        }
    }

    if (character->getCurrentCycle() == cycle_exit) {
        if (character->animator->isCompleted(AnimIndexAction)) {
            character->enterVehicle(nullptr, seat);
            character->setPosition(exitPos);

            if (isDriver) {
                // Apply the handbrake
                vehicle->setHandbraking(true);
                vehicle->setThrottle(0.f);
            }

            return true;
        }
    } else {
        character->playCycle(cycle_exit);
        if (door) {
            vehicle->setPartTarget(door, true, door->openAngle);
        }
    }

    return false;
}