Merge pull request 'Audio flag to prevent crashing when audio is disabled' (#22) from Onek8/LNXSDK:main into main
Reviewed-on: #22
This commit is contained in:
commit
9478e4e957
@ -1,7 +1,7 @@
|
|||||||
package leenkx.logicnode;
|
package leenkx.logicnode;
|
||||||
|
#if lnx_audio
|
||||||
import iron.object.SpeakerObject;
|
import iron.object.SpeakerObject;
|
||||||
|
#end
|
||||||
class PauseSoundNode extends LogicNode {
|
class PauseSoundNode extends LogicNode {
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
@ -9,9 +9,11 @@ class PauseSoundNode extends LogicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||||
if (object == null) return;
|
if (object == null) return;
|
||||||
object.pause();
|
object.pause();
|
||||||
|
#end
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package leenkx.logicnode;
|
package leenkx.logicnode;
|
||||||
|
#if lnx_audio
|
||||||
import iron.object.SpeakerObject;
|
import iron.object.SpeakerObject;
|
||||||
|
#end
|
||||||
class PlaySoundNode extends LogicNode {
|
class PlaySoundNode extends LogicNode {
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
@ -9,9 +9,11 @@ class PlaySoundNode extends LogicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||||
if (object == null) return;
|
if (object == null) return;
|
||||||
object.play();
|
object.play();
|
||||||
|
#end
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,16 @@ class PlaySoundRawNode extends LogicNode {
|
|||||||
public var property5: Bool;
|
public var property5: Bool;
|
||||||
|
|
||||||
public var property6: String;
|
public var property6: String;
|
||||||
|
#if lnx_audio
|
||||||
var sound: kha.Sound = null;
|
var sound: kha.Sound = null;
|
||||||
var channel: kha.audio1.AudioChannel = null;
|
var channel: kha.audio1.AudioChannel = null;
|
||||||
|
#end
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
super(tree);
|
super(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
switch (from) {
|
switch (from) {
|
||||||
case Play:
|
case Play:
|
||||||
if (property6 == 'Sound' ? sound == null : true) {
|
if (property6 == 'Sound' ? sound == null : true) {
|
||||||
@ -63,6 +64,10 @@ class PlaySoundRawNode extends LogicNode {
|
|||||||
case UpdateVolume:
|
case UpdateVolume:
|
||||||
if (channel != null) channel.volume = inputs[4].get();
|
if (channel != null) channel.volume = inputs[4].get();
|
||||||
}
|
}
|
||||||
|
#end
|
||||||
|
#if !lnx_audio
|
||||||
|
runOutput(0);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUpdate() {
|
function onUpdate() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package leenkx.logicnode;
|
package leenkx.logicnode;
|
||||||
|
#if lnx_audio
|
||||||
import iron.object.SpeakerObject;
|
import iron.object.SpeakerObject;
|
||||||
|
#end
|
||||||
class SetSoundNode extends LogicNode {
|
class SetSoundNode extends LogicNode {
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
@ -9,10 +9,12 @@ class SetSoundNode extends LogicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||||
var sound: String = inputs[2].get();
|
var sound: String = inputs[2].get();
|
||||||
if (object == null || sound == null) return;
|
if (object == null || sound == null) return;
|
||||||
object.setSound(sound);
|
object.setSound(sound);
|
||||||
|
#end
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package leenkx.logicnode;
|
package leenkx.logicnode;
|
||||||
|
#if lnx_audio
|
||||||
import iron.object.SpeakerObject;
|
import iron.object.SpeakerObject;
|
||||||
|
#end
|
||||||
class SetVolumeSoundNode extends LogicNode {
|
class SetVolumeSoundNode extends LogicNode {
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
@ -9,9 +9,11 @@ class SetVolumeSoundNode extends LogicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||||
if (object == null) return;
|
if (object == null) return;
|
||||||
object.setVolume(inputs[2].get());
|
object.setVolume(inputs[2].get());
|
||||||
|
#end
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package leenkx.logicnode;
|
package leenkx.logicnode;
|
||||||
|
#if lnx_audio
|
||||||
import iron.object.SpeakerObject;
|
import iron.object.SpeakerObject;
|
||||||
|
#end
|
||||||
class StopSoundNode extends LogicNode {
|
class StopSoundNode extends LogicNode {
|
||||||
|
|
||||||
public function new(tree: LogicTree) {
|
public function new(tree: LogicTree) {
|
||||||
@ -9,9 +9,11 @@ class StopSoundNode extends LogicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override function run(from: Int) {
|
override function run(from: Int) {
|
||||||
|
#if lnx_audio
|
||||||
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject);
|
||||||
if (object == null) return;
|
if (object == null) return;
|
||||||
object.stop();
|
object.stop();
|
||||||
|
#end
|
||||||
runOutput(0);
|
runOutput(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user