
/*********************************************************************
 ** Copyright (c) 1992-2022 MAK Technologies, Inc.
 ** All rights reserved.
 *********************************************************************/

/*********************************************************************
 **
 *t  diguyVehicleController
 **
 */

#ifndef __diguyVehicleController_H
#define __diguyVehicleController_H

#ifdef SWIG
%module diguyVehicleController
#else
#define CPLUSPLUS_ONLY
#endif

#ifdef CPLUSPLUS_ONLY

#include <declspec_diguy.h>
#include <diguy_constants.h>

class diguyCharacter;
class bdiScenarioVehicleController;

#endif

/*!
 **  \class diguyVehicleController
 **  \ingroup diguyCore
 **  \brief Attached to certain types of more complex vehicles, to manage their behavior.
 **
 **  An instance of this class is attached to vehicles that are of the following character types.
 **
 *-  vehicle_09
 *-  vehicle_wheels
 *-  vehicle_turret
 **
 **  These vehicles might be wheeled vehicles, turreted vehicles, or "complete" vehicles. The set
 **  does not include vehicles that belong to the older character type, "vehicle"; this character
 **  type does not support rotating or turning wheels. Some vehicles in vehicle_09 are helicopters
 **  and support rotating blades. Some feature rotating gun turrets.
 */

/****************************************************************************/
class BDI_DECLSPEC_diguy diguyVehicleController
{

public:

/*****************************************************************************
 **
 *2  Character Functions
 **
 */
   diguyCharacter* get_vehicle_character();


/*****************************************************************************
 **
 *2  Speed Functions
 **
 **    These functions should only be used in free action mode.
 **
 */

   /*l
    *b  Description:
    **
    **    This function sets the vehicle's speed.  The speed becomes
    **    effective immediately; no acceleration or deceleration is applied.
    **
    *b  Arguments:
    **
    *a    speed - new speed of vehicle
    *a    units - units of speed
    **
    *b  Callable From:
    **
    *-    - C++
    *-    - Script
    */
   void set_speed(float speed,
      diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
   **  Returns vehicle's current speed. See set_speed().
   */
   float get_speed(diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
    **  Vehicle's speed will increase or decrease over time to match the desired speed.
    **  If necessary, the acceleration value will be applied as deceleration instead.
    */
   void set_desired_speed_with_acceleration(float desired_speed,
      float acceleration,
      diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
    **  An acceleration value is calculated from the time interval and the difference
    **  between current speed and desired speed.
    */
   void set_desired_speed_with_acceleration_time(float desired_speed,
      float acceleration_time,   // seconds
      diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
    **  Returns the desired speed, as currently set.
    */
   float get_desired_speed(diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
    **  Sets the default acceleration value that will be used whenever the vehicle needs to raise
    **  its speed.
    */
   void  set_default_acceleration(float acceleration,
      diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);
   float get_default_acceleration(diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);

   /*l
    **  Sets the default deceleration value that will be used whenever the vehicle needs to lower
    **  its speed.
    */
   void  set_default_deceleration(float deceleration,
      diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);
   float get_default_deceleration(diguySpeedUnits units = DIGUY_SPEED_UNITS_METERS_PER_SECOND);


/*****************************************************************************
 **
 *2  Steering Functions
 **
 **    These functions should only be used in free action mode.
 **
 */

   /*l
   **  Sets the simulation mode, which corresponds, roughly, to the degree of realism
   **  of the vehicle's movements.
   **
   *b  Values:
   **
   *-    - DIGUY_VEHICLE_SIMULATION_MODE_NONE: the vehicle behaves simply as a moving box,
   *-      with no wheel rotation or turning, or steering. The vehicle simply pivots around
   *-      its origin.
   *-    - DIGUY_VEHICLE_SIMULATION_MODE_WHEELS: like NONE, but the wheels rotate.
   *-    - DIGUY_VEHICLE_SIMULATION_MODE_REAR_AXLE_FOLLOWING: like WHEELS, but the turning is
   *-      more realistic. The front wheels turn in their wells, and the pivot axis is what
   *-      it would be in a real car. The vehicle will try to only perform turns that fit
   *-      its steering limits; thus, it might go through a series of turns to round a tight
   *-      corner or to turn around.
   *-    - DIGUY_VEHICLE_SIMULATION_MODE_STEERING: only applies in I-Guy mode, in Scenario.
   *-      Allows the user to be given direct control over the vehicle.
   *-    - DIGUY_VEHICLE_SIMULATION_MODE_FULL_PHYSICS: causes control of the vehicle to be
   *-      taken over by the physics module. This mode is only useful for rigid body simulation
   *-      purposes, such as when a vehicle is thrown through the air by an explosion, not
   *-      for control of normal vehicle movements. All the modes above have some degree of
   *-      "physics", in the sense that DI-Guy makes an effort to keep the wheels on the
   *-      terrain.
   */
   void set_vehicle_simulation_mode(diguyVehicleSimulationMode vsim_mode);

   //! Returns value set by set_vehicle_simulation_mode()
   diguyVehicleSimulationMode get_vehicle_simulation_mode();

   /*l
   **  Only works in DIGUY_VEHICLE_SIMULATION_MODE_STEERING. Sets the steering angle of the front
   **  wheels, with zero being straight ahead.
   */
   void set_front_wheels_steer_angle(float angle);

   /*l
   **  See set_front_wheels_steer_angle()
   */
   float get_front_wheels_steer_angle();

   /*l
   **  Similar to set_desired_front_wheels_steer_angle(), but sets the angle that the wheels will
   **  eventually move to, at the rate specified.
   */
   void set_desired_front_wheels_steer_angle(float desired_angle,
      float angle_change_rate = DIGUY_DEFAULT_FLOAT);

   /*l
   **  See set_desired_front_wheels_steer_angle()
   */
   float get_desired_front_wheels_steer_angle();


   /**
    *x  The functions and variables past this point are for internal use only.
    **   No external access to them is expected or necessary.
    */
#ifdef CPLUSPLUS_ONLY

   bdiScenarioVehicleController* get_scripted_object() {return m_scripted_object;}

private:

   /*l
    **  A private constructor.
    */
   diguyVehicleController(bdiScenarioVehicleController* vehicle_controller);

   /*l
    **  A pointer to internal data.
    */
   bdiScenarioVehicleController* m_scripted_object;

   friend class bdiScenarioVehicleController;

#endif

};

#endif /* __diguyVehicleController_H */


