1
0
Fork 0

Shake effect: optimize legacy code

This commit is contained in:
legoboyvdlp R 2020-05-03 18:34:38 +01:00
parent 443207e9b6
commit bd19335941
2 changed files with 10 additions and 11 deletions

View file

@ -77,6 +77,7 @@ var Gear = {
compression: [props.globals.getNode("/gear/gear[0]/compression-norm"), props.globals.getNode("/gear/gear[1]/compression-norm"), props.globals.getNode("/gear/gear[2]/compression-norm")],
wow: [props.globals.getNode("/gear/gear[0]/wow"), props.globals.getNode("/gear/gear[1]/wow"), props.globals.getNode("/gear/gear[2]/wow")],
position: [props.globals.getNode("/gear/gear[0]/position-norm"), props.globals.getNode("/gear/gear[1]/position-norm"), props.globals.getNode("/gear/gear[2]/position-norm")],
rollspeed: [props.globals.getNode("/gear/gear[0]/rollspeed-ms"), props.globals.getNode("/gear/gear[1]/rollspeed-ms"), props.globals.getNode("/gear/gear[2]/rollspeed-ms")],
};
var Instrumentation = {

View file

@ -4,20 +4,18 @@
var shakeEffectA3XX = props.globals.initNode("/systems/shake/effect", 0, "BOOL");
var shakeA3XX = props.globals.initNode("/systems/shake/shaking", 0, "DOUBLE");
var rSpeed = 0;
var sf = 0;
var n_g_c = 0;
var n_g_l = 0;
var n_g_r = 0;
var theShakeEffect = func {
n_g_c = getprop("gear/gear[0]/compression-norm") or 0;
n_g_l = getprop("gear/gear[1]/compression-norm") or 0;
n_g_r = getprop("gear/gear[2]/compression-norm") or 0;
rSpeed = getprop("gear/gear[0]/rollspeed-ms") or 0;
sf = rSpeed / 94000;
n_g_c = pts.Gear.compression[0].getValue() or 0;
n_g_l = pts.Gear.compression[1].getValue() or 0;
n_g_r = pts.Gear.compression[2].getValue() or 0;
if (shakeEffectA3XX.getBoolValue() and (n_g_c > 0 or n_g_l > 0 or n_g_r > 0)) {
sf = pts.Gear.rollspeed[0].getValue() / 94000;
interpolate("/systems/shake/shaking", sf, 0.03);
settimer(func {
interpolate("/systems/shake/shaking", -sf * 2, 0.03);
@ -27,13 +25,13 @@ var theShakeEffect = func {
}, 0.12);
settimer(theShakeEffect, 0.09);
} else {
setprop("systems/shake/shaking", 0);
setprop("systems/shake/effect", 0);
shakeA3XX.setValue(0);
shakeEffectA3XX.setBoolValue(0);
}
}
setlistener("/systems/shake/effect", func(state) {
if(state.getBoolValue()) {
setlistener("/systems/shake/effect", func {
if (shakeEffectA3XX.getBoolValue()) {
theShakeEffect();
}
}, 1, 0);
}, 0, 0);