Ejemplo n.º 1
0
//
// ExplosionObj::ProcessCycle
//
// Per-cycle processing
//
void ExplosionObj::ProcessCycle()
{
  PERF_S(("ExplosionObj"))

  // Apply damage
  ExplosionType()->Apply(Origin(), sourceUnit.GetPointer(), sourceTeam);

  // Has the persistence time expired ?
  if (GetBirthTime() + ExplosionType()->persist < GameTime::SimTotalTime())
  {
    MarkForDeletion();
  }

  PERF_E(("ExplosionObj"))
}
Ejemplo n.º 2
0
//
// ProjectileObj::ProcessCycle
//
// Per-cycle processing
//
void ProjectileObj::ProcessCycle()
{
  PERF_S(("ProjectileObj"))

  Bool boom = FALSE;

  // Has a proximity distance been specifed ?
  F32 proximity2 = ProjectileType()->GetProximity2();

  if (proximity2 && GetTarget().Alive())
  {
    // Is the target close enough ?
    Vector target = GetTarget().GetLocation() - Position();

    // Proximity type checks
    switch (ProjectileType()->GetProximityType())
    {
      case ProjectileObjType::PROXIMITY_NORMAL:
        if (target.Magnitude2() < proximity2)
        {
          boom = TRUE;
        }
        break;

      case ProjectileObjType::PROXIMITY_XZ:
        if (target.MagnitudeXZ2() < proximity2)
        {
          boom = TRUE;
        }
        break;

      case ProjectileObjType::PROXIMITY_Y:
        if ((GetVelocity().y < 0.0F) && (fabs(target.y) < ProjectileType()->GetProximity()))
        {
          boom = TRUE;
        }
        break;
    }

    if (boom)
    {
      // Kaboom
      Detonate();
    }
  }

  // Has the fuse expired ?
  if 
  (
    !boom && !ProjectileType()->GetImpact() && 
    GameTime::SimTotalTime() - GetBirthTime() > ProjectileType()->GetFuse()
  )
  {
    // Kaboom
    Detonate();
  }

  // Perform type specific physics
  if (!deathNode.InUse())
  {
    Matrix m = WorldMatrix();
    Vector s;

    ProjectileType()->ProcessProjectilePhysics(*this, m, s);

    // Update odometer and position
    distTravelled += s.Magnitude();
    m.posit += s;
    SetSimTarget(m);

    // Register movement with the collision system
    CollisionCtrl::AddObject(this);
  }

  PERF_E(("ProjectileObj"))

  // Call base class
  MapObj::ProcessCycle();
}