void CBirdsFlock::SetEnabled( bool bEnabled ) { if (!m_bc.bSpawnFromPoint) CFlock::SetEnabled(bEnabled); else { if (m_bEnabled != bEnabled) { SetAttractOutput(false); m_bEnabled = bEnabled; for (Boids::iterator it = m_boids.begin(); it != m_boids.end(); ++it) { CBoidBird *pBoid = (CBoidBird *)*it; float radius = 0.5; // Spawn not far from origin float z = /*gEnv->p3DEngine->GetTerrainElevation(m_origin.x,m_origin.y) + */7.f + Boid::Frand()*2.f; // z = terrain height + [5-9] pBoid->m_pos = m_origin + Vec3(radius*Boid::Frand(),radius*Boid::Frand(), radius*Boid::Frand()); z = .25f*Boid::Frand() + .25f; // z-heading = 0.0 - 0.5 pBoid->m_heading = ( Vec3(Boid::Frand(),Boid::Frand(),z) ).GetNormalized(); pBoid->m_scale = m_bc.boidScale + Boid::Frand()*m_bc.boidRandomScale; pBoid->m_speed = m_bc.MinSpeed + (Boid::Frand()+1)/2.0f*(m_bc.MaxSpeed - m_bc.MinSpeed); pBoid->m_dead = 0; pBoid->m_currentAccel(0,0,0); pBoid->SetSpawnFromPt(true); pBoid->m_fNoCenterAttract = m_bc.factorAttractToOrigin; pBoid->m_fNoKeepHeight = m_bc.factorKeepHeight; pBoid->SetAttracted(false); } if (!bEnabled && m_bEntityCreated) DeleteEntities(false); } } }
void CBirdsFlock::SetAttractionPoint(const Vec3& point) { m_bc.attractionPoint = point; SetAttractOutput(false); for (Boids::iterator it = m_boids.begin(); it != m_boids.end(); ++it) { ((CBoidBird*)*it)->SetAttracted(); } }