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:
parent
443cbf8be3
commit
6c968d8bc7
@ -20,6 +20,10 @@ ACE_Modifier = 0;
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
GVAR(isOpeningDoor) = false;
|
||||
|
||||
[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
|
||||
|
||||
["tapShoulder", {
|
||||
params ["_unit", "_shoulderNum"];
|
||||
|
||||
@ -33,8 +37,6 @@ if (!hasInterface) exitWith {};
|
||||
["displayTextStructured", _message] call EFUNC(common,targetEvent);
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
GVAR(isOpeningDoor) = false;
|
||||
|
||||
// restore global fire teams for JIP
|
||||
private "_team";
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ PREP(pardon);
|
||||
// interaction with doors
|
||||
PREP(getDoor);
|
||||
PREP(getDoorAnimations);
|
||||
PREP(handleScrollWheel);
|
||||
PREP(openDoor);
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
GVAR(isOpeningDoor) = true;
|
||||
|
||||
playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting
|
||||
|
||||
[_house, _animations] spawn { // @todo
|
||||
params ["_house", "_animations"];
|
||||
GVAR(doorTargetPhase) = _house animationPhase (_animations select 0);
|
||||
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);
|
||||
_position = getPosASL ACE_player;
|
||||
if !(GVAR(isOpeningDoor)) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
_time = ACE_time + 0.2;
|
||||
_usedMouseWheel = false;
|
||||
// didn't use incremental opening. Just do animation normally.
|
||||
if !(GVAR(usedScrollWheel)) then {
|
||||
private "_phase";
|
||||
_phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5);
|
||||
|
||||
waitUntil {
|
||||
if (inputAction "PrevAction" > 0 || {inputAction "NextAction" > 0}) then {
|
||||
_usedMouseWheel = true;
|
||||
{_house animate [_x, _phase]; false} count _animations;
|
||||
};
|
||||
|
||||
_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 {
|
||||
_phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5);
|
||||
|
||||
{_house animate [_x, _phase]} forEach _animations;
|
||||
// check if player moved too far away
|
||||
if (getPosASL ACE_player distance _position > 1) exitWith {
|
||||
GVAR(isOpeningDoor) = false;
|
||||
};
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user