Ejemplo n.º 1
0
void CStimResponseCollection::Restore(idRestoreGame *savefile)
{
	int num;

	savefile->ReadInt(num);
	m_Stims.SetNum(num);
	for (int i = 0; i < num; i++)
	{
		// Allocate a new stim class (according to the type info)
		int typeInt;
		savefile->ReadInt(typeInt);
		m_Stims[i] = CStimPtr(new CStim(NULL, static_cast<StimType>(typeInt), -1));
		m_Stims[i]->Restore(savefile);
	}

	savefile->ReadInt(num);
	m_Responses.SetNum(num);
	for (int i = 0; i < num; i++)
	{
		// Allocate a new response class (according to the type info)
		int typeInt;
		savefile->ReadInt(typeInt);
		m_Responses[i] = CResponsePtr(new CResponse(NULL, static_cast<StimType>(typeInt), -1));
		m_Responses[i]->Restore(savefile);
	}
}
CStimPtr CStimResponseCollection::GetStimByType( StimType type ) {
	for( int i = 0; i < m_Stims.Num(); ++i ) {
		if( m_Stims[i]->m_StimTypeId == type ) {
			return m_Stims[i];
		}
	}
	return CStimPtr();
}
CStimPtr CStimResponseCollection::CreateStim( idEntity *p_owner, StimType type ) {
	/*	grayman #3462 - undo the following change

		// grayman #2862 - don't create a visual stim for a door that's not marked shouldBeClosed

		if (( type == ST_VISUAL ) &&
			( idStr::Cmp( p_owner->spawnArgs.GetString("AIUse"), AIUSE_DOOR ) == 0 ) &&
			( !p_owner->spawnArgs.GetBool("shouldBeClosed","0" ) ) )
		{
			return CStimPtr(); // null result
		}
	 */
	// Increase the counter to the next ID
	gameLocal.m_HighestSRId++;
	DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "Creating Stim with ID: %d\r", gameLocal.m_HighestSRId );
	DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "Creating CStim\r" );
	return CStimPtr( new CStim( p_owner, type, gameLocal.m_HighestSRId ) );
}