Ejemplo n.º 1
0
void updateDoors(void)
{
	int i;
	for(i=0;i<NUMDOORS;i++)
	{
		if(door[i].used)updateDoor(&door[i]);
	}
}
Ejemplo n.º 2
0
void Parallaction::runZone(ZonePtr z) {
	debugC(3, kDebugExec, "runZone (%s)", z->_name);

	uint16 actionType = ACTIONTYPE(z);

	debugC(3, kDebugExec, "actionType = %x, itemType = %x", actionType, ITEMTYPE(z));
	switch (actionType) {

	case kZoneExamine:
		enterCommentMode(z);
		return;

	case kZoneGet:
		pickupItem(z);
		break;

	case kZoneDoor:
		if (z->_flags & kFlagsLocked) break;
		updateDoor(z, !(z->_flags & kFlagsClosed));
		break;

	case kZoneHear:
		if (z->u._hearChannel == MUSIC_HEAR_CHANNEL) {
			_soundMan->execute(SC_SETMUSICFILE, z->u._filename.c_str());
			_soundMan->execute(SC_PLAYMUSIC);
		} else {
			_soundMan->execute(SC_SETSFXCHANNEL, z->u._hearChannel);
			_soundMan->execute(SC_SETSFXLOOPING, (int)((z->_flags & kFlagsLooping) == kFlagsLooping));
			_soundMan->execute(SC_SETSFXVOLUME, 60);
			_soundMan->execute(SC_PLAYSFX, z->u._filename.c_str());
		}
		break;

	case kZoneSpeak:
		if (z->u._speakDialogue) {
			enterDialogueMode(z);
			return;
		}
		break;
	}

	debugC(3, kDebugExec, "runZone completed");

	_cmdExec->run(z->_commands, z);

	return;
}
Ejemplo n.º 3
0
void Garage::tick(float dt) {
    if (!doorObject) {
        return;
    }
    if (!active) {
        return;
    }

    needsToUpdate = false;

    switch (state) {
        case State::Opened: {
            if (shouldClose()) {
                state = State::Closing;
                doOnStartClosingEvent();
            }

            break;
        }

        case State::Closed: {
            if (shouldOpen()) {
                state = State::Opening;
                doOnStartOpeningEvent();
            }

            break;
        }

        case State::Opening: {
            if (shouldStopOpening()) {
                state = State::Closing;
            } else {
                fraction += dt * step;

                if (fraction >= 1.0f) {
                    state = State::Opened;
                    fraction = 1.f;
                    doOnOpenEvent();
                }

                needsToUpdate = true;
            }

            break;
        }

        case State::Closing: {
            if (shouldStopClosing()) {
                state = State::Opening;
            } else {
                fraction -= dt * step;

                if (fraction <= 0.f) {
                    state = State::Closed;
                    fraction = 0.f;
                    doOnCloseEvent();
                }

                needsToUpdate = true;
            }

            break;
        }

        default: { break; }
    }

    if (needsToUpdate) {
        updateDoor();
    }
}
Ejemplo n.º 4
0
Garage::Garage(GameWorld* engine_, size_t id_, const glm::vec3& coord0,
               const glm::vec3& coord1, Type type_)
    : engine(engine_), id(id_), type(type_) {
    min.x = std::min(coord0.x, coord1.x);
    min.y = std::min(coord0.y, coord1.y);
    min.z = std::min(coord0.z, coord1.z);

    max.x = std::max(coord0.x, coord1.x);
    max.y = std::max(coord0.y, coord1.y);
    max.z = std::max(coord0.z, coord1.z);

    glm::vec2 midpoint;
    midpoint.x = (min.x + max.x) / 2;
    midpoint.y = (min.y + max.y) / 2;

    // Find door objects for this garage
    for (const auto& p : engine->instancePool.objects) {
        const auto inst = static_cast<InstanceObject*>(p.second.get());

        if (!inst->getModel()) {
            continue;
        }

        if (!SimpleModelInfo::isDoorModel(
                inst->getModelInfo<BaseModelInfo>()->name)) {
            continue;
        }

        const auto instPos = inst->getPosition();
        const auto xDist = std::abs(instPos.x - midpoint.x);
        const auto yDist = std::abs(instPos.y - midpoint.y);

        if (xDist < 20.f && yDist < 20.f) {
            if (!doorObject) {
                doorObject = inst;
                continue;
            } else {
                secondDoorObject = inst;
            }
        }
    }

    if (doorObject) {
        startPosition = doorObject->getPosition();

        // Setup door height based on model's bounding box
        auto doorModel = doorObject->getModelInfo<BaseModelInfo>();
        auto collision = doorModel->getCollision();
        // Original behavior - game actually subtracts 0.1f
        doorHeight =
            collision->boundingBox.max.z - collision->boundingBox.min.z - 0.1f;
    }

    if (secondDoorObject) {
        startPositionSecondDoor = secondDoorObject->getPosition();
    }

    step /= doorHeight;

    switch (type) {
        case Garage::Type::Mission:
        case Garage::Type::CollectCars1:
        case Garage::Type::CollectCars2:
        case Garage::Type::MissionForCarToComeOut:
        case Garage::Type::MissionKeepCar:
        case Garage::Type::Hideout1:
        case Garage::Type::Hideout2:
        case Garage::Type::Hideout3:
        case Garage::Type::MissionToOpenAndClose:
        case Garage::Type::MissionForSpecificCar:
        case Garage::Type::MissionKeepCarAndRemainClosed: {
            state = State::Closed;
            break;
        }

        case Garage::Type::BombShop1:
        case Garage::Type::BombShop2:
        case Garage::Type::BombShop3:
        case Garage::Type::Respray:
        case Garage::Type::Crusher: {
            state = State::Opened;
            break;
        }
    }

    if (state == State::Closed) {
        fraction = 0.f;
    } else {
        fraction = 1.f;
    }

    if (doorObject) {
        updateDoor();
    }
}