-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from gruppe-adler/local-speed-limit
Local speed limit
- Loading branch information
Showing
16 changed files
with
169 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "..\script_component.hpp" | ||
|
||
ISNILS(GVAR(customSpeedLimits), []); // Array<(Location, number)> | ||
ISNILS(GVAR(townSpeedLimits), ([] call FUNC(determineTownLocations)) apply {[ARR_2(_x, GVAR(townSpeedLimit))]}); | ||
|
||
GVAR(townSpeedLimits) + GVAR(customSpeedLimits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _radius = worldSize / 2; | ||
private _center = [_radius, _radius]; | ||
private _townLocationTypes = ["NameCity", "NameCityCapital", "NameVillage", "FlatAreaCity", "FlatAreaCitySmall"]; | ||
nearestLocations [ | ||
_center, | ||
_townLocationTypes, | ||
_radius | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "..\script_component.hpp" | ||
|
||
private _speedLimits = call FUNC(determineSpeedLimits); | ||
|
||
{ | ||
_x setVariable [QGVAR(speedLimit), GVAR(globalSpeedLimit)]; | ||
} forEach GVAR(localCars); | ||
|
||
{ | ||
_x params ["_location", "_speedLimit"]; | ||
private _affectedCars = GVAR(localCars) inAreaArray _location; | ||
{ | ||
_x setVariable [QGVAR(speedLimit), _speedLimit]; | ||
} forEach _affectedCars; | ||
} forEach _speedLimits; | ||
|
||
{ | ||
_x limitSpeed (_x getVariable [QGVAR(speedLimit), GVAR(globalSpeedLimit)]); | ||
} forEach GVAR(localCars); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "..\script_component.hpp" | ||
|
||
params [ | ||
["_mode", "update", [""]] | ||
]; | ||
|
||
ISNILS(GVAR(speedLimitMarkers), []); | ||
{ | ||
deleteMarkerLocal _x; | ||
} forEach GVAR(speedLimitMarkers); | ||
GVAR(speedLimitMarkers) = []; | ||
|
||
if (_mode == "delete") exitWith {}; | ||
|
||
private _speedLimits = call EFUNC(cars,determineSpeedLimits); | ||
|
||
{ | ||
_x params ["_location", "_speedLimit"]; | ||
|
||
private _circle = createMarkerLocal [format ["speed_limit_town_%1_circle", _forEachIndex], position _location]; | ||
_circle setMarkerShapeLocal "ELLIPSE"; | ||
_circle setMarkerSizeLocal (size _location); | ||
_circle setMarkerBrushLocal "SolidBorder"; | ||
_circle setMarkerColorLocal "ColorBlue"; | ||
_circle setMarkerAlphaLocal 0.5; | ||
|
||
private _text = createMarkerLocal [format ["speed_limit_town_%1_text", _forEachIndex], position _location]; | ||
_text setMarkerShapeLocal "ICON"; | ||
_text setMarkerTypeLocal "mil_circle_noShadow"; | ||
_text setMarkerColorLocal "ColorBlue"; | ||
_text setMarkerTextLocal (format ["%1 km/h", _speedLimit]); | ||
|
||
|
||
GVAR(speedLimitMarkers) pushBack _circle; | ||
GVAR(speedLimitMarkers) pushBack _text; | ||
|
||
} forEach _speedLimits; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "..\script_component.hpp" | ||
|
||
ISNILS(GVAR(speedLimitsPfh), -1); | ||
|
||
if (!GVAR(showSpeedLimitsOnMap)) exitWith { | ||
[GVAR(speedLimitsPfh)] call CBA_fnc_removePerFrameHandler; | ||
GVAR(speedLimitsPfh) = -1; | ||
["delete"] call FUNC(drawSpeedLimitsOnMap); | ||
}; | ||
|
||
if (GVAR(speedLimitsPfh) != -1) exitWith { | ||
WARNING("showSpeedLimitsOnMap already has pfh, not adding another one"); | ||
}; | ||
|
||
GVAR(speedLimitsPfh) = [ | ||
{ | ||
if (!isGameFocused || isGamePaused) exitWith {}; | ||
["update"] call FUNC(drawSpeedLimitsOnMap); | ||
}, | ||
2, | ||
[] | ||
] call CBA_fnc_addPerFrameHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters