//-------------------------------------------------------------------
//
//  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 included
//CBf109Plane

class CBf109PlaneMesh
{
  string MeshFile = "Models/Bf109.mesh";
  string SkinFile = "Models/Bf109.skin";
  string AnimFile = "Models/OneRotor.anim";
}

 class CBf109PlaneCollisionDetector
{
  float CollisionRadius = 2.0f;

  void SetTerrainCollisionMode()
  {
    RestrictCollisionTo(CLASSIFICATOR_TERRAIN);
  }
}

class CBf109PlaneStateControl extends CFlyUnitLifeControl
{
  void CBf109PlaneStateControl()
  {
    CUnitLifeControl(500.0);
    m_DestroyPause = 0.0;
  }
}

class CBf109PlaneGun extends CBaseWeaponDescriptor
{
   int    AmmoQuantity      = -1;
  float  BulletSpeed       = 600.0;
  float  FireDeviation     = 0.0002;
  string LinkJointName     = "_Gun_Fire_01";

  string WeaponName        = "Gun";
  float  FireWeaponDelay   = 0.2;
  bool   IsAutotargeting   = false;
  int    AttachSlotNumber  = 1;
  float  TargetingRange    = 12.0;

  //bool   NotifyOnFire      = true;

  string BulletPatternId   = "BULLETID_AirPlaneGunBullet";
  string EffectOnFire      = "EFFECTID_GunTowerGunFireEffect";   //#TMP
  string SoundOnFire       = "";     //#TMP

  bool   ShellCasing       = true;
  string ShellPatternId    = "BULLETID_HelicopterGunShell";
  vector ShellBaseDirection = vector(0.0, 0.0, 0.0); // added to weapon's dir
  float  ShellBaseSpeed     = 10.0; // added to weapon's speed
}

class CBf109PlaneBehavior extends
                              CBaseFlyBehavior,
                              CBf109PlaneFireParameters,
                              CBf109PlaneFlyParams
{

  void CBf109PlaneBehavior()
  {
    CBaseBehavior();
  }
}

class CBf109PlaneFireParameters
{
 bool CanFire = true;

  int  FirePeriod        = 100;//400; // ms если по русски, то это называется скорострельность
  int  FirePeriodRandAdd = 50;//0; // ms
  int  ShootGunNum = 1;

  bool BurstFire         = true;//true;
  int  BurstTime         = 300; // ms    это время которое идет стрельба
  int  BurstTimeRandAdd  = 50; // ms

  int  BurstDelay        = 100; // ms   это перерыв между стрельбой
  int  BurstDelayRandAdd = 10; // ms

// radar

  bool  HasRadar = true;

  float MaxRadarDistance = 1500; // m
  float MinRadarDistance = 30;   // m

  int   UpdateRadarPeriod        = 3000; // ms
  int   UpdateRadarPeriodRandAdd = 1000; // ms

  bool  FireFlying = true;
  bool  FireGround = true;
};

class CBf109PlaneFlyParams extends CBaseFlyParams
{
  float MoveSpeed = 80;
  float ChangeDirSpeed = 40;
};

 class CBf109PlaneRotorAnimator
{
  string AnimationName = "rotor";
  float  SpeedFactor   = 3.15;
}
class CBf109Plane extends     CFlyingUnit,
                              CUnitWithStateControl,
                              CUnitWithBehavior,
                              CArmedUnit,
                              CUnitWithSound
{
  void CBf109Plane()
  {
    //model
    InitializeModelAsAnimated("CBf109PlaneMesh");
    //life state
    CUnitWithStateControl("CBf109PlaneStateControl");
     //weapons
    CreateStaticWeapon("Weapon", "CBf109PlaneGun");
    //Sound
    InitializeSound("CPlaneEngineSound");
    //behavior
    InitializeVehicleBehavior("CBf109PlaneBehavior");
     //Collision
    CreateComponent("CollisionDetector", "PointCollisionDetector", "CBf109PlaneCollisionDetector");
    SetComponentPositionable("CollisionDetector", "Mesh");
     //Smoke
    CreateComponent("SmokeGenerator", "DustGenerator", "CAirPlaneSmokeGenerator");
    SetComponentPositionable("SmokeGenerator", "Mesh");
    
    //Rotors
    CreateComponent("Rotor", "CircledAnimator", "CBf109PlaneRotorAnimator");
    SetComponentSlaveObject("Rotor", "Mesh");
    CreateComponent("RotorEffect", "StaticEffect", "CZeroRotorEffect");
    CreateComponent("RotorLink", "ObjectEffectLink");
    SetComponentSlaveObject("RotorLink",  "RotorEffect");
    SetComponentPositionable("RotorLink", "Mesh", "RH_up");
    
    //Classificators
    Core_AddClassificator("German");
    Core_AddClassificator("FlyingUnit"); /// for behavior fire logic
    Core_AddClassificator("AirUnit");    /// for air unit identification in behavior class
    Core_AddClassificator("AirPlane"); /// for cockpit
  }
}
