mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
per frame handler for incremental door opening
This commit is contained in:
@ -20,6 +20,10 @@ ACE_Modifier = 0;
|
|||||||
|
|
||||||
if (!hasInterface) exitWith {};
|
if (!hasInterface) exitWith {};
|
||||||
|
|
||||||
|
GVAR(isOpeningDoor) = false;
|
||||||
|
|
||||||
|
[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
|
||||||
|
|
||||||
["tapShoulder", {
|
["tapShoulder", {
|
||||||
params ["_unit", "_shoulderNum"];
|
params ["_unit", "_shoulderNum"];
|
||||||
|
|
||||||
@ -33,8 +37,6 @@ if (!hasInterface) exitWith {};
|
|||||||
["displayTextStructured", _message] call EFUNC(common,targetEvent);
|
["displayTextStructured", _message] call EFUNC(common,targetEvent);
|
||||||
}] call EFUNC(common,addEventHandler);
|
}] call EFUNC(common,addEventHandler);
|
||||||
|
|
||||||
GVAR(isOpeningDoor) = false;
|
|
||||||
|
|
||||||
// restore global fire teams for JIP
|
// restore global fire teams for JIP
|
||||||
private "_team";
|
private "_team";
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ PREP(pardon);
|
|||||||
// interaction with doors
|
// interaction with doors
|
||||||
PREP(getDoor);
|
PREP(getDoor);
|
||||||
PREP(getDoorAnimations);
|
PREP(getDoorAnimations);
|
||||||
|
PREP(handleScrollWheel);
|
||||||
PREP(openDoor);
|
PREP(openDoor);
|
||||||
|
|
||||||
// interaction with boats
|
// interaction with boats
|
||||||
|
23
addons/interaction/functions/fnc_handleScrollWheel.sqf
Normal file
23
addons/interaction/functions/fnc_handleScrollWheel.sqf
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Handles incremental door opening
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: scroll amount <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* handled <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_scroll"];
|
||||||
|
|
||||||
|
if !(GVAR(isOpeningDoor)) exitWith {false};
|
||||||
|
|
||||||
|
GVAR(doorTargetPhase) = ((GVAR(doorTargetPhase) + (_scroll / (1.2 * 12))) max 0) min 1;
|
||||||
|
|
||||||
|
GVAR(usedScrollWheel) = true;
|
||||||
|
|
||||||
|
true
|
@ -35,39 +35,37 @@ if (_house animationPhase (_animations select 0) <= 0 && {_house getVariable [_l
|
|||||||
_lockedVariable call BIS_fnc_LockedDoorOpen;
|
_lockedVariable call BIS_fnc_LockedDoorOpen;
|
||||||
};
|
};
|
||||||
|
|
||||||
GVAR(isOpeningDoor) = true;
|
|
||||||
|
|
||||||
playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting
|
playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting
|
||||||
|
|
||||||
[_house, _animations] spawn { // @todo
|
GVAR(doorTargetPhase) = _house animationPhase (_animations select 0);
|
||||||
params ["_house", "_animations"];
|
GVAR(isOpeningDoor) = true;
|
||||||
|
GVAR(usedScrollWheel) = false;
|
||||||
|
|
||||||
private ["_phase", "_position", "_time", "_usedMouseWheel"];
|
[{
|
||||||
|
(_this select 0) params ["_house", "_animations", "_position", "_time", "_frame"];
|
||||||
|
|
||||||
_phase = _house animationPhase (_animations select 0);
|
if !(GVAR(isOpeningDoor)) exitWith {
|
||||||
_position = getPosASL ACE_player;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
|
|
||||||
_time = ACE_time + 0.2;
|
// didn't use incremental opening. Just do animation normally.
|
||||||
_usedMouseWheel = false;
|
if !(GVAR(usedScrollWheel)) then {
|
||||||
|
private "_phase";
|
||||||
|
_phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5);
|
||||||
|
|
||||||
waitUntil {
|
{_house animate [_x, _phase]; false} count _animations;
|
||||||
if (inputAction "PrevAction" > 0 || {inputAction "NextAction" > 0}) then {
|
|
||||||
_usedMouseWheel = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_phase = _phase + (inputAction "PrevAction" / 12) min 1;
|
|
||||||
_phase = _phase - (inputAction "NextAction" / 12) max 0;
|
|
||||||
|
|
||||||
{_house animate [_x, _phase]} forEach _animations;
|
|
||||||
|
|
||||||
!GVAR(isOpeningDoor) || {getPosASL ACE_player distance _position > 1}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!_usedMouseWheel && {ACE_time < _time} && {[ACE_player, objNull, []] call EFUNC(common,canInteractWith)}) then {
|
// check if player moved too far away
|
||||||
_phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5);
|
if (getPosASL ACE_player distance _position > 1) exitWith {
|
||||||
|
GVAR(isOpeningDoor) = false;
|
||||||
{_house animate [_x, _phase]} forEach _animations;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GVAR(isOpeningDoor) = false;
|
// this allows for holding the door in it's current state.
|
||||||
};
|
if (ACE_time > _time && {diag_frameno > _frame}) then {
|
||||||
|
GVAR(usedScrollWheel) = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// do incremental door opening
|
||||||
|
{_house animate [_x, GVAR(doorTargetPhase)]; false} count _animations;
|
||||||
|
}, 0.1, [_house, _animations, getPosASL ACE_player, ACE_time + 0.2, diag_frameno + 2]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
Reference in New Issue
Block a user