//-----------------------------------------------------------------------------
// Fixes up all elements
//-----------------------------------------------------------------------------
void CImportSFMV6::FixupElement( CDmElement *pElement )
{
	if ( !pElement )
		return;

	const char *pType = pElement->GetTypeString();

	if ( !V_stricmp( pType, "DmeProjectedLight" ) )
	{
		Vector vDir = pElement->GetValue<Vector>( "direction" );
		pElement->RemoveAttribute( "direction" );
		Quaternion q = DirectionToOrientation( vDir );
		pElement->SetValue<Quaternion>( "orientation", q );
	}
}
Example #2
0
void GameObject::Update(float elapsed)
{
	if (!path.empty()) {
		sf::Vector2f tgt = path.top();
		sf::Vector2f dist = tgt - GetPosition();

		if (norm(dist) < 0.2)
			path.pop();

		if (path.empty() && noticeOnPathComplete)
			Scripting::Get().PostEvent("ObjectPathComplete", id);
	}
	if (!path.empty()) {
		sf::Vector2f tgt = path.top();
		sf::Vector2f dir = tgt - GetPosition();

		float r = norm(dir);
		dir /= r;

		position += (dir * moveSpeed * elapsed);

		SetOrientation(DirectionToOrientation(dir));
	}
}