Merge pull request #2054 from MikeMatrix/codeCleanupSitting

Code cleanup of Sitting module
This commit is contained in:
Glowbal 2015-08-08 17:00:07 +02:00
commit c69aa09d55
8 changed files with 32 additions and 26 deletions

View File

@ -10,17 +10,16 @@
* Can Sit Down <BOOL> * Can Sit Down <BOOL>
* *
* Example: * Example:
* [seat, player] call ace_sitting_fnc_canSit; * [seat, player] call ace_sitting_fnc_canSit
* *
* Public: No * Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_seat,_player); params ["_seat", "_player"];
// Sitting enabled, is seat object, not occupied and standing up (or not on a big slope) // Sitting enabled, is seat object, not occupied and standing up (or not on a big slope)
GVAR(enable) && GVAR(enable) &&
{getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} && {getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} &&
{isNil{_seat getVariable QGVAR(seatOccupied)}} && {isNil {_seat getVariable QGVAR(seatOccupied)}} &&
{round (vectorUp _seat select 0) == 0 && {round (vectorUp _seat select 1) == 0} && {round (vectorUp _seat select 2) == 1}} {round (vectorUp _seat select 0) == 0 && {round (vectorUp _seat select 1) == 0} && {round (vectorUp _seat select 2) == 1}}

View File

@ -15,7 +15,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_player); params ["_player"];
// Sitting // Sitting
(_player getVariable [QGVAR(isSitting),false]) (_player getVariable [QGVAR(isSitting), false])

View File

@ -9,13 +9,13 @@
* Random Animation <STRING> * Random Animation <STRING>
* *
* Example: * Example:
* _animation = call ace_sitting_fnc_getRandomAnimation; * _animation = call ace_sitting_fnc_getRandomAnimation
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_animations"]; private "_animations";
// Animations Pool // Animations Pool
_animations = [ _animations = [

View File

@ -9,13 +9,13 @@
* None * None
* *
* Example: * Example:
* player call ace_sitting_fnc_handleInterrupt; * player call ace_sitting_fnc_handleInterrupt
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_player); params ["_player"];
if (_player getVariable [QGVAR(isSitting), false]) then { if (_player getVariable [QGVAR(isSitting), false]) then {
_player call FUNC(stand); _player call FUNC(stand);

View File

@ -10,18 +10,21 @@
* None * None
* *
* Example: * Example:
* [seat, seatPos] call ace_sitting_fnc_hasChairMoved; * [seat, seatPos] call ace_sitting_fnc_hasChairMoved
* *
* Public: No * Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_seat,_seatPosOrig); params ["_seat", "_seatPosOrig"];
TRACE_2("Chair position",_seatPosOrig,getPosASL _seat); TRACE_2("Chair position",_seatPosOrig,getPosASL _seat);
(getPosASL _seat) params ["_seatX", "_seatY", "_seatZ"];
_seatPosOrig params ["_seatOrigX", "_seatOrigY", "_seatOrigZ"];
// Check each coordinate due to possibility of tiny movements in simulation // Check each coordinate due to possibility of tiny movements in simulation
(getPosASL _seat) select 0 < (_seatPosOrig select 0) - 0.01 || {(getPosASL _seat) select 0 > (_seatPosOrig select 0) + 0.01} || if (abs (_seatX - _seatOrigX) > 0.01) exitWith {true};
{(getPosASL _seat) select 1 < (_seatPosOrig select 1) - 0.01 || {(getPosASL _seat) select 1 > (_seatPosOrig select 1) + 0.01}} || if (abs (_seatY - _seatOrigY) > 0.01) exitWith {true};
{(getPosASL _seat) select 2 < (_seatPosOrig select 2) - 0.01 || {(getPosASL _seat) select 2 > (_seatPosOrig select 2) + 0.01}} if (abs (_seatZ - _seatOrigZ) > 0.01) exitWith {true};
false

View File

@ -3,18 +3,22 @@
* Initializes the Sitting module. * Initializes the Sitting module.
* *
* Arguments: * Arguments:
* Whatever the module provides. * 0: The module logic <LOGIC>
* 1: Units <ARRAY>
* 2: Activated <BOOL>
* *
* Return Value: * Return Value:
* None * None
*
* Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
if !(isServer) exitWith {}; if !(isServer) exitWith {};
PARAMS_3(_logic,_units,_activated); params ["_logic", "_units", "_activated"];
if !(_activated) exitWith {}; if (!_activated) exitWith {};
[_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule);

View File

@ -14,12 +14,11 @@
* *
* Public: No * Public: No
*/ */
//#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
private ["_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"]; private ["_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"];
PARAMS_2(_seat,_player); params ["_seat", "_player"];
// Set global variable for standing up // Set global variable for standing up
GVAR(seat) = _seat; GVAR(seat) = _seat;
@ -50,12 +49,13 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop
_sitDirectionVisual = getDirVisual _player; // Needed for precision and issues with using above directly _sitDirectionVisual = getDirVisual _player; // Needed for precision and issues with using above directly
_seatPosOrig = getPosASL _seat; _seatPosOrig = getPosASL _seat;
[{ [{
EXPLODE_5_PVT(_this select 0,_player,_sitDirectionVisual,_sitRotation,_seat,_seatPosOrig); params ["_args", "_pfhId"];
_args params ["_player", "_sitDirectionVisual", "_sitRotation", "_seat", "_seatPosOrig"];
// Remove PFH if not sitting any more // Remove PFH if not sitting any more
if !(_player getVariable [QGVAR(isSitting), false]) exitWith { if !(_player getVariable [QGVAR(isSitting), false]) exitWith {
[_this select 1] call cba_fnc_removePerFrameHandler; [_pfhId] call cba_fnc_removePerFrameHandler;
TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting),false)]); TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting), false)]);
}; };
// Stand up if chair moves // Stand up if chair moves

View File

@ -15,7 +15,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_player); params ["_player"];
// Restore animation // Restore animation
[_player, "", 2] call EFUNC(common,doAnimation); [_player, "", 2] call EFUNC(common,doAnimation);