Difference between revisions of "VN ms fnc cacheLayer"

From Savage Game Design Wiki
Jump to navigation Jump to search
m (Text replacement - "]]; |p1n=" to "]] |p1n=")
(Page filling)
 
Line 1: Line 1:
[[Category:TODO]]
 
 
{{Function
 
{{Function
  
Line 8: Line 7:
 
|a=
 
|a=
  
|e=
+
|e= global
 +
 
 +
|n= server
  
 
|g1= general
 
|g1= general
  
|d= <pre>/*
+
|d= Toggle caching (disabling simulation) of editor layer.      
    Author: Wyqer, veteran29
 
    Date: 2019-10-15
 
    Last Update: 2020-10-24
 
    Public: Yes
 
 
 
    Description:
 
        Toggle caching of editor layer.
 
 
 
    Parameter(s):
 
        _layer  - Layer name    [STRING, defaults to ""]
 
        _cached - Caching state [BOOL, defaults to true]
 
 
 
    Returns:
 
        Function reached the end [BOOL]
 
 
 
    Example(s):
 
        ["myEditorLayer", false] call vn_ms_fnc_cacheLayer
 
*/
 
params [
 
    ["_layer", "", [""]],
 
    ["_cached", true, [false]]
 
];
 
 
 
#ifdef VN_DEBUG
 
    systemChat format ["[Layer] %1, %2", _layer, _cached];
 
#endif
 
 
 
private _layerData = (getMissionLayerEntities _layer) param [0, []];
 
if (_layerData isEqualTo []) exitWith {
 
    ["Layer '%1' does not contain units, can not (un)cache!", _layer] call BIS_fnc_error;
 
    false
 
};
 
 
 
{
 
    _x enableSimulationGlobal !_cached;
 
    _x hideObjectGlobal _cached;
 
    if (_cached) then {
 
        _x setVariable ["vn_cache_damageAllowed", isDamageAllowed _x, true];
 
        _x allowDamage false;
 
    } else {
 
        _x allowDamage (_x getVariable ["vn_cache_damageAllowed", true]);
 
        _x setVariable ["vn_cache_damageAllowed", nil, true];
 
    };
 
} forEach _layerData;
 
 
 
private _groups = _layerData apply {group _x};
 
_groups = _groups arrayIntersect _groups;
 
{
 
    // handle dynamic simulation for groups
 
    if (_cached && {isNil {_x getVariable "vn_cache_dynSim"}}) then {
 
        _x setVariable ["vn_cache_dynSim", dynamicSimulationEnabled _x];
 
        _x enableDynamicSimulation false;
 
    } else {
 
        if (!_cached) then {
 
            _x enableDynamicSimulation (_x getVariable ["vn_cache_dynSim", false]);
 
            _x setVariable ["vn_cache_dynSim", nil];
 
        };
 
    };
 
} forEach _groups;
 
 
 
true
 
</pre><small>''(Placeholder description extracted from the function header by '''LM_exportFunctionsToWiki.sqf''')''</small>
 
  
|s= [] call [[vn_ms_fnc_cacheLayer]]
+
|s= [layerName, cached] call [[VN_ms_fnc_cacheLayer]]
  
|p1n=
+
|p1n= layerName
|p1t=
+
|p1t= string
|p1d=
+
|p1d= layer name
 
|p1v=
 
|p1v=
  
|p2n=
+
|p2n= cached
|p2t=
+
|p2t= boolean
|p2d=
+
|p2d= caching state
|p2v=
+
|p2v= true
  
|r1t=
+
|r1t= boolean
|r1d=
+
|r1d= function's success
  
|x1= <code>-</code>
+
|x1= <code>["myEditorLayer", false] call [[VN_ms_fnc_cacheLayer]];</code>
 
}}
 
}}

Latest revision as of 18:05, 22 February 2021

← back to Functions Introduced in S.O.G. Prairie Fire v1.00
by Wyqer, veteran29
Argument(s): n/a
Effect(s): global
Execution: Server only

Description

Toggle caching (disabling simulation) of editor layer.

Syntax

Syntax
[layerName, cached] call VN_ms_fnc_cacheLayer
Parameters
layerName: String - layer name
cached: Boolean - (Optional, default true) caching state
Return value
Boolean - function's success

Examples

Example 1
["myEditorLayer", false] call VN_ms_fnc_cacheLayer;