Пример #1
0
void CBoundingContainer::SetupEntity()
{
	IEntity* pEntity = GetEntity();
	CRY_ASSERT(pEntity != NULL);

	IScriptTable* pScriptTable = pEntity->GetScriptTable();
	if (pScriptTable != NULL)
	{
		SmartScriptTable propertiesTable;
		if (pScriptTable->GetValue("Properties", propertiesTable))
		{
			Vec3 boundingDimensions(0.0f,0.0f,0.0f);
			propertiesTable->GetValue("DimX", boundingDimensions.x);
			propertiesTable->GetValue("DimY", boundingDimensions.y);
			propertiesTable->GetValue("DimZ", boundingDimensions.z);

			m_vBoundingMin = -boundingDimensions/2.0f;
			m_vBoundingMax = boundingDimensions/2.0f;
		}
	}
}
Пример #2
0
void CBodyDestrutibilityInstance::ResetMaterials( IEntity& characterEntity, ICharacterInstance& characterInstance )
{
	characterEntity.SetSlotMaterial(0, NULL);

	IAttachmentManager *pAttachmentManager = characterInstance.GetIAttachmentManager();
	CRY_ASSERT(pAttachmentManager);
	
	const uint32 attachmentCount = (uint32)pAttachmentManager->GetAttachmentCount();

	for(TOriginalMaterials::iterator it = m_originalMaterials.begin(); it != m_originalMaterials.end(); ++it)
	{
		IAttachmentObject *pAttachmentObject = (it->first < attachmentCount) ? pAttachmentManager->GetInterfaceByIndex(it->first)->GetIAttachmentObject() : NULL;
		if (pAttachmentObject)
		{
			pAttachmentObject->SetReplacementMaterial(it->second);
			it->second->Release();
		}
	}

	m_originalMaterials.clear();
}
Пример #3
0
void CLedgeManagerEdit::EnableLedge( const EntityId entityId, bool enable )
{
	TLedgeObjectsEditorContainer::iterator ledgeIt = std::find(m_ledgeObjects.begin(), m_ledgeObjects.end(), entityId);

	if (ledgeIt != m_ledgeObjects.end())
	{
		SLedgeObjectEditor& ledgeObject = *ledgeIt;
		CRY_ASSERT( (ledgeObject.m_ledgeFlags[LedgeSide_In] & kLedgeFlag_static) == 0 );

		if (enable)
		{
			ledgeObject.m_ledgeFlags[LedgeSide_In] |= kLedgeFlag_enabled;
			ledgeObject.m_ledgeFlags[LedgeSide_Out] |= kLedgeFlag_enabled;
		}
		else
		{
			ledgeObject.m_ledgeFlags[LedgeSide_In] &= ~kLedgeFlag_enabled;
			ledgeObject.m_ledgeFlags[LedgeSide_Out] &= ~kLedgeFlag_enabled;
		}
	}
}
Пример #4
0
//------------------------------------------------------------------------
void CGameRules::HostMigrationRemoveDuplicateDynamicEntities()
{
	CRY_ASSERT(!m_hostMigrationCachedEntities.empty());

	TEntityIdVec dynamicEntities;
	HostMigrationFindDynamicEntities(dynamicEntities);

	CryLog("CGameRules::HostMigrationRemoveDuplicateDynamicEntities(), found %i entities, already know about %i", (uint32)dynamicEntities.size(), (uint32)m_hostMigrationCachedEntities.size());
	// Any entities in the dynamicEntities vector that aren't in the m_hostMigrationCachedEntities vector have been added during a previous migration attempt, need to remove them now
	// Note: entities in the m_hostMigrationCachedEntities vector are removed in OnFinalise
	const int numEntities = dynamicEntities.size();
	for (int i = 0; i < numEntities; ++ i)
	{
		EntityId entityId = dynamicEntities[i];
	
		if (!stl::find(m_hostMigrationCachedEntities, entityId))
		{
			gEnv->pEntitySystem->RemoveEntity(entityId, true);
		}
	}
}
    CCoherentViewListener* CCoherentUISystem::CreateHUDView( std::wstring path )
    {
        m_HudViewListener.reset( new CCoherentHUDViewListener() );

        CRY_ASSERT( m_pUISystem );

        Coherent::UI::ViewInfo info;
        info.Width = gEnv->pRenderer->GetWidth();
        info.Height = gEnv->pRenderer->GetHeight();
        info.UsesSharedMemory = true;
        info.IsTransparent = true;
        info.SupportClickThrough = true;

        if ( m_HudViewListener->GetView() == nullptr )
        {
            m_pUISystem->CreateView( info, path.c_str(), m_HudViewListener.get() );
        }

        m_PlayerEventListener.get()->AddViewListener( m_HudViewListener.get() );
        return m_HudViewListener.get();
    }
Пример #6
0
void CCinematicInput::ReEnablePlayerAfterCutscenes()
{
	CActor* pClientActor = static_cast<CActor*>(g_pGame->GetIGameFramework()->GetClientActor());
	if (pClientActor)
	{
		CRY_ASSERT(pClientActor->GetActorClass() == CPlayer::GetActorClassType());
		CPlayer* pClientPlayer = static_cast<CPlayer*>(pClientActor);

		if (m_bMutedAudioForCutscene)
		{
			uint32 playerFlags = pClientPlayer->GetEntity()->GetFlagsExtended();
			pClientPlayer->GetEntity()->SetFlagsExtended(playerFlags & ~ENTITY_FLAG_EXTENDED_AUDIO_DISABLED);
		}

		pClientPlayer->StateMachineHandleEventMovement( SStateEventCutScene( false ) );
	}

	g_pGameActions->FilterCutsceneNoPlayer()->Enable(false);

	g_pGame->GetIGameFramework()->GetIActionMapManager()->EnableActionMap( "player_cine" , false );
}
Пример #7
0
bool CFlowGraphDebugger::HasBreakpoint(IFlowGraphPtr pFlowGraph, const SFlowAddress& addr) const
{
	CRY_ASSERT(NULL != pFlowGraph);

	if (!pFlowGraph)
		return false;

	const SBreakPointPortInfo* breakpointInfo = GetBreakpointInfo(pFlowGraph, addr);

	if (breakpointInfo)
	{
		return true;
	}
	else
	{
		// no breakpoints at all for this flownode
		return false;
	}

	return false;
}
Пример #8
0
void SDeclareExplosiveObjectState::SerializeWith( TSerialize ser )
{
	LOGBREAK("SDeclareExplosiveObjectState: %s", ser.IsReading() ? "Reading:" : "Writing");

	ser.Value("breakId", breakId, 'brId');
	ser.Value("isEnt", isEnt);
	if (isEnt)
	{
		if (ser.IsWriting())
			CRY_ASSERT(CCryAction::GetCryAction()->GetGameContext()->GetNetContext()->IsBound(entId));
		ser.Value("entid", entId, 'eid');
		ser.Value("entpos", entPos);
		ser.Value("entrot", entRot);
		ser.Value("entscale", entScale);
	}
	else
	{
		ser.Value("eventPos", eventPos);
		ser.Value("hash", hash);
	}
}
Пример #9
0
//------------------------------------------------------------------------
void CInventory::SetAmmoCount(IEntityClass* pAmmoType, int count)
{
	int capacity = GetAmmoCapacity(pAmmoType);
	CRY_ASSERT(pAmmoType);
	if (pAmmoType)
	{
		if (capacity > 0)
			m_stats.ammoInfo[pAmmoType].SetCount(min(count, capacity));
		else
			m_stats.ammoInfo[pAmmoType].SetCount(count);
	}

	TListenerVec::iterator iter = m_listeners.begin();
	m_iteratingListeners = true;
	while (iter != m_listeners.end())
	{
		(*iter)->OnSetAmmoCount(pAmmoType, count);
		++iter;
	}
	m_iteratingListeners = false;
}
Пример #10
0
	ILightSource* CEffectsController::GetLightSource(const TAttachedEffectId effectId) const
	{
		CRY_ASSERT(m_pOwnerEntity);

		TAttachedEffects::const_iterator effectCit = std::find(m_attachedEffects.begin(), m_attachedEffects.end(), effectId);

		if (effectCit != m_attachedEffects.end()) 
		{
			const SEffectInfo &effectInfo = *effectCit;

			if (effectInfo.entityEffectSlot >= 0)
			{
				SEntitySlotInfo slotInfo;
				if(m_pOwnerEntity->GetSlotInfo(effectInfo.entityEffectSlot, slotInfo) && slotInfo.pLight)
				{
					return slotInfo.pLight;
				}
			}

			if (effectInfo.characterEffectSlot >= 0)
			{
				SEntitySlotInfo slotInfo;
				if (m_pOwnerEntity->GetSlotInfo(effectInfo.characterEffectSlot, slotInfo) && slotInfo.pCharacter)
				{
					IAttachmentManager *pAttachmentManager = slotInfo.pCharacter->GetIAttachmentManager();
					IAttachment *pAttachment = pAttachmentManager->GetInterfaceByName(effectInfo.helperName.c_str());
					if (pAttachment)
					{
						IAttachmentObject *pAttachmentObject = pAttachment->GetIAttachmentObject();
						if (pAttachmentObject != NULL && (pAttachmentObject->GetAttachmentType() == IAttachmentObject::eAttachment_Light))
						{
							return static_cast<CLightAttachment *>(pAttachmentObject)->GetLightSource();
						}
					}
				}
			}
		}

		return NULL;
	}
void CGameLobbyManager::EthernetStateCallback(UCryLobbyEventData eventData, void *arg)
{
	if(eventData.pEthernetStateData)
	{
		CryLog("[GameLobbyManager] EthernetStateCallback state %d", eventData.pEthernetStateData->m_curState);

		CGameLobbyManager *pGameLobbyManager = (CGameLobbyManager*)arg;
		CRY_ASSERT(pGameLobbyManager);

		if(g_pGame->HasExclusiveControllerIndex())
		{
			ECableState newState = eventData.pEthernetStateData->m_curState;







			// cable has been removed, clear dialog
			if ((newState == eCS_Unplugged) || (newState == eCS_Disconnected))
			{
				CErrorHandling *pErrorHandling = CErrorHandling::GetInstance();
				if (pErrorHandling)
				{
					pErrorHandling->OnFatalError(CErrorHandling::eFE_EthernetCablePulled);
				}







			}
		}

		pGameLobbyManager->m_isCableConnected = (eventData.pEthernetStateData->m_curState == eCS_Connected) ? true : false;
	}
}
Пример #12
0
bool AutoEnum_GetEnumValFromString(const char *inString, const char **inArray, int arraySize, int *outVal)
{
	bool  done = false;

	if(inString && (inString[0] != '\0'))   // avoid a load of work if the string's NULL or empty
	{
		CRY_ASSERT(arraySize > 0);

		char  skipThisString[32];
		size_t  skipChars = cry_copyStringUntilFindChar(skipThisString, inArray[0], sizeof(skipThisString), '_');

#if DO_PARSE_BITFIELD_STRING_LOGS
		CryLog("AutoEnum_GetEnumValFromString: Parsing '%s' (skipping first %d chars '%s%s' of each string in array)", inString, skipChars, skipThisString, skipChars ? "_" : "");
#endif

		for(int i=0; i<arraySize; i++)
		{
#if DO_PARSE_BITFIELD_STRING_LOGS
			CryLog("AutoEnum_GetEnumValFromString: Searching... Enum val %d = '%s'", i, (inArray[i] + skipChars));
#endif

			if(0 == stricmp((inArray[i] + skipChars), inString))
			{
#if DO_PARSE_BITFIELD_STRING_LOGS
				CryLog("AutoEnum_GetEnumValFromString: Flag '%s' found in enum list as value %d", inString, i);
#endif

				if(outVal)
					(*outVal) = i;

				done = true;
				break;
			}
		}

		CRY_ASSERT_MESSAGE(done, string().Format("No flag called '%s' in enum list", inString));
	}

	return done;
}
Пример #13
0
void CGameLobbyManager::EthernetStateCallback(UCryLobbyEventData eventData, void *arg)
{
	if(eventData.pEthernetStateData)
	{
		CryLog("[GameLobbyManager] EthernetStateCallback state %d", eventData.pEthernetStateData->m_curState);

		CGameLobbyManager *pGameLobbyManager = (CGameLobbyManager*)arg;
		CRY_ASSERT(pGameLobbyManager);

		if(g_pGame->HasExclusiveControllerIndex())
		{
			ECableState newState = eventData.pEthernetStateData->m_curState;
#if 0 // old frontend
			if(pMPMenuHub)
			{
				pMPMenuHub->EthernetStateChanged(newState);
			}
#endif

			// cable has been removed, clear dialog
			if ((newState == eCS_Unplugged) || (newState == eCS_Disconnected))
			{
				CErrorHandling *pErrorHandling = CErrorHandling::GetInstance();
				if (pErrorHandling)
				{
					pErrorHandling->OnFatalError(CErrorHandling::eFE_EthernetCablePulled);
				}
#if 0 // old frontend
				CWarningsManager *pWM = g_pGame->GetWarnings();
				if(pWM)
				{
					pWM->RemoveWarning("ChatRestricted");
				}
#endif
			}
		}

		pGameLobbyManager->m_isCableConnected = (eventData.pEthernetStateData->m_curState == eCS_Connected) ? true : false;
	}
}
Пример #14
0
void CWeaponStats::SetStatsFromFiremode(const SWeaponStatsData *pStats)
{
	const int numStats = eWeaponStat_NumStats;

	if (!pStats) // Valid, notifies clear
	{
		for (int i = 0; i < numStats; i++)
		{
			m_weaponStats[i].firemodeModifier = 0;
		}
	}
	else
	{
		CRY_ASSERT(m_weaponStats.size() == pStats->stats.size() && m_weaponStats.size() == eWeaponStat_NumStats);
		for (int i = 0; i < numStats; i++)
		{
			m_weaponStats[i].firemodeModifier = pStats->stats[i];
		}
	}

	UpdateTotalValue();
}
void CAnimatedCharacter::SetBlendWeightParam(const EMotionParamID motionParamID, const float value, const uint8 targetFlags/* = eBWPT_All*/)
{
	if (motionParamID >= eMotionParamID_BlendWeight && motionParamID <= eMotionParamID_BlendWeight_Last)
	{ //only allowed on the generic blend weights params

		IEntity* pEntity = GetEntity();
		CRY_ASSERT(pEntity);

		if (targetFlags & eBWPT_FirstPersonSkeleton)
		{
			if (ICharacterInstance* pCharacterInstance = pEntity->GetCharacter(0))
			{
				if (ISkeletonAnim* pSkeletonAnim = pCharacterInstance->GetISkeletonAnim())
				{
					pSkeletonAnim->SetDesiredMotionParam(motionParamID, value, 0.0f);
				}
			}
		}

		if (targetFlags & eBWPT_ShadowSkeleton)
		{
			if (m_hasShadowCharacter)
			{
				if (ICharacterInstance* pShadowCharacter = pEntity->GetCharacter(m_shadowCharacterSlot))
				{
					if (ISkeletonAnim* pShadowSkeletonAnim = pShadowCharacter->GetISkeletonAnim())
					{
						pShadowSkeletonAnim->SetDesiredMotionParam(motionParamID, value, 0.0f);
					}
				}
			}
		}

	} 
	else
	{
		CryLogAlways("[CryAnimation] ERROR: motionParam that was sent: %d is not within allowed range of blendweights %d to %d", motionParamID, eMotionParamID_BlendWeight, eMotionParamID_BlendWeight_Last);
	}
}
Пример #16
0
// ----------------------------------------------------------------------------
CExactPositioning::ETriggerState CExactPositioning::StatePreparing_HandleEvent( SStateMachineEvent& event )
{
	switch( event.type )
	{
	case ESME_Enter:
		m_pExactPositioningTarget->preparing = true;
		CRY_ASSERT( !m_pExactPositioningTarget->activated );

		// we're very close, start forcing the character to the right point

		// Adjust the positionWidth & positionDepth, replacing the prepareRadius by 0.1m in the calculation of positionWidth/Depth
		// so instead of going towards the big box of 3.1m width/depth, we now go to a small box of 0.1m width/depth?

		m_pExactPositioningTarget->positionWidth = 0.1f + m_actorTargetParams.startWidth; // NOTE: the positionWidth gets forced to 0.1f in SetTriggerState, should we do this too??
		m_pExactPositioningTarget->positionDepth = 0.1f;

		// NOTE: the box size doesn't seem consistent with the positionWidth/positionDepth above. Just mimicking ExactPositioning here. Thankfully the values above are not used anywhere. *sigh*
		m_exactPositioningTrigger.ResetRadius( Vec3( m_pExactPositioningTarget->startWidth, 0.0f, 20.0f ), m_pExactPositioningTarget->orientationTolerance ); // note: for the orientationTolerance it would go back to the original request, which I don't store anymore, possibly because the animationTarget contained 0 tolerance until now. What does it mean????!!!

		break;

	case ESME_Update:
		if ( m_pPendingRequest.get() )
			return eTS_Disabled;

		if ( m_pExactPositioningTarget->pAction->GetStatus() != IAction::None )
			return eTS_Disabled;

		UpdateAnimationTrigger(); // NOTE: because Update() was already called in the ResetRadius during Enter, it will be called twice during one frame

		//	[our first AnimationTrigger got reached, which is a box of 0.1m (sometimes +startWidth) around the adjusted trigger position]
		if ( m_exactPositioningTrigger.IsTriggered() )
			return eTS_FinalPreparation;

		break;
	};

	return m_state;
}
Пример #17
0
void CLedgeManager::UpdateLedgeMarkers( const EntityId entityId, const SLedgeMarker* pMarkersArray, const uint32 markerCount )
{
	if (m_editorManager.IsInEditorMode())
	{
		m_editorManager.UpdateLedgeMarkers( entityId, pMarkersArray, markerCount );
	}
	else
	{
		SLedgeObject* pLedgeObject = m_levelLedges.FindLedgeForEntity( entityId );

		if ((pLedgeObject != NULL) && (pLedgeObject->m_markersCount == markerCount))
		{
			const uint32 endMarkerIdx = pLedgeObject->m_markersStartIdx + pLedgeObject->m_markersCount;
			CRY_ASSERT( endMarkerIdx <= m_levelLedges.m_markerCount );

			for (uint32 markerIdx = pLedgeObject->m_markersStartIdx, idx = 0; markerIdx < endMarkerIdx; ++markerIdx, ++idx)
			{
				m_levelLedges.m_pMarkers[markerIdx] = pMarkersArray[idx];
			}
		}
	}
}
Пример #18
0
bool CBoundingContainer::ShouldHide( const EntityId entityId, const IEntity* pEntity )
{
	CRY_ASSERT( pEntity != NULL );
	
	// First check if is an item
	const IItem* pItem = g_pGame->GetIGameFramework()->GetIItemSystem()->GetItem( entityId );
	if ( pItem != NULL)
	{
		return true;
	}

	// Try hardcoded entity types
	static IEntityClass* s_pInteractiveEntityClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("InteractiveEntity");

	IEntityClass* pEntityClass = pEntity->GetClass();
	if (pEntityClass != NULL && pEntityClass == s_pInteractiveEntityClass)
	{
		return true;
	}

	return false;
}
Пример #19
0
void CPlayerVisTable::RemoveNthEntity(const VisEntryIndex n)
{
	CRY_ASSERT(m_numUsedVisTableEntries > 0);

	//NOTE: This does not have to be synched as the access will be on this thread.

	const VisEntryIndex swapIndex = m_numUsedVisTableEntries - 1;

	if(m_visTableEntries[n].flags & eVF_Pending)
	{
		RemovePendingDeferredLinetest(n);
	}

	if(m_visTableEntries[swapIndex].flags & eVF_Pending && n != swapIndex)
	{
		UpdatePendingDeferredLinetest(swapIndex, n);
	}

	m_visTableEntries[n] = m_visTableEntries[swapIndex];
	m_visTableEntries[swapIndex].Reset();
	m_numUsedVisTableEntries--;
}
//--------------------------------------------------------
EntityId CMelee::GetNearestTarget()
{
	CActor* pOwnerActor = m_pWeapon->GetOwnerActor();
	if(pOwnerActor == NULL || (gEnv->bMultiplayer && m_slideKick))
		return 0;

	CRY_ASSERT(pOwnerActor->IsClient());

	IMovementController* pMovementController = pOwnerActor->GetMovementController();
	if (!pMovementController)
		return 0;

	SMovementState moveState;
	pMovementController->GetMovementState(moveState);

	const Vec3 playerDir = moveState.aimDirection;
	const Vec3 playerPos = moveState.eyePosition;
	const float range = g_pGameCVars->pl_melee.melee_snap_target_select_range;
	const float angleLimit = cos_tpl(DEG2RAD(g_pGameCVars->pl_melee.melee_snap_angle_limit));

	return m_collisionHelper.GetBestAutoAimTargetForUser(pOwnerActor->GetEntityId(), playerPos, playerDir, range, angleLimit);
}
void CGameVolume_Water::AwakeAreaIfRequired( bool forceAwake )
{
	if (gEnv->IsEditing())
		return;

	if ((m_segments[0].m_pWaterArea == NULL) || (m_awakeAreaWhenMoving == false))
		return;

	const float thresholdSqr = (2.0f * 2.0f);
	const float movedDistanceSqr = (m_baseMatrix.GetTranslation() - m_lastAwakeCheckPosition).len2();
	if ((forceAwake == false) && (movedDistanceSqr <= thresholdSqr))
		return;

	m_lastAwakeCheckPosition = m_baseMatrix.GetTranslation();

	WaterSegments::iterator iter = m_segments.begin();
	WaterSegments::iterator end = m_segments.end();
	while(iter != end)
	{
		CRY_ASSERT(iter->m_pWaterArea);
		pe_status_pos areaPos;
		iter->m_pWaterArea->GetStatus( &areaPos );

		const Vec3 areaBoxCenter = areaPos.pos;
		IPhysicalEntity **pEntityList = NULL;
	
		const int numberOfEntities = gEnv->pPhysicalWorld->GetEntitiesInBox( areaBoxCenter + areaPos.BBox[0], areaBoxCenter + areaPos.BBox[1], pEntityList, ent_sleeping_rigid|ent_rigid );
	
		pe_action_awake awake;
		awake.bAwake = true;
	
		for (int i = 0; i < numberOfEntities; ++i)
		{
			pEntityList[i]->Action( &awake );
		}

		++iter;
	}
}
Пример #22
0
float CCameraFlight::GetCourseLength() const
{
	if(m_fCourseLengthOverwrite > 0.0f)
		return m_fCourseLengthOverwrite;

	float fMoveDistance = 0.0f;
	Vec3 vTempPos = m_cameraCourse[0].m_vCamPos;

	CRY_ASSERT(!m_cameraCourse.empty());
	std::vector<SCameraFlightPoint>::const_iterator iter = m_cameraCourse.begin();
	// iterate to the second position
	++iter;

	std::vector<SCameraFlightPoint>::const_iterator end = m_cameraCourse.end();
	for(; iter != end; ++iter)
	{
		fMoveDistance += (iter->m_vCamPos - vTempPos).len();
		vTempPos = iter->m_vCamPos;
	}

	return fMoveDistance;
}
Пример #23
0
// Description:
//
// Arguments:
//
// Return:
//
bool CPersonalRangeSignaling::Init( EntityId Id )
{
  CRY_ASSERT( m_bInit == false );

  m_EntityId = Id;
  m_bInit = true;

  // Enabled state starts off matching proxy's state
  IAIActorProxy* pAIProxy = GetEntityAIProxy(m_EntityId);
  SetEnabled(pAIProxy && pAIProxy->IsEnabled());

  if( GetActor() == NULL )
  {
    m_bInit = false;
  }
  else
  {
	SetListener(true);
  }

  return( m_bInit );
}
Пример #24
0
void CCameraFlight::SetCameraCourse(const std::vector<Vec3> &cPositions, const Vec3 &vLookAt, bool bLookAtRelative, const Vec3 &vRefPos, IEntity *pRefEntity)
{
	CRY_ASSERT(cPositions.size() > 1);

	const int iNumPoints = cPositions.size();
	m_cameraCourse.resize(iNumPoints);
	m_tempCourseA.resize(iNumPoints);
	m_tempCourseB.resize(iNumPoints);

	for(int i = 0; i < iNumPoints; ++i)
	{
		const Vec3 &vPos = cPositions[i];
		m_cameraCourse[i].m_vCamPos = vPos;
		m_cameraCourse[i].m_vCamLookAt = (bLookAtRelative)?vPos+vLookAt:vLookAt;
	}

	//this is a linear "track"
	if(m_cameraCourse.size() == 2)
		m_cameraCourse.push_back(m_cameraCourse[1]);

	InitFlight(vRefPos, pRefEntity);
}
Пример #25
0
//--------------------------------------------------------------------------------------------------
// Name: QueueMaterialEffect
// Desc: Queues material effect and sets off a deferred linetest for later processing
//--------------------------------------------------------------------------------------------------
void CExplosionGameEffect::QueueMaterialEffect(SExplosionContainer &explosionContainer)
{
	ExplosionInfo explosionInfo = explosionContainer.m_explosionInfo;

	// If an effect was already specified, don't use MFX
	if(explosionInfo.pParticleEffect)
		return;

	const int intersectionObjTypes = ent_all|ent_water;    
	const unsigned int intersectionFlags = rwi_stop_at_pierceable|rwi_colltype_any;

	CRY_ASSERT(explosionContainer.m_mfxInfo.m_rayId == 0);

	if(explosionInfo.impact)
	{
		Vec3 explosionDir = explosionInfo.impact_velocity.normalized();
		
		explosionContainer.m_mfxInfo.m_rayId = g_pGame->GetRayCaster().Queue(
			RayCastRequest::HighPriority,
			RayCastRequest(explosionInfo.pos-explosionDir*0.1f, explosionDir,
			intersectionObjTypes,
			intersectionFlags),
			functor(explosionContainer.m_mfxInfo, &SDeferredMfxExplosion::OnRayCastDataReceived));
	}
	else
	{
		const Vec3 explosionDir(0.0f, 0.0f, -g_pGameCVars->g_explosion_materialFX_raycastLength);

		explosionContainer.m_mfxInfo.m_rayId = g_pGame->GetRayCaster().Queue(
			RayCastRequest::HighPriority,
			RayCastRequest(explosionInfo.pos, explosionDir,
			intersectionObjTypes,
			intersectionFlags),
			functor(explosionContainer.m_mfxInfo, &SDeferredMfxExplosion::OnRayCastDataReceived));
	}

	explosionContainer.m_mfxInfo.m_state = eDeferredMfxExplosionState_Dispatched;
}
void CBodyDestrutibilityInstance::ReplaceMaterial( IEntity& characterEntity, ICharacterInstance& characterInstance, IMaterial& replacementMaterial )
{
	IMaterial* pCurrentMaterial = characterInstance.GetIMaterial();
	if ((pCurrentMaterial != NULL) && stricmp(pCurrentMaterial->GetName(), replacementMaterial.GetName()))
	{
		characterEntity.SetSlotMaterial(0, &replacementMaterial);
	}

	const bool storeOriginalReplacementMaterials = m_originalMaterials.empty();

	IAttachmentManager *pAttachmentManager = characterInstance.GetIAttachmentManager();
	CRY_ASSERT(pAttachmentManager);

	const int attachmentCount = pAttachmentManager->GetAttachmentCount();
	for (int attachmentIdx = 0; attachmentIdx < attachmentCount; ++attachmentIdx)
	{
		IAttachmentObject *pAttachmentObject = pAttachmentManager->GetInterfaceByIndex(attachmentIdx)->GetIAttachmentObject();
		if (pAttachmentObject)
		{
			IMaterial* pAttachMaterial = (IMaterial*)pAttachmentObject->GetBaseMaterial();
			if ((pAttachMaterial != NULL) && stricmp(pAttachMaterial->GetName(), replacementMaterial.GetName()))
			{
				if (storeOriginalReplacementMaterials)
				{
					IMaterial* pOriginalReplacementMaterial = pAttachmentObject->GetReplacementMaterial();
					if(pOriginalReplacementMaterial != NULL)
					{
						pOriginalReplacementMaterial->AddRef();
						m_originalMaterials.push_back(TAttachmentMaterialPair((uint32)attachmentIdx, pOriginalReplacementMaterial));
					}
				}

				pAttachmentObject->SetReplacementMaterial(&replacementMaterial);
			}
		}

	}
}
Пример #27
0
SHomingMissileParams::SHomingMissileParams( const XmlNodeRef& paramsNode )
: m_accel(10.0f)
, m_turnSpeed(2.0f)
, m_maxSpeed(20.0f)
, m_cruiseAltitude(100.0f)
, m_alignAltitude(50.0f)
, m_descendDistance(50.0f)
, m_lazyness(0.35f)
, m_bTracksChaff (false)
, m_cruise(true)
, m_controlled(false)
, m_autoControlled(false)
, m_detonationRadius(0.0f)
, m_lockedTimer(0.2f)
, m_maxTargetDistance(200.0f)
, m_cruiseActivationTime(0.0f)
{
	CRY_ASSERT(paramsNode != NULL);

	CGameXmlParamReader reader(paramsNode);

	reader.ReadParamValue<float>("cruise_altitude", m_cruiseAltitude);
	reader.ReadParamValue<float>("accel", m_accel);
	reader.ReadParamValue<float>("turn_speed", m_turnSpeed);
	reader.ReadParamValue<float>("max_speed", m_maxSpeed);
	reader.ReadParamValue<float>("align_altitude", m_alignAltitude);
	reader.ReadParamValue<float>("descend_distance", m_descendDistance);
	reader.ReadParamValue<float>("max_target_distance", m_maxTargetDistance);
	reader.ReadParamValue<bool>("cruise", m_cruise);
	reader.ReadParamValue<bool>("controlled", m_controlled);
	reader.ReadParamValue<bool>("autoControlled",m_autoControlled);
	reader.ReadParamValue<float>("lazyness",m_lazyness);
	reader.ReadParamValue<float>("initial_delay",m_lockedTimer);
	reader.ReadParamValue<float>("detonation_radius",m_detonationRadius);
	reader.ReadParamValue<bool>("tracks_chaff", m_bTracksChaff);
	reader.ReadParamValue<float>("cruiseActivationTime", m_cruiseActivationTime);
	m_launchEffect = reader.ReadParamValue("launch_effect");
}
Пример #28
0
// ----------------------------------------------------------------------------
CExactPositioning::ETriggerState CExactPositioning::StateConsidering_HandleEvent( SStateMachineEvent& event )
{
	switch( event.type )
	{
	case ESME_Enter:
		if ( !m_pPendingRequest.get() ) // paranoia
		{
			CRY_ASSERT(false);
			return eTS_Disabled;
		}

		CommitPendingRequest();

		break;

	case ESME_Update:
		if ( m_pPendingRequest.get() )
			return eTS_Disabled;

		if ( m_pExactPositioningTarget->pAction->GetStatus() != IAction::None )
			return eTS_Disabled;

		//	--> if (startRadiusSq <= square(END_CONSIDERING_DISTANCE) && m_ds.pathfindRetryTimer <= 0.0f)
		//	[within 15m AND (we're not waiting for a re-pathfind??)]
		Vec3 worldPos = m_pAnimatedCharacter->GetEntity()->GetWorldPos();
		float startRadiusSq = worldPos.GetSquaredDistance( m_pExactPositioningTarget->location.t );

		const bool withinConsideringDistance = ( startRadiusSq <= square( END_CONSIDERING_DISTANCE ) );
		if ( withinConsideringDistance )
			return eTS_Waiting;

		UpdateAnimationTrigger(); // Mimicking the old exact positioning here: is this really necessary? we're not even checking it...

		break;
	};

	return m_state;
}
void CGameAchievements::GiveAchievement(int achievement)
{
	if(AllowAchievement())
	{
		CPersistantStats::GetInstance()->OnGiveAchievement(achievement);

		ICryLobby* pLobby = gEnv->pNetwork->GetLobby();
		IPlatformOS* pOS = gEnv->pSystem->GetPlatformOS();
		if(pLobby != NULL && pOS != NULL)
		{
			ICryReward* pReward = pLobby->GetReward();
			if(pReward)
			{
				unsigned int user = g_pGame->GetExclusiveControllerDeviceIndex();
				if(user != IPlatformOS::Unknown_User)
				{
					uint32 achievementId = achievement + ACHIEVEMENT_STARTINDEX;

					//-- Award() only puts awards into a queue to be awarded.
					//-- This code here only asserts that the award was added to the queue successfully, not if the award was successfully unlocked.
					//-- Function has been modified for a CryLobbyTaskId, callback and callback args parameters, similar to most other lobby functions,
					//-- to allow for callback to trigger when the award is successfully unlocked (eCLE_Success) or failed to unlock (eCLE_InternalError).
					//-- In the case of trying to unlock an award that has already been unlocked, the callback will return eCLE_Success.
					//-- Successful return value of the Award function has been changed from incorrect eCRE_Awarded to more sensible eCRE_Queued.
					CRY_TODO(3,9,2010, "Register a callback to inform game when queued award is processed successfully or failed.");

					ECryRewardError error = pReward->Award(user, achievementId, NULL, NULL, NULL);
					CryLog("Award error %d", error);
					CRY_ASSERT(error == eCRE_Queued);
				}
			}
		}
	}
	else
	{
		CryLog("Not Awarding achievement - have been disabled");
	}
}
///Getline wrapper to break on newlines as adapted from the old AI Code Coverage Manager
int CCodeCheckpointDebugMgr::GetLine( char * pBuff, FILE * fp )
{	
	CRY_ASSERT(pBuff && fp);

	/// Wraps fgets to remove newlines and use correct buffer/string lengths

	/// Must use CryPak FGets on CryPak files
	/// Will retrieve up to the next newline character in the file buffer.
	if (!gEnv->pCryPak->FGets( pBuff, BUFF_SIZE, fp ))
		return 0;

	/// Convert newlines to \0 and discover length
	int i=0;
	int nLimit = LABEL_LENGTH + 1;
	for (; i < nLimit ; i++)
	{
		char c = pBuff[i];
		if (c == '\n' || c == '\r' || c== '\0') 
			break;
	}

	/// If i == LABEL_LENGTH, the string was of maximum length
	/// If i == LABEL_LENGTH + 1, the string was too long
	if (i == nLimit)
	{
		// Malformed - fail
		pBuff[--i] = '\0';
		return 0;
	}

	/// Overwrite the last character (usually line terminator) with string delimiter
	pBuff[i] = '\0';

	if ( i == 0 )
		return 0;

	return i+1;
}