//-------------------------------------------------------------------
//
//  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 CGroundUnit
{
  void InitializeModelAsStatic(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "StaticObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");

    CreateComponent("GroundControl", "GroundControl");
    SetComponentSlaveObject("GroundControl", "Mesh");

    CreateComponent("DustGenerator", "DustGenerator", "CGroundUnitDustGenerator");
    SetComponentPositionable("DustGenerator", "Mesh");
  }

  void InitializeModelAsAnimated(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "AnimatedObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");

    CreateComponent("GroundControl", "GroundControl");
    SetComponentSlaveObject("GroundControl", "Mesh");

    CreateComponent("DustGenerator", "DustGenerator", "CGroundUnitDustGenerator");
    SetComponentPositionable("DustGenerator", "Mesh");
  }
}

class CFlyingUnit
{
  void InitializeModelAsStatic(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "StaticObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");
  }

  void InitializeModelAsAnimated(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "AnimatedObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");
  }
}

class CBuilding
{
  void CBuilding()
  {
    Core_AddClassificator(CLASSIFICATOR_OBSTACLE);
  }

  void InitializeModelAsStatic(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "StaticObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");
  }

  void InitializeModelAsAnimated(
      string _MeshClass
    )
  {
    CreateComponent("Mesh", "AnimatedObject", _MeshClass);
    SetCompoundObjectPositionable("Mesh");
  }

  void InitializeGroundControl()
  {
    CreateComponent("GroundControl", "GroundControl");
    SetComponentSlaveObject("GroundControl", "Mesh");
  }
}

class CCameraCollisionControl
{
  float CollisionRadius = 10.0f;
}

class CUnitWithCamera
{
  void InitializeCamera(
      string _CamLink
    )
  {
    CreateComponent("Camera", "Camera", "CFullScreenCamera");

    CreateComponent("CamLink", "ObjectCameraLink", _CamLink);
    SetComponentSlaveObject("CamLink", "Camera");
    SetComponentPositionable("CamLink", "Mesh");

    CreateComponent("CameraCollision", "CameraCollisionControl", "CCameraCollisionControl");
    SetComponentSlaveObject("CameraCollision", "Camera");
  }
}

class CArmedUnit
{
  array m_WeaponNames = array();

  void CreateStaticWeapon(
      string _WeaponName,
      string _WeaponClass
    )
  {
    CreateComponent(_WeaponName, "Weapon", _WeaponClass);
    SetComponentPositionable(_WeaponName, "Mesh");
    m_WeaponNames.addElement(_WeaponName);
  }

  void CreateAnimatedWeapon(
      string _WeaponName,
      string _WeaponClass,
      string _AnimatorClass
    )
  {
    CreateComponent(_WeaponName, "Weapon", _WeaponClass);
    SetComponentPositionable(_WeaponName, "Mesh");
    m_WeaponNames.addElement(_WeaponName);

    CreateComponent("Animator", "TargetingAnimator", _AnimatorClass);
    SetComponentSlaveObject("Animator", "Mesh");
    SetComponentPositionable("Animator", _WeaponName);
  }
}

class CUnitWithSound
{
  void InitializeSound(
      string _SoundId
    )
  {
    CreateComponent("Emitter", "Emitter", _SoundId);
    CreateComponent("EmtLink", "ObjectEmitterLink");

    SetComponentSlaveObject("EmtLink", "Emitter");
    SetComponentPositionable("EmtLink", "Mesh");
  }
}

class CUnitWithBehavior
{
  void InitializeVehicleBehavior(
      string _BehaviorClass
    )
  {
    CreateComponent("Behavior", "VehicleBehavior", _BehaviorClass);

    SetComponentSlaveObject("Behavior", "Mesh");

    for (int Index = 0; Index < m_WeaponNames.size(); Index = Index + 1)
      SetComponentSlaveObject("Behavior", m_WeaponNames[Index]);
  }
}

class CUnitWithStateControl
{
  void CUnitWithStateControl(
      string _Script
    )
  {
    CreateComponent("StateControl", "UnitStateControl", _Script);
    SetComponentPositionable("StateControl", "Mesh");
  }
}



class CBaseWeaponDescriptor
{
  int    AmmoQuantity      = -1;
  float  BulletSpeed       = 600.0;
  float  FireDeviation     = 0.0;
  string BulletPatternId   = "";
  string LinkJointName     = "";
  string EffectOnFire      = "";
  string FireCloudEffect   = "";
  string SoundOnFire       = "";
  float  TargetingRange    = -1.0;
  vector GravityVector     = vector(0.0, 0.0, 0.0);

  string WeaponName        = "";
  float  FireWeaponDelay   = 0.0;
  bool   IsAutotargeting   = false;
  int    AttachSlotNumber  = 0;

  bool   NotifyOnFire      = false;
}
