//-------------------------------------------------------------------
//
//  This code is copyright 2001 by G5 Software.
//  Any unauthorized usage, either in part or in whole of this code
//  is strictly prohibited. Violators WILL be prosecuted to the
//  maximum extent allowed by law.
//
//-------------------------------------------------------------------

class CBaseTerrain extends CExplosionGenerator
{
  // properties

  float fTargetScreenMimimumDetail = 0.6;
  float fTargetScreenDesiredDetail = 0.3;

  //
  //  You can try to decrease the following parameters
  //  to get faster terrain performance
  //

  float  MinimumResolutionMin =  6.0;
  float  DesiredResolutionMin = 12.0;

  float  MinimumResolutionMax = 10.0;
  float  DesiredResolutionMax = 14.0;

  //
  //  terrain texturing parms
  //

  float  GeospecificTextureScale = 1024.0;
  float  GeotypicalTextureScale  = 4.0;

  //
  //  terrain dimension
  //

  int    Dimension = 1024;

  void OnMissionLoaded()
  {
    UpdateZoneMap();

    // tell RouterPrecalculatedGraph to generate graph
    Core_SendEventTo(
      "RouterPrecalculatedGraph",
      "OnGeneratePrecalculatedGraph");
  }

  void OnDetonation(
      string _SourceType,   // source type (explosion type)
      matrix _SourcePlace,  // source place
      float  _Radius        // damage radius
    )
  {
    if (_SourceType == "SphericExplosion")
    {
     DigHole(Core_GetMatrixOrigin(_SourcePlace), _Radius);
    }
    else
    if (_SourceType == "WaveExplosion")
    {
      DigHole(Core_GetMatrixOrigin(_SourcePlace), _Radius);
    }
  }

  void OnToDamage(
      float  _DamageRate,   // damage applied to object
      string _TargetId,     // target object id, "" if none
      string _SourceType,   // source type (explosion type)
      matrix _SourcePlace   // source place
    )
  {
    if (_TargetId != Core_GetIdentificator())
      return;

    if (_SourceType == "DotExplosion")
    {
      Core_CallFunction(
          "Effects",
          "CreateEffect",
          "EFFECTID_BulletHitGroundEffect",
          _SourcePlace
        );
      Core_CallFunction(
          "Sounds",
          "CreateSound",
          "SOUNDID_BulletHitGroundSound",
          _SourcePlace
        );
    }
  }
}

