コード例 #1
0
// Make a new CNeighbour object, copying values from a base one
// Takes a protocol ID and a base neighbour to copy information from
CNeighbour::CNeighbour(PROTOCOLID nProtocol, CNeighbour* pBase)
{
	// Calls CConection::AttachTo, treating CNeighbour* pBase as class* CConnection
	AttachTo( pBase );

	// Copy the values from pBase into this CNeighbour object
	CopyMemory( &m_zStart, &pBase->m_zStart, (LPBYTE)&m_zEnd - (LPBYTE)&m_zStart );

	// Set some custom values for the new CNeighbour object
	m_nState		= nrsConnected;		// Set the state of this neighbour to connected
	m_nProtocol		= nProtocol;		// Store the given protocol in the object
	m_tConnected	= GetTickCount();	// Set Connected and LastPacket with the current time
	m_tLastPacket	= m_tConnected;

	// If this connected computer is sending and receiving Gnutella2 packets, it will also support query routing
	if ( m_bQueryRouting )
	{
		// Make two new QueryHashTable objects, one for the local table, and one for the remote one for
		m_pQueryTableLocal	= new CQueryHashTable();
		m_pQueryTableRemote	= new CQueryHashTable();
	}

	// Call CNeighboursBase::Add to keep track of this newly created CNeighbours object
	Neighbours.Add( this, FALSE );
}
コード例 #2
0
ファイル: Connection.cpp プロジェクト: 453483289/WMI
void Connection::execMethod(IWbemServicesPtr connection, IWbemClassObjectPtr object,
							const tchar* path, const tchar* method, IWbemClassObjectPtr arguments, WCL::Variant& returnValue)
{
	ASSERT(connection.get() != nullptr);

	const WCL::ComStr objectPath(path);
	const WCL::ComStr methodName(method);

	IWbemClassObjectPtr output;

	HRESULT result = connection->ExecMethod(objectPath.Get(), methodName.Get(), 0,
											nullptr, arguments.get(), AttachTo(output), nullptr);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to execute method '%s' on object '%s'"), method, path);
		throw Exception(result, connection, message.c_str());
	}

	const WCL::ComStr RETURN_VALUE(TXT("ReturnValue"));

    result = output->Get(RETURN_VALUE.Get(), 0, &returnValue, NULL, 0);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to get '%s' method return value"), method);
		throw Exception(result, connection, message.c_str());
	}
}
コード例 #3
0
ファイル: Connection.cpp プロジェクト: 453483289/WMI
void Connection::open(const tstring& host, const tstring& login, const tstring& password, const tstring& nmspace)
{
	ASSERT(!isOpen());

	// Format the full connection path.
	tstring path = host + nmspace;

	if (path.compare(0, 2, TXT("\\\\")) != 0)
		path = TXT("\\\\") + path;

	// Create the connection.
	IWbemServicesPtr	services;
	IWbemLocatorPtr		locator(CLSID_WbemLocator);
	WCL::ComStr			bstrPath(path);
	WCL::ComStr			bstrAuth(TXT(""));
	HRESULT				result;

	if (login.empty())
	{
		result = locator->ConnectServer(bstrPath.Get(), nullptr, nullptr, nullptr, 0,
										bstrAuth.Get(), nullptr, AttachTo(services));
	}
	else
	{
		WCL::ComStr	bstrLogin(login);
		WCL::ComStr	bstrPassword(password);

		result = locator->ConnectServer(bstrPath.Get(), bstrLogin.Get(), bstrPassword.Get(), nullptr, 0,
										bstrAuth.Get(), nullptr, AttachTo(services));
	}

	if (FAILED(result))
		throw Exception(result, locator, Core::fmt(TXT("Failed to connect to the WMI provider on '%s'"), host.c_str()).c_str());

	// Enable impersonation on the connection.
    result = ::CoSetProxyBlanket(services.get(), RPC_C_AUTHN_DEFAULT, RPC_C_AUTHZ_DEFAULT, nullptr,
									RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE,
									nullptr, EOAC_NONE);

	if (FAILED(result))
		throw Exception(result, locator, TXT("Failed to enable impersonation on the WMI connection"));

	// Update state.
	m_locator  = locator;
	m_services = services;
}
コード例 #4
0
ファイル: Graph.cpp プロジェクト: pokelege/ProjectTap_Code
UStaticMeshComponent* AGraph::makeEdgeMeshForEdge(int32 i, int32 j)
{
	auto name = FString("Edge").Append(FString::FromInt(i)).Append(FString::FromInt(j));
	auto edge = NewObject<UStaticMeshComponent>(this, *name);
	edge->AttachTo(RootComponent);
	edge->SetStaticMesh(edgeStaticMesh);

	return edge;
}
コード例 #5
0
void UPrimitiveComponent::WeldTo(USceneComponent* InParent, FName InSocketName /* = NAME_None */)
{
	//automatically attach if needed
	if (AttachParent != InParent || AttachSocketName != InSocketName)
	{
		AttachTo(InParent, InSocketName, EAttachLocation::KeepWorldPosition);
	}

	WeldToImplementation(InParent, InSocketName);
}
コード例 #6
0
CClientPickup::~CClientPickup ( void )
{
    AttachTo ( NULL );

    // Make sure our pickup is destroyed
    Destroy ();

    // Remove us from the pickup manager's list
    Unlink ();
}
コード例 #7
0
VideoPipelineSource::VideoPipelineSource(VideoPipelineSink* sink,
                                         VideoUnit* idle_unit,
                                         const SourceRatePolicy& policy,
                                         float max_fps)
    : sink_(sink),
      idle_unit_(idle_unit),
      source_rate_policy_(policy),
      max_fps_(max_fps) {
  AttachTo(sink);
  frame_num_ = 0;
}
コード例 #8
0
ファイル: Graph.cpp プロジェクト: pokelege/ProjectTap_Code
UStaticMeshComponent* AGraph::makeVertexMeshForVertex(int32 v)
{
	auto name = FString("vertex").Append(FString::FromInt(v));
	auto vertex = NewObject<UStaticMeshComponent>(this, *name);
	vertex->AttachTo(RootComponent);

	vertex->SetStaticMesh(vertexStaticMesh);
	vertex->SetWorldScale3D(FVector(40.0f, 40.0f, 1.0f));
	vertex->SetWorldLocation(mark[v]->GetActorLocation());

	return vertex;
}
コード例 #9
0
ファイル: Neighbour.cpp プロジェクト: GetEnvy/Envy
// Make a new CNeighbour object, copying values from a base one
// Takes a protocol ID and a base neighbour to copy information from
CNeighbour::CNeighbour(PROTOCOLID nProtocol, CNeighbour* pBase)
	: CConnection( nProtocol )
	, m_nRunCookie		( 0 )
	, m_nState			( nrsConnected )
	, m_pVendor 		( pBase->m_pVendor )
	, m_oGUID			( pBase->m_oGUID )
	, m_oMoreResultsGUID( )
	, m_pProfile		( NULL )
	, m_bAutomatic		( pBase->m_bAutomatic )
	, m_nNodeType		( pBase->m_nNodeType )
	, m_bQueryRouting	( pBase->m_bQueryRouting )
	, m_bPongCaching	( pBase->m_bPongCaching )
	, m_bVendorMsg		( pBase->m_bVendorMsg )
	, m_bGGEP			( pBase->m_bGGEP )
	, m_tLastQuery		( pBase->m_tLastQuery )
	, m_bBadClient		( pBase->m_bBadClient )
	, m_nDegree 		( pBase->m_nDegree )
	, m_nMaxTTL 		( pBase->m_nMaxTTL )
	, m_bDynamicQuerying( pBase->m_bDynamicQuerying )
	, m_bUltrapeerQueryRouting ( pBase->m_bUltrapeerQueryRouting )
	, m_sLocalePref 	( pBase->m_sLocalePref )
	, m_bRequeries		( pBase->m_bRequeries )
	, m_bExtProbes		( pBase->m_bExtProbes )
	, m_nInputCount		( pBase->m_nInputCount )
	, m_nOutputCount	( pBase->m_nOutputCount )
	, m_nDropCount		( pBase->m_nDropCount )
	, m_nLostCount		( pBase->m_nLostCount )
	, m_nOutbound		( pBase->m_nOutbound )
	, m_nFileCount		( pBase->m_nFileCount )
	, m_nFileVolume 	( pBase->m_nFileVolume )
	// If the connected computer is sending and receiving Gnutella2 packets, it will also support query routing
	, m_pQueryTableRemote( m_bQueryRouting ? new CQueryHashTable : NULL )
	, m_pQueryTableLocal ( m_bQueryRouting ? new CQueryHashTable : NULL )
	, m_tLastPacket 	( GetTickCount() )
	, m_pZInput 		( pBase->m_pZInput )	// Transfer of ownership
	, m_pZOutput		( pBase->m_pZOutput )	// Transfer of ownership
	, m_nZInput 		( pBase->m_nZInput )	// Transfer of ownership
	, m_nZOutput		( pBase->m_nZOutput )	// Transfer of ownership
	, m_pZSInput		( NULL )
	, m_pZSOutput		( NULL )
	, m_bZFlush 		( pBase->m_bZFlush )
	, m_bZInputEOS		( pBase->m_bZInputEOS )
	, m_tZOutput		( pBase->m_tZOutput )
{
	AttachTo( pBase );

	pBase->m_pZInput  = NULL;
	pBase->m_pZOutput = NULL;

	m_bAutoDelete = TRUE;

	Neighbours.Add( this );		// Call CNeighboursBase::Add to keep track of this newly created CNeighbours object
}
コード例 #10
0
void FWorldTileModel::SetAlwaysLoaded(bool bAlwaysLoaded)
{
	if (LevelCollectionModel.IsReadOnly() || GetLevelObject() == NULL || IsRootTile())
	{
		return;
	}

	FWorldTileInfo Info = LevelCollectionModel.GetWorld()->WorldComposition->GetTileInfo(TileDetails->PackageName);
	
	if (Info.bAlwaysLoaded != bAlwaysLoaded)
	{
		bool bWasVisible = GetLevelObject()->bIsVisible;
		
		// Hide level, so it will be positioned at origin
		SetVisible(false);
		
		auto& WorldModel = static_cast<FWorldTileCollectionModel&>(LevelCollectionModel);
		TSharedPtr<FWorldTileModel> RootTileModel = WorldModel.GetWorldRootModel();

		// Remove parent relationship	
		AttachTo(RootTileModel);
		
		// Detach children
		for (auto It = AllChildren.CreateConstIterator(); It; ++It)
		{
			(*It)->AttachTo(RootTileModel);
		}
		
		//Remove world positioning
		TileDetails->Position = FIntPoint::ZeroValue;
		TileDetails->AbsolutePosition = FIntPoint::ZeroValue;

		//Mark level
		TileDetails->bAlwaysLoaded = bAlwaysLoaded;
		OnLevelInfoUpdated();

		// Restore level visibility
		if (bAlwaysLoaded)
		{
			// Always loaded levels - always visible
			SetVisible(true);
		}
		else
		{
			SetVisible(bWasVisible);
		}
	}
}
コード例 #11
0
BOOL CHostBrowser::OnPush(GGUID* pClientID, CConnection* pConnection)
{
	if ( m_tPushed == 0 ) return FALSE;
	if ( m_hSocket != INVALID_SOCKET ) return FALSE;

	if ( m_pClientID != *pClientID ) return FALSE;

	AttachTo( pConnection );

	m_pAddress	= m_pHost.sin_addr;
	m_nPort		= htons( m_pHost.sin_port );

	SendRequest();

	return TRUE;
}
コード例 #12
0
ファイル: CVehicle.cpp プロジェクト: vvc/mtasa-blue
void CVehicle::SpawnAt ( const CVector& vecPosition, const CVector& vecRotation )
{
    SetHealth ( GetRespawnHealth () );
    SetIsBlown ( false );
    StopIdleTimer ();
    ResetDoorsWheelsPanelsLights ();
    SetLandingGearDown ( true );
    SetAdjustableProperty ( 0 );
    SetTowedByVehicle ( NULL );
    AttachTo ( NULL );
    
    m_vecTurnSpeed = CVector ();
    m_vecVelocity = CVector ();
    m_vecPosition = vecPosition;
    m_vecRotationDegrees = vecRotation;
    UpdateSpatialData ();
}
コード例 #13
0
ファイル: HostBrowser.cpp プロジェクト: GetEnvy/Envy
BOOL CHostBrowser::OnPush(const Hashes::Guid& oClientID, CConnection* pConnection)
{
	//CQuickLock oTransfersLock( Transfers.m_pSection );

	// ED2K connections aren't handled here- they are in ED2KClient
	if ( m_nProtocol == PROTOCOL_ED2K || m_nProtocol == PROTOCOL_DC || m_tPushed == 0 ) return FALSE;
	if ( IsValid() || ! pConnection->IsValid() || ! validAndEqual( m_oClientID, oClientID ) ) return FALSE;

	AttachTo( pConnection );

	m_pAddress	= m_pHost.sin_addr;
	m_nPort		= htons( m_pHost.sin_port );

	SendRequest();

	return TRUE;
}
コード例 #14
0
CClientObject::~CClientObject ( void )
{
    // Unrequest whatever we've requested or we'll crash in unlucky situations
    m_pModelRequester->Cancel ( this, false );  

    // Detach us from anything
    AttachTo ( NULL );

    // Destroy the object
    Destroy ();

    // Remove us from the list
    Unlink ();

    if ( m_bIsLowLod )
        m_pManager->OnLowLODElementDestroyed ();
}
コード例 #15
0
ファイル: Exception.cpp プロジェクト: TidyHuang/WMI
tstring Exception::formatWmiError(HRESULT error)
{
	typedef WCL::ComPtr<IWbemStatusCodeText> IWbemStatusCodeTextPtr;

	WCL::ComStr text;

	// Use the WMI error lookup first.
	IWbemStatusCodeTextPtr converter(CLSID_WbemStatusCodeText);

	HRESULT result = converter->GetErrorCodeText(error, 0, 0, AttachTo(text));

	if (SUCCEEDED(result))
		return Core::trimCopy(W2T(text.Get()));

	// Fall-back to using the standard error formatter.
	return tstring(CStrCvt::FormatError(error));
}
コード例 #16
0
ファイル: Connection.cpp プロジェクト: 453483289/WMI
Object Connection::getObject(const tstring& path) const
{
	const WCL::ComStr objectPath(path);

	IWbemClassObjectPtr object;

	HRESULT result = m_services->GetObject(objectPath.Get(), WBEM_FLAG_RETURN_WBEM_COMPLETE,
											nullptr, AttachTo(object), nullptr);

	if (FAILED(result))
	{
		const tstring message = Core::fmt(TXT("Failed to get object from path '%s'"), path);
		throw Exception(result, m_services, message.c_str());
	}

	return Object(object, *this);
}
コード例 #17
0
bool CStickyProjectile::StickToStatic( const SStickParams& stickParams )
{
	m_stuckNormal = stickParams.m_stickNormal;
	m_stuckPartId = stickParams.m_targetPartId;

	IEntity* pProjectileEntity = stickParams.m_pProjectile->GetEntity();
	QuatT loc;
	CalculateLocationForStick( *pProjectileEntity, stickParams.m_stickPosition, stickParams.m_stickNormal, loc );
	pProjectileEntity->SetWorldTM(Matrix34(loc));

	m_stuckPos = loc.t;
	m_stuckRot = loc.q;
	AttachTo(stickParams.m_pProjectile, NULL);

	m_childId = pProjectileEntity->GetId();
	m_flags |= eSF_IsStuck;
	return true;
}
コード例 #18
0
void CStickyProjectile::NetSetStuck(CProjectile* pProjectile, bool stuck)
{
	if(stuck && ((m_flags&eSF_IsStuck)==0))
	{
		IEntity* pTargetEntity = gEnv->pEntitySystem->GetEntity(m_parentId);
		if(pTargetEntity)
		{
			if(ICharacterInstance* pTargetCharacter = pTargetEntity->GetCharacter(0))
			{
				const char* boneName = pTargetCharacter->GetICharacterModel()->GetICharacterModelSkeleton()->GetJointNameByID(m_stuckJoint);
				if(AttachToCharacter(pProjectile, *pTargetEntity, *pTargetCharacter, boneName))
				{
					IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTargetEntity->GetId());
					m_flags |= eSF_IsStuck;
					m_flags |= pActor ? pActor->IsPlayer() ? eSF_StuckToPlayer : eSF_StuckToAI : 0;
					m_childId = pProjectile->GetEntityId();
				}
			}
		}
		if((m_flags&eSF_IsStuck)==0)
		{
			IEntity* pProjectileEntity = pProjectile->GetEntity();
			AttachTo(pProjectile, pTargetEntity);
			m_childId = pProjectileEntity->GetId();
			if(pTargetEntity) //If we have a parent then the stuck position/rotation are local to the parent
			{
				pProjectileEntity->SetPos(m_stuckPos);
				pProjectileEntity->SetRotation(m_stuckRot);
			}
			else if(m_flags&eSF_OrientateToCollNormal)
			{
				Matrix34 mat;
				mat.SetTranslation(m_stuckPos);
				mat.SetRotation33(Matrix33(m_stuckRot));
				pProjectileEntity->SetWorldTM(mat);
			}
			else
			{
				pProjectileEntity->SetPos(m_stuckPos);
			}
			m_flags |= eSF_IsStuck;
		}
	}
}
コード例 #19
0
ファイル: Connection.cpp プロジェクト: 453483289/WMI
ObjectIterator Connection::execQuery(const tchar* query) const
{
	ASSERT(isOpen());

	WCL::ComStr	language(L"WQL");
	WCL::ComStr	queryText(query);
	long		flags(WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY);

	IEnumWbemClassObjectPtr enumerator;

	// Execute it.
	HRESULT result = m_services->ExecQuery(language.Get(), queryText.Get(), flags,
											nullptr, AttachTo(enumerator));

	if (FAILED(result))
		throw Exception(result, m_services, TXT("Failed to execute a WMI query"));

	return ObjectIterator(enumerator, *this);
}
コード例 #20
0
ファイル: CVehicle.cpp プロジェクト: EagleShen/MTA
void CVehicle::SpawnAt ( const CVector& vecPosition, const CVector& vecRotation )
{
    SetHealth ( GetRespawnHealth () );
    SetBlowTime ( 0 );
    SetIdleTime ( 0 );
    GetInitialDoorStates ( m_ucDoorStates );
    memset ( m_ucWheelStates, 0, sizeof ( m_ucWheelStates ) );
    memset ( m_ucPanelStates, 0, sizeof ( m_ucPanelStates ) );
    memset ( m_ucLightStates, 0, sizeof ( m_ucLightStates ) );
    SetLandingGearDown ( true );
    SetAdjustableProperty ( 0 );
    SetTowedByVehicle ( NULL );
    AttachTo ( NULL );
    
    CVector vecNull;

    m_vecTurnSpeed = vecNull;
    m_vecVelocity = vecNull;
    m_vecPosition = vecPosition;
    m_vecRotationDegrees = vecRotation;
    UpdateSpatialData ();
}
コード例 #21
0
 CInterfaceHook& operator=(I* interface)
 {
     AttachTo(interface);
     return *this;
 }
コード例 #22
0
 CInterfaceHook(I* interface = NULL) :
     m_Interface(NULL)
 {
     AttachTo(interface);
 }
コード例 #23
0
bool CStickyProjectile::StickToEntity( const SStickParams& stickParams, IEntity* pTargetEntity )
{
	IEntity* pProjectileEntity = stickParams.m_pProjectile->GetEntity();
	ICharacterInstance* pCharInstance = pTargetEntity->GetCharacter(0);
	if( pCharInstance)	
	{
		IActor* pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(pTargetEntity->GetId());
		if (!pActor || (stickParams.m_bStickToFriendlies || !pActor->IsFriendlyEntity(stickParams.m_ownerId)) && (gEnv->bMultiplayer || !pActor->IsDead()))
		{
			m_stuckJoint = GetJointIdFromPartId(*pTargetEntity, stickParams.m_targetPartId);
			m_stuckNormal = stickParams.m_stickNormal;
			m_stuckPartId = stickParams.m_targetPartId;

			ICharacterModelSkeleton* pICharacterModelSkeleton = pCharInstance->GetICharacterModel()->GetICharacterModelSkeleton();
			ISkeletonPose* pSkeleton = pCharInstance->GetISkeletonPose();
			const char* boneName = pICharacterModelSkeleton->GetJointNameByID(m_stuckJoint);
			const QuatT jointWorld = QuatT(pTargetEntity->GetWorldTM()) * pSkeleton->GetAbsJointByID(m_stuckJoint);
			QuatT loc;
			CalculateLocationForStick( *pProjectileEntity, stickParams.m_stickPosition, stickParams.m_stickNormal, loc );
			pProjectileEntity->SetWorldTM(Matrix34(loc));

			// Get the local pos and rot.
			loc = jointWorld.GetInverted() * loc;
			m_stuckPos = loc.t;
			m_stuckRot = loc.q;

			// Attach.
			if(AttachToCharacter( stickParams.m_pProjectile, *pTargetEntity, *pCharInstance, boneName))
			{
				m_flags |= eSF_IsStuck;
				m_flags |= pActor ? pActor->IsPlayer() ? eSF_StuckToPlayer : eSF_StuckToAI : 0;
				SetParentId(pTargetEntity->GetId());
				m_childId = pProjectileEntity->GetId();
				return true;
			}
		}
	}
	else
	{
		m_stuckNormal = stickParams.m_stickNormal;
		m_stuckPartId = stickParams.m_targetPartId;

		QuatT loc;
		CalculateLocationForStick( *pProjectileEntity, stickParams.m_stickPosition, stickParams.m_stickNormal, loc );

		AttachTo(stickParams.m_pProjectile, pTargetEntity);

		pProjectileEntity->SetWorldTM(Matrix34(loc));

		// Set as Stuck.
		SetParentId(pTargetEntity->GetId());
		m_childId = pProjectileEntity->GetId();
		m_flags |= eSF_IsStuck;

		//Store position and rotation relative to parent entity
		m_stuckPos = pProjectileEntity->GetPos();
		m_stuckRot = pProjectileEntity->GetRotation();
		return true;
	}

	return false;
}
コード例 #24
0
ファイル: Floater.cpp プロジェクト: ChriPiv/MCServer
void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
{
	HandlePhysics(a_Dt, a_Chunk);
	if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
	{
		if ((!m_CanPickupItem) && (m_AttachedMobID == -1))  // Check if you can't already pickup a fish and if the floater isn't attached to a mob.
		{
			if (m_CountDownTime <= 0)
			{
				m_World->BroadcastSoundEffect("random.splash", GetPosX(), GetPosY(), GetPosZ(), 1, 1);
				SetPosY(GetPosY() - 1);
				m_CanPickupItem = true;
				m_PickupCountDown = 20;
				m_CountDownTime = 100 + m_World->GetTickRandomNumber(800);
				LOGD("Floater %i can be picked up", GetUniqueID());
			}
			else if (m_CountDownTime == 20)  // Calculate the position where the particles should spawn and start producing them.
			{
				LOGD("Started producing particles for floater %i", GetUniqueID());
				m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8)));
				m_World->BroadcastParticleEffect("splash", (float) m_ParticlePos.x, (float) m_ParticlePos.y, (float) m_ParticlePos.z, 0, 0, 0, 0, 15);
			}
			else if (m_CountDownTime < 20)
			{
				m_ParticlePos = (m_ParticlePos + (GetPosition() - m_ParticlePos) / 6);
				m_World->BroadcastParticleEffect("splash", (float) m_ParticlePos.x, (float) m_ParticlePos.y, (float) m_ParticlePos.z, 0, 0, 0, 0, 15);
			}
			
			m_CountDownTime--;
			if (m_World->GetHeight((int) GetPosX(), (int) GetPosZ()) == (int) GetPosY())
			{
				if (m_World->IsWeatherWet() && m_World->GetTickRandomNumber(3) == 0)  // 25% chance of an extra countdown when being rained on.
				{
					m_CountDownTime--;
				}
			}
			else  // if the floater is underground it has a 50% chance of not decreasing the countdown.
			{
				if (m_World->GetTickRandomNumber(1) == 0)
				{
					m_CountDownTime++;
				}
			}
		}
		SetSpeedY(0.7);
	}

	if (CanPickup())  // Make sure the floater "loses its fish"
	{
		m_PickupCountDown--;
		if (m_PickupCountDown == 0)
		{
			m_CanPickupItem = false;
			LOGD("The fish is gone. Floater %i can not pick an item up.", GetUniqueID());
		}
	}

	if ((GetSpeed().Length() > 4) && (m_AttachedMobID == -1))
	{
		cFloaterEntityCollisionCallback Callback(this, GetPosition(), GetPosition() + GetSpeed() / 20);
		
		a_Chunk.ForEachEntity(Callback);
		if (Callback.HasHit())
		{
			AttachTo(Callback.GetHitEntity());
			Callback.GetHitEntity()->TakeDamage(*this);  // TODO: the player attacked the mob not the floater.
			m_AttachedMobID = Callback.GetHitEntity()->GetUniqueID();
		}
	}

	cFloaterCheckEntityExist EntityCallback;
	m_World->DoWithEntityByID(m_PlayerID, EntityCallback);
	if (!EntityCallback.DoesExist())  // The owner doesn't exist anymore. Destroy the floater entity.
	{
		Destroy(true);
	}

	if (m_AttachedMobID != -1)
	{
		m_World->DoWithEntityByID(m_AttachedMobID, EntityCallback);  // The mob the floater was attached to doesn't exist anymore.
		if (!EntityCallback.DoesExist())
		{
			m_AttachedMobID = -1;
		}
	}

	SetSpeedX(GetSpeedX() * 0.95);
	SetSpeedZ(GetSpeedZ() * 0.95);

	BroadcastMovementUpdate();
}
コード例 #25
0
concurrency::task<void> FavoritesService::doRefreshAsync(concurrency::cancellation_token cancelToken)
{
	auto& authState = getAuthenticationService().authenticationState();
	bool refreshFailed = false;
	if (!authState.isAuthenticated()) {
		{
			std::lock_guard<std::recursive_mutex> lg(_mutex);
			_albumIds.clear();
			_artistIds.clear();
			_trackIds.clear();
			_playlistIds.clear();

			_albums->Clear();
			_artists->Clear();
			_playlists->Clear();
			_myPlaylists->Clear();
			_tracks->Clear();
		}
		co_await concurrency::task_from_result();
	}
	else {
		auto albumsTask = api::GetFavoriteAlbumsQuery::Make(authState.userId(), authState.sessionId(), authState.countryCode())->executeAsync(cancelToken);
		auto artistsTask = api::GetFavoriteArtistsQuery::Make(authState.userId(), authState.sessionId(), authState.countryCode())->executeAsync(cancelToken);
		auto tracksTask = api::GetFavoriteTracksQuery::Make(authState.userId(), authState.sessionId(), authState.countryCode())->executeAsync(cancelToken);
		auto playlistsTask = api::GetFavoritePlaylistsQuery::Make(authState.userId(), authState.sessionId(), authState.countryCode())->executeAsync(cancelToken);
		auto myPlaylistsTask = api::GetMyPlaylistsQuery::Make(authState.userId(), authState.sessionId(), authState.countryCode())->executeAsync(cancelToken);

		try {
			auto albums = co_await albumsTask;
			std::sort(albums->items.begin(), albums->items.end(), [](const auto& lhs, const auto& rhs) {
				return lhs.created > rhs.created;
			});
			{
				std::lock_guard<std::recursive_mutex> lg(_mutex);
				_albumIds.clear();
				_albums->Clear();
				for (auto&& item : albums->items) {
					_albumIds.insert(item.item.id);
					_albums->Append(ref new Tidal::AlbumResumeItemVM(item.item));
				}
			}
		}
		catch (concurrency::task_canceled&) {}
		catch (...) {
			refreshFailed = true;
		}

		try {
			auto artists = co_await artistsTask;

			std::sort(artists->items.begin(), artists->items.end(), [](const auto& lhs, const auto& rhs) {
				return lhs.created > rhs.created;
			});
			{
				std::lock_guard<std::recursive_mutex> lg(_mutex);
				_artistIds.clear();
				_artists->Clear();
				for (auto&& item : artists->items) {
					_artistIds.insert(item.item.id);
					_artists->Append(ref new Tidal::ArtistItemVM(item.item));
				}
			}
		}
		catch (concurrency::task_canceled&) {}
		catch (...) {
			refreshFailed = true;
		}
		try {
			auto tracks = co_await tracksTask;

			std::sort(tracks->items.begin(), tracks->items.end(), [](const auto& lhs, const auto& rhs) {
				return lhs.created > rhs.created;
			});
			{
				std::lock_guard<std::recursive_mutex> lg(_mutex);
				_trackIds.clear();
				_tracks->Clear();
				for (auto&& item : tracks->items) {
					_trackIds.insert(item.item.id);
					auto ti = ref new Tidal::TrackItemVM(item.item);
					_tracks->Append(ti);
					ti->AttachTo(_tracks);
				}
			}

		}
		catch (concurrency::task_canceled&) {}
		catch (...) {
			refreshFailed = true;
		}


		try {
			auto playlists = co_await playlistsTask;

			std::sort(playlists->items.begin(), playlists->items.end(), [](const auto& lhs, const auto& rhs) {
				return lhs.created > rhs.created;
			});
			{
				std::lock_guard<std::recursive_mutex> lg(_mutex);
				_playlistIds.clear();
				_playlists->Clear();
				for (auto&& item : playlists->items) {
					_playlistIds.insert(item.item.uuid);
					_playlists->Append(ref new Tidal::PlaylistResumeItemVM(item.item));
				}
			}
		}
		catch (concurrency::task_canceled&) {}
		catch (...) {
			refreshFailed = true;
		}

		try {
			auto myPlaylists = co_await myPlaylistsTask;
			{
				std::lock_guard<std::recursive_mutex> lg(_mutex);
				_myPlaylists->Clear();
				for (auto&& item : myPlaylists->items) {
					_myPlaylists->Append(ref new Tidal::PlaylistResumeItemVM(item));
				}
			}
		}
		catch (concurrency::task_canceled&) {}
		catch (...) {
			refreshFailed = true;
		}

		if (cancelToken.is_canceled()) {
			concurrency::cancel_current_task();
		}
		else if(refreshFailed) {
			throw refresh_failed();
		}
	}
	getFavoritesRefreshedMediator().raise(true);
}
コード例 #26
0
ファイル: SellrTable.cpp プロジェクト: peartail/myfishGame
// Sets default values
ASellrTable::ASellrTable()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;

	gameCamera = CreateDefaultSubobject<UCameraComponent>("gameCamera");
	RootComponent = gameCamera;

	gameCamera->SetWorldScale3D(FVector(0.05f));

	UVectorFieldComponent* vf3 = CreateDefaultSubobject<UVectorFieldComponent>("Board_VF");
	vf3->AttachTo(gameCamera);
	vf_Board = vf3;

	UVectorFieldComponent* vf1 = CreateDefaultSubobject<UVectorFieldComponent>("BoardSub_VF");
	vf1->AttachTo(vf3);
	vf_BoardSub = vf1;

	UVectorFieldComponent* vf2 = CreateDefaultSubobject<UVectorFieldComponent>("Guchidae_VF");
	vf2->AttachTo(vf3);
	vf_Guchidae = vf2;

	UVectorFieldComponent* vf4 = CreateDefaultSubobject<UVectorFieldComponent>("Customer_VF");
	vf4->AttachTo(vf3);
	vf_Customer = vf4;

	
	static ConstructorHelpers::FObjectFinder<UPaperSprite> guchidae_sprite(TEXT("PaperSprite'/Game/fishGames/Scene/ShopContent/sprites/bread_chair_Sprite.bread_chair_Sprite'"));

	/*if (guchidae_sprite.Succeeded())
	{
		for (int i = 0; i < 9; i++)
		{
			FName filename(*("guchidae_" + FString::FromInt(i)));
			auto comp = CreateDefaultSubobject<UPaperSpriteComponent>(filename);
			comp->AttachTo(vf2);
			comp->SetSprite(guchidae_sprite.Object);
			comp->SetRelativeLocation(FVector(0.f, -2.f * i, 60.f * i));

		}
	}*/
	//touchevent.BindUFunction(this, TEXT("OnInputTouchBoard"));
	//clickevent.BindUFunction(this, TEXT("OnClickBoard"));
	TArray<UStaticMeshComponent*> boardlist;
	for (int i = 0; i < 9; i++)
	{
		FName filename(*("board_" + FString::FromInt(i)));
		auto comp = CreateDefaultSubobject<UStaticMeshComponent>(filename);
		comp->AttachTo(vf1);
		
		
		boardlist.Add(comp);
	}

	board1 = boardlist[0];
	board2 = boardlist[1];
	board3 = boardlist[2];
	board4 = boardlist[3];
	board5 = boardlist[4];
	board6 = boardlist[5];
	board7 = boardlist[6];
	board8 = boardlist[7];
	board9 = boardlist[8];

	TArray<UStaticMeshComponent*> fishlist;
	for (int i = 0; i < 9; i++)
	{
		FName filename(*("fish_" + FString::FromInt(i)));
		auto comp = CreateDefaultSubobject<UStaticMeshComponent>(filename);
		comp->AttachTo(boardlist[i]);

		fishlist.Add(comp);
	}

	fish1 = fishlist[0];
	fish2 = fishlist[1];
	fish3 = fishlist[2];
	fish4 = fishlist[3];
	fish5 = fishlist[4];
	fish6 = fishlist[5];
	fish7 = fishlist[6];
	fish8 = fishlist[7];
	fish9 = fishlist[8];

	static ConstructorHelpers::FObjectFinder<UMaterialInstance> fishbread_mat(TEXT("MaterialInstanceConstant'/Game/fishGames/Object/bread/fishbread2/fishbread2_Mat3_Inst.fishbread2_Mat3_Inst'"));

	for (int i = 0; i < 9; i++)
	{
		auto info = new FSFishBreadInfo;
		info->fishbread = fishlist[i];
		info->boardmesh = boardlist[i];
		if (fishbread_mat.Succeeded())
		{
			info->bakingMat = info->fishbread->CreateDynamicMaterialInstance(0, fishbread_mat.Object);
		}
		_productInfoList.Add(info);
	}

	
	

}