예제 #1
0
//--------------------------------------------------------------
// Name:        setupRushEnemyFailed()
// Class:       GeneralCombatWithMeleeWeapon
//
// Description: Failure Handler for _setupRushEnemy
//
// Parameters:  Actor &self
//
// Returns:     None
//--------------------------------------------------------------
void GeneralCombatWithMeleeWeapon::setupRushEnemyFailed ( Actor & )
{
 	if ( !_allowRushFailure )
		{
		SetFailureReason( "RushToEnemy Failed" );
		_state = GENERAL_COMBAT_MELEE_FAILED;
		return;
		}

	_nextRushAttemptTime = level.time + G_Random( 0.25 ) + 1.25f;
	_state = GENERAL_COMBAT_MELEE_SELECT_STATE;   
}
예제 #2
0
파일: pns_router.cpp 프로젝트: chgans/kicad
bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer )
{
    m_clearanceResolver->UseDpGap( false );

    switch( m_mode )
    {
    case PNS_MODE_ROUTE_SINGLE:
        m_placer = new PNS_LINE_PLACER();
        break;
    case PNS_MODE_ROUTE_DIFF_PAIR:
        m_placer = new PNS_DIFF_PAIR_PLACER();
        m_clearanceResolver->UseDpGap( true );
        break;
    case PNS_MODE_TUNE_SINGLE:
        m_placer = new PNS_MEANDER_PLACER();
        break;
    case PNS_MODE_TUNE_DIFF_PAIR:
        m_placer = new PNS_DP_MEANDER_PLACER();
        break;
    case PNS_MODE_TUNE_DIFF_PAIR_SKEW:
        m_placer = new PNS_MEANDER_SKEW_PLACER();
        break;

    default:
        return false;
    }

    // FIXME: it's not our business to set the minimum size here
    m_sizes.SetMinimumTrackWidth(m_board->GetDesignSettings().m_TrackMinWidth);

    m_placer->SetInitialWorld( m_world );
    m_placer->UpdateSizeSettings( m_sizes );
    m_placer->SetLayer( aLayer );
    m_placer->SetDebugDecorator( m_debugDecorator );

    VECTOR2I startPoint = aP;
    bool dummy;
    if (SnappingEnabled())
        startPoint = SnapToItem( aStartItem, startPoint, dummy);

    bool rv = m_placer->Start( startPoint, aStartItem );
    SetFailureReason(m_placer->FailureReason());

    if( !rv )
        return false;

    m_state = ROUTE_TRACK;
    return rv;
}
예제 #3
0
//--------------------------------------------------------------
// Name:		updateEnemy()
// Class:		CloseInOnEnemyWhileFiringWeapon
//
// Description:	Sets our _currentEnemy
//
// Parameters:	None
//
// Returns:		None
//--------------------------------------------------------------
void CloseInOnEnemyWhileFiringWeapon::updateEnemy()
{
	Entity *currentEnemy = _self->enemyManager->GetCurrentEnemy();
	if ( !currentEnemy )
		{
		_self->enemyManager->FindHighestHateEnemy();
		currentEnemy = _self->enemyManager->GetCurrentEnemy();
		if ( !currentEnemy )
			{
			SetFailureReason( "CloseInOnEnemyWhileFiringWeapon::updateEnemy -- No Enemy" );
			transitionToState( CIWF_FAILED );
			}
			
		}

	_currentEnemy = currentEnemy;	
}
예제 #4
0
//--------------------------------------------------------------
// Name:		updateEnemy()
// Class:		StationaryFireCombat
//
// Description:	Sets our _currentEnemy
//
// Parameters:	None
//
// Returns:		None
//--------------------------------------------------------------
void StationaryFireCombat::updateEnemy()
{
	Entity *currentEnemy = _self->enemyManager->GetCurrentEnemy();
	if ( !currentEnemy )
		{
		_self->enemyManager->FindHighestHateEnemy();
		currentEnemy = _self->enemyManager->GetCurrentEnemy();
		if ( !currentEnemy )
			{
			SetFailureReason( "STATIONARY_FIRE_FAILED::updateEnemy -- No Enemy" );
			transitionToState( STATIONARY_FIRE_FAILED );
			return;
			}
			
		}

	_currentEnemy = currentEnemy;
	//_self->turnTowardsEntity( _currentEnemy, 0.0f );	
}
예제 #5
0
//--------------------------------------------------------------
// Name:		updateEnemy()
// Class:		GeneralCombatWithRangedWeapon
//
// Description:	Sets our _currentEnemy
//
// Parameters:	None
//
// Returns:		None
//--------------------------------------------------------------
void GeneralCombatWithRangedWeapon::updateEnemy()
{
	
	Entity *currentEnemy = _self->enemyManager->GetCurrentEnemy();
	if ( !currentEnemy )
		{
		_self->enemyManager->FindHighestHateEnemy();
		currentEnemy = _self->enemyManager->GetCurrentEnemy();
		if ( !currentEnemy )
			{
			SetFailureReason( "GeneralCombatWithRangedWeapon::updateEnemy -- No Enemy" );
			transitionToState( GC_WRW_FAILED );
			}
			
		}

	_currentEnemy = currentEnemy;
	_self->SetHeadWatchTarget( _currentEnemy );
	setupRotate();
}
예제 #6
0
//--------------------------------------------------------------
// Name:		updateEnemy()
// Class:		CorridorCombatWithRangedWeapon
//
// Description:	Sets our _currentEnemy
//
// Parameters:	None
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::updateEnemy()
{
	if ( level.time < _enemyUpdateTime )
		return;

	Entity *currentEnemy = _self->enemyManager->GetCurrentEnemy();
	if ( !currentEnemy )
		{
		_self->enemyManager->FindHighestHateEnemy();
		currentEnemy = _self->enemyManager->GetCurrentEnemy();
		if ( !currentEnemy )
			{
			SetFailureReason( "CorridorCombatWithRangedWeapon::updateEnemy -- No Enemy" );
			transitionToState( CORRIDORCOMBAT_WRW_FAILED );
			}
			
		}

	_currentEnemy = currentEnemy;
	_enemyUpdateTime = level.time + G_Random() + 3.0f; 
	setupRotate();
}
예제 #7
0
//--------------------------------------------------------------
// Name:		failureStateAim()
// Class:		TorsoAimAndFireWeapon
//
// Description:	Failure Handler for the Failure State
//
// Parameters:	const str& failureReason
//
// Returns:		None
//--------------------------------------------------------------
void TorsoAimAndFireWeapon::failureStateAim( const str& failureReason )
{
	SetFailureReason( failureReason );
}
예제 #8
0
//--------------------------------------------------------------
// Name:        Evaluate()
// Class:       GeneralCombatWithMeleeWeapon
//
// Description: Returns True Or False, and is run every frame
//              that the behavior
//
// Parameters:  Actor &self
//
// Returns:     True or False
//--------------------------------------------------------------
BehaviorReturnCode_t GeneralCombatWithMeleeWeapon::Evaluate ( Actor &self )
{      
	Entity *currentEnemy;

	// Make sure our rotate and headwatch targets are up to date
	if ( _state != GENERAL_COMBAT_MELEE_ATTACK && _state != GENERAL_COMBAT_MELEE_CHANGE_POSTURE )
		setUpRotate( self );        
		
	faceEnemy( self );
	setHeadWatchTarget( self );


	currentEnemy = self.enemyManager->GetCurrentEnemy();

	if (currentEnemy && _maxDistanceToEngage && !self.WithinDistance( currentEnemy, _maxDistanceToEngage))
		{
		self.enemyManager->ClearCurrentEnemy();
		SetFailureReason( "My Current Enemy is farther away than my _maxDistanceToEngage\n" );
		return BEHAVIOR_FAILED; // I may have an enemy, but he's too far away.  Ignore him.
		}
 
	if ( _state == GENERAL_COMBAT_MELEE_FAILED )
		return BEHAVIOR_FAILED;

	if ( currentEnemy && !self.WithinDistance( currentEnemy , _meleeDistance ) && level.time > _nextRushAttemptTime )
		{
		setupRushEnemy( self );
		_state = GENERAL_COMBAT_MELEE_RUSH_ENEMY;      
		}

	switch ( _state )
		{
		case GENERAL_COMBAT_MELEE_SELECT_STATE:
			//setTorsoAnim( self ); // Breaks the initial attack anim
			selectState( self );
		break;

		case GENERAL_COMBAT_MELEE_RUSH_ENEMY:
			rushEnemy( self );
		break;

		case GENERAL_COMBAT_MELEE_STRAFE:
			setTorsoAnim( self );
			strafe(self);
			setTorsoAnim( self );
		break;

		case GENERAL_COMBAT_MELEE_ATTACK:      
			attack( self );
		break;

		case GENERAL_COMBAT_MELEE_BLOCK:
			block( self );
		break;

		case GENERAL_COMBAT_MELEE_CHANGE_POSTURE:
			changePosture(self);
		break;

		case GENERAL_COMBAT_MELEE_HOLD:
			setTorsoAnim( self );
			hold( self );
		break;

		case GENERAL_COMBAT_MELEE_FAILED:
			return BEHAVIOR_FAILED;
		}

	return BEHAVIOR_EVALUATING; 
}
예제 #9
0
//--------------------------------------------------------------
// Name:		failureStateFindNode
// Class:		GotoCurrentHelperNode
//
// Description:	Failure Handler for State Move To Cover
//
// Parameters:	const str &failureReason
//
// Returns:		None
//--------------------------------------------------------------
void GotoCurrentHelperNode::failureStateFindNode( const str &failureReason )
{
	SetFailureReason( failureReason );
}
예제 #10
0
//--------------------------------------------------------------
// Name:		failureStatePause()
// Class:		StationaryFireCombat
//
// Description:	Failure Handler for our Pause State
//
// Parameters:	const str &failureReason
//
// Returns:		None
//--------------------------------------------------------------
void StationaryFireCombat::failureStateAim( const str &failureReason )
{
	SetFailureReason( failureReason );
}
예제 #11
0
//--------------------------------------------------------------
// Name:		failureStateAttack()
// Class:		StationaryFireCombat
//
// Description:	Failure Handler for Attack State
//
// Parameters:	const str &failureReason
//
// Returns:		None
//--------------------------------------------------------------
void StationaryFireCombat::failureStateAttack( const str &failureReason )
{
	SetFailureReason( failureReason );
	_fireWeapon.End( *_self );
}
예제 #12
0
//--------------------------------------------------------------
// Name:		failureStateAttack()
// Class:		TorsoAimAndFireWeapon
//
// Description: Failure Handler for Attack State
//
// Parameters:	const str& failureReason
//
// Returns:		None
//--------------------------------------------------------------
void TorsoAimAndFireWeapon::failureStateAttack( const str& failureReason )
{
	SetFailureReason( failureReason );
	_fireWeapon.End( *_self );
}
예제 #13
0
//--------------------------------------------------------------
// Name:		failureStateMoveToNode
// Class:		GotoHelperNode
//
// Description:	Failure Handler for State Move To Cover
//
// Parameters:	const str &failureReason
//
// Returns:		None
//--------------------------------------------------------------
void GotoHelperNode::failureStateMoveToNode( const str &failureReason )
{
	SetFailureReason( failureReason );
}
예제 #14
0
//--------------------------------------------------------------
// Name:		failureStateChangePostureDuck()
// Class:		CorridorCombatWithRangedWeapon
//
// Description:	Failure Handler for ChangePostureDuck State
//
// Parameters:	const str &failureReason -- Why we're failing
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::failureStateChangePostureDuck( const str &failureReason )
{
	SetFailureReason( failureReason );
}
예제 #15
0
//--------------------------------------------------------------
// Name:		failureStateMoveToBetterNode()
// Class:		CorridorCombatWithRangedWeapon
//
// Description:	Failure Handler for state
//
// Parameters:	const str& failureReason
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::failureStateMoveToBetterNode( const str& failureReason )
{
	SetFailureReason( failureReason );
}
예제 #16
0
//--------------------------------------------------------------
// Name:		failureStateBackPedal()
// Class:		CorridorCombatWithRangedWeapon
//
// Description:	Failure Handler
//
// Parameters:	const str& failureReason
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::failureStateBackPedal( const str& failureReason )
{
	SetFailureReason( failureReason );
}
예제 #17
0
//--------------------------------------------------------------
// Name:		failureStateFindNode()
// Class:		CorridorCombatWithRangedWeapon
//	
// Description:	Failure Handler for Find Cover State
//
// Parameters:	const str& failureReason	
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::failureStateFindNode(const str& failureReason)
{
	SetFailureReason( failureReason );
}
예제 #18
0
//--------------------------------------------------------------
// Name:		failureStateHoldPosition()
// Class:		CorridorCombatWithRangedWeapon
//
// Description:	Failure Handler
//
// Parameters:	const str& failureReason
//
// Returns:		None
//--------------------------------------------------------------
void CorridorCombatWithRangedWeapon::failureStateHoldPosition( const str& failureReason )
{
	SetFailureReason( failureReason );
}