-------------------------------------------------------------------------------- Description: Sets up the attached ambient effect. The ambient effect will be distributed across the turret locators via a EveChildInstanceContainer --------------------------------------------------------------------------------
| 392 | // EveChildInstanceContainer |
| 393 | // -------------------------------------------------------------------------------- |
| 394 | void EveTurretSet::InitializeAmbientEffect() |
| 395 | { |
| 396 | auto registry = GetComponentRegistry(); |
| 397 | if( EveEntityPtr entity = BlueCastPtr( m_generatedDistributedAmbientEffect ) ) |
| 398 | { |
| 399 | entity->UnRegister( registry ); |
| 400 | } |
| 401 | m_generatedDistributedAmbientEffect = nullptr; |
| 402 | |
| 403 | if( nullptr == m_ambientEffect ) |
| 404 | { |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | m_ambientOffsetMatrix = IdentityMatrix(); |
| 409 | if( m_ambientEffectEditingMode && !m_singleTurrets.empty() ) |
| 410 | { |
| 411 | auto& firstTurret = m_singleTurrets[0]; |
| 412 | // calculate the offset to place the ambient effect, if we are in editing mode so we can see the effect on the first turret |
| 413 | m_ambientOffsetMatrix = firstTurret.localMatrix; |
| 414 | } |
| 415 | |
| 416 | m_generatedDistributedAmbientEffect.CreateInstance(); |
| 417 | m_generatedDistributedAmbientEffect->SetSourceEffect( m_ambientEffect ); |
| 418 | |
| 419 | for( auto it = m_singleTurrets.begin(); it != m_singleTurrets.end(); ++it ) |
| 420 | { |
| 421 | auto& turret = *it; |
| 422 | // Add the instance to the generated effect |
| 423 | // Note that we don't want this to be attached to a bone |
| 424 | m_generatedDistributedAmbientEffect->AddInstanceTransform( Vector3( 1, 1, 1 ), turret.localQuaternion, turret.localPosition.GetXYZ() ); |
| 425 | } |
| 426 | |
| 427 | // This will either return the source or the generated effect |
| 428 | auto ambientEffect = GetAmbientEffectOrGeneratedEffect(); |
| 429 | |
| 430 | if( m_ambientEffectEditingMode ) |
| 431 | { |
| 432 | if( EveEntityPtr entity = BlueCastPtr( m_ambientEffect ) ) |
| 433 | { |
| 434 | entity->Register( registry ); |
| 435 | } |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | if( EveEntityPtr entity = BlueCastPtr( m_generatedDistributedAmbientEffect ) ) |
| 440 | { |
| 441 | entity->Register( registry ); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | switch( m_state ) |
| 446 | { |
| 447 | case STATE_FIRING: |
| 448 | ambientEffect->SetControllerVariable( "TurretState", float( STATE_TARGETING ) ); |
| 449 | SetAmbientEffectControllerVariableOnInstance( m_activeTurret, "TurretState", float( m_state ) ); |
| 450 | break; |
| 451 | default: |
nothing calls this directly
no test coverage detected