Exemplo n.º 1
0
void Ship::SetFlightState(Ship::FlightState newState)
{
	if (m_flightState == newState) return;
	if (IsHyperspaceActive() && (newState != FLYING))
		ResetHyperspaceCountdown();

	if (newState == FLYING) {
		m_testLanded = false;
		if (m_flightState == DOCKING || m_flightState == DOCKED) onUndock.emit();
		m_dockedWith = 0;
		// lock thrusters for two seconds to push us out of station
		m_launchLockTimeout = 2.0;
	}

	m_flightState = newState;
	switch (m_flightState)
	{
		case FLYING: SetMoving(true); SetColliding(true); SetStatic(false); break;
		case DOCKING: SetMoving(false); SetColliding(false); SetStatic(false); break;
// TODO: set collision index? dynamic stations... use landed for open-air?
		case DOCKED: SetMoving(false); SetColliding(false); SetStatic(false); break;
		case LANDED: SetMoving(false); SetColliding(true); SetStatic(true); break;
		case HYPERSPACE: SetMoving(false); SetColliding(false); SetStatic(false); break;
	}
}
Exemplo n.º 2
0
void Ship::SetFlightState(Ship::FlightState newState)
{
	if (m_flightState == newState) return;
	if (IsHyperspaceActive() && (newState != FLYING))
		AbortHyperjump();

	if (newState == FLYING) {
		m_testLanded = false;
		if (m_flightState == DOCKING || m_flightState == DOCKED)
			onUndock.emit();

		m_dockedWith = nullptr;

		// lock thrusters on for amount of time needed to push us out of station
		static const double MASS_LOCK_REFERENCE(40000.0); // based purely on experimentation
		// limit the time to between 2.0 and 20.0 seconds of thrust, the player can override
		m_launchLockTimeout = std::min(std::max(2.0, 2.0 * (GetMass() / MASS_LOCK_REFERENCE)), 20.0);
	}

	m_flightState = newState;
	Properties().Set("flightState", EnumStrings::GetString("ShipFlightState", m_flightState));

	switch (m_flightState)
	{
		case FLYING:		SetMoving(true);	SetColliding(true);		SetStatic(false);	break;
		case DOCKING:		SetMoving(false);	SetColliding(false);	SetStatic(false);	break;
		case UNDOCKING:	SetMoving(false);	SetColliding(false);	SetStatic(false);	break;
// TODO: set collision index? dynamic stations... use landed for open-air?
		case DOCKED:		SetMoving(false);	SetColliding(false);	SetStatic(false);	break;
		case LANDED:		SetMoving(false);	SetColliding(true);		SetStatic(true);	break;
		case JUMPING:		SetMoving(true);	SetColliding(false);	SetStatic(false);	break;
		case HYPERSPACE:	SetMoving(false);	SetColliding(false);	SetStatic(false);	break;
	}
}
Exemplo n.º 3
0
ShipCockpit::ShipCockpit(const std::string &modelName) :
m_shipDir(0.0),
m_shipYaw(0.0),
m_dir(0.0),
m_yaw(0.0),
m_rotInterp(0.f),
m_transInterp(0.f),
m_gForce(0.f),
m_offset(0.f),
m_shipVel(0.f),
m_translate(0.0),
m_transform(matrix4x4d::Identity())
{
	assert(!modelName.empty());
	SetModel(modelName.c_str());
	assert(GetModel());
	SetColliding(false);
	m_icc = nullptr;
}