/*
	Author: Brazilian Armed Forces
	
	- Rodrigo "Ogrinho" Arantes

	Description:
	- This function is designed to implement semi-authenthic ejection system on fixed wing 2 seated aircrafts.

	Exucution:
	- Call the function via user action added to the aircrfat itself.

			class Plane_Eject_UserActionExample
			{
				priority = 0.05;
				shortcut = "Eject";
				displayName = "$STR_A3_action_eject";
				condition="player in this && {speed this > 1}";
				statement="[this] spawn BRAF_fnc_EjectPilot, [this] spawn BRAF_fnc_EjectCopilot";
				position = "pilotcontrol";
				radius = 10;
				onlyforplayer = 1;
				showWindow = 0;
		        hideOnUse = 1;
			};

	Requirments:
		Aircrfat model (in model cfg & class AnimationSources) must have a set of hide animations defined to hide the covers and wheel chocks when new seaparate vehicles are spawned.

		In model.cfg

		class RBFHide
		{
			type="hide";
			source="canopy_hide";
			selection="rbf";
			sourceAddress="clamp";
			minPhase=0;
			maxPhase=1;
			minValue=0;
			maxValue=1;
			memory=1;
			hideValue=0.001;
		};
		
		In cfgVehicles >> class AnimationSources

		class RBFHide
		{
			source = "user";
			animPeriod = 0.001;
			initPhase = 0;
		};

	Parameter(s):
		_this select 0: mode (Scalar)
		0: plane/object

		other parameters are gathered from configuration files.

	Returns: nothing
	Result: Intake, Pitot tube and Propellers covers, wheel chock and another protections will show up. Aircraft will be locked.

*/

#define DISPOSE_ASSETS			if (!isNil{_canopy} && {!isNull _canopy}) then {_canopy setDamage 1;addToRemainsCollector [_canopy]}; if (!isNil{_ejectionSeat} && {!isNull _ejectionSeat}) then {addToRemainsCollector [_ejectionSeat]}

private _plane = param [0,objNull];

if (isNull _plane || {!alive _plane || {unitIsUAV _plane || {speed _plane > 1}}}) exitWith {};

if (_plane getVariable ["braf_A29_locked",false]) exitWith {};
_plane setVariable ["braf_A29_locked",true];

_plane spawn
{
	private _plane = _this;
	//hide ejection seat on plane
	_plane animateSource [RBFHide, 1, true];
	_plane animateSource [rotor, 0, true];
	_plane lock 2;

	
};