include "Locomotive.gs"
class ZLocomotiveLLCType2 isclass Locomotive {
bool FanState = false;
Asset MyAsset1;
public void Init(Asset asset) {
inherited(asset);
MyAsset1 = asset;
SetMeshAnimationState("galuzi_vody_right", false);
SetMeshAnimationState("galuzi_vody_left", false);
SetMeshAnimationState("galuzi1_verhnie", false);
AddHandler(me, "Vehicle", "Throttle-Change", "OnThrottleChanged");
}
void OnThrottleChanged(Message msg) {
float throttle = GetEngineSetting("throttle");
if (!FanState and GetEngineSetting("throttle")>5) {
FanState = true;
World.PlaySound(MyAsset1, "sound/zhaluzi_on.wav", 1.0f, 20.0f, 100.0f, me, "a.zhaluzi");
Sleep(0.1);
SetMeshAnimationState("galuzi_vody_right", true);
SetMeshAnimationState("galuzi_vody_left", true);
SetMeshAnimationState("galuzi1_verhnie", true);
}
else if (FanState and GetEngineSetting("throttle")==0) {
FanState = false;
World.PlaySound(MyAsset1, "sound/zhaluzi_off.wav", 1.0f, 20.0f, 100.0f, me, "a.zhaluzi");
Sleep(0.1);
SetMeshAnimationState("galuzi_vody_right", false);
SetMeshAnimationState("galuzi_vody_left", false);
SetMeshAnimationState("galuzi1_verhnie", false);
}
}
};