Example #1
0
void cGameLamp::OnPlayerInteract()
{
	Log("cGameLamp::OnPlayerInteract -->%s, at distance %f\n", msName.c_str(), mpInit->mpPlayer->GetPickedDist());

	if(mpInit->mpPlayer->GetPickedDist() < mfMaxInteractDist)
	{
		bool bInteracted=false;
		if(mbLit && mbInteractOff && msOffItem==""){
			SetLit(false,true);
			bInteracted = true;
		}
		else if(!mbLit && mbInteractOn && msOnItem==""){
			SetLit(true,true);
			bInteracted = true;
		}
		
		//If no interaction, use grab mode
		if(	mpInit->mpPlayer->GetPickedBody()->GetMass() != 0 && 
			bInteracted==false && ((mbLit && mbInteractOff) || (!mbLit && mbInteractOn)))
		{
			if(mpInit->mbHasHaptics && mpInit->mpPlayer->mbProxyTouching==false) return;

			mpInit->mpPlayer->mbPickAtPoint = false;
			mpInit->mpPlayer->mbRotateWithPlayer = true;
			mpInit->mpPlayer->mbUseNormalMass = false;
			mpInit->mpPlayer->mfGrabMassMul = (float)mvBodies.size();
			mpInit->mpPlayer->mfCurrentMaxInteractDist = mfMaxInteractDist;

			mpInit->mpPlayer->SetPushBody(mpInit->mpPlayer->GetPickedBody());
			mpInit->mpPlayer->ChangeState(ePlayerState_Grab);
		}
	}
}
Example #2
0
bool cGameLamp::OnUseItem(cInventoryItem *apItem)
{
	if(mbLit && mbInteractOff && msOffItem==apItem->GetName())
	{
		SetLit(false,true);
		return true;
	}
	else if(!mbLit && mbInteractOn && msOnItem==apItem->GetName())
	{
		SetLit(true,true);
		return true;
	}

	return false;
}
Example #3
0
void cGameLamp::LoadFromSaveData(iGameEntity_SaveData *apSaveData)
{
	__super::LoadFromSaveData(apSaveData);
	cGameLamp_SaveData *pData = static_cast<cGameLamp_SaveData*>(apSaveData);
	
	kCopyFromVar(pData,msLitChangeCallback);

	SetLit(pData->mbLit,false);
	SetFlicker(pData->mbFlickering);
}