# AirSim Code Flow

### AirSim Code Flow

Need to figure out how to instantiate the API from within the Unreal environment. This will allow us to embed DroneBlocks directly into the game and send commands without having to go through the RPC server. Not sure if this is possible.

This is the entry point into the AirSim Game Mode:

{% embed url="<https://github.com/microsoft/AirSim/blob/master/Unreal/Plugins/AirSim/Source/AirSimGameMode.cpp#L68>" %}

The SimHUD initializes several components:

{% embed url="<https://github.com/microsoft/AirSim/blob/master/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp#L34>" %}

This is where the API service gets started

{% embed url="<https://github.com/microsoft/AirSim/blob/master/Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp#L34>" %}

An example of a takeoff command and how it gets mapped to a moveToPosition call:

{% embed url="<https://github.com/microsoft/AirSim/blob/master/AirLib/src/vehicles/multirotor/api/MultirotorApiBase.cpp#L22-L41>" %}

In the series of API calls moveOnPath appears to be one of the most important navigation calls. moveToPosition is a wrapper for moveOnPath:

{% embed url="<https://github.com/microsoft/AirSim/blob/master/AirLib/src/vehicles/multirotor/api/MultirotorApiBase.cpp#L217-L395>" %}
