asIScriptFunction* ETHPhysicsEntityController::GetContactCallback(const str_type::string& prefix, asIScriptModule* module)
{
	ETHEntity* entity = static_cast<ETHEntity*>(m_body->GetUserData());
	str_type::stringstream ss;
	ss << prefix << Platform::RemoveExtension(entity->GetEntityName().c_str());
	return module->GetFunctionByName(utf8::c(ss.str()).c_str());
}
void ETHDestructionListener::SayGoodbye(b2Joint* joint)
{
    ETHEntity *jointOwner = static_cast<ETHEntity*>(joint->GetUserData());

    // Set joint pointer to NULL for safety
    jointOwner->AddRef();
    ETHPhysicsEntityControllerPtr ownerController = boost::dynamic_pointer_cast<ETHPhysicsEntityController>(jointOwner->GetController());
    assert(ownerController);
    ownerController->KillJoint(joint);
    jointOwner->Release();
}
ETHEntity *ETHScriptWrapper::SeekEntity(const int id)
{
	if (WarnIfRunsInMainFunction(GS_L("SeekEntity")))
		return 0;

	ETHEntity *pEntity = m_pScene->GetBucketManager().SeekEntity(id);
	if (pEntity)
	{
		// don't let it return temporary handles
		if (pEntity->IsTemporary())
		{
			return 0;
		}
		else
		{
			pEntity->AddRef();
			return pEntity;
		}
	}
	return 0;
}