forked from LeenkxTeam/LNXSDK
Add leenkx/Sources/leenkx/logicnode/GetPositionSpeakerNode.hx
This commit is contained in:
33
leenkx/Sources/leenkx/logicnode/GetPositionSpeakerNode.hx
Normal file
33
leenkx/Sources/leenkx/logicnode/GetPositionSpeakerNode.hx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package leenkx.logicnode;
|
||||||
|
|
||||||
|
#if lnx_audio
|
||||||
|
import iron.object.SpeakerObject;
|
||||||
|
import kha.audio1.AudioChannel;
|
||||||
|
#end
|
||||||
|
|
||||||
|
class GetPositionSpeakerNode extends LogicNode {
|
||||||
|
|
||||||
|
public function new(tree: LogicTree) {
|
||||||
|
super(tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
override function get(from: Int): Dynamic {
|
||||||
|
#if lnx_audio
|
||||||
|
var object: SpeakerObject = cast(inputs[0].get(), SpeakerObject);
|
||||||
|
if (object == null || object.sound == null) return 0.0;
|
||||||
|
|
||||||
|
if (object.channels.length == 0) return 0.0;
|
||||||
|
|
||||||
|
var channel = object.channels[0];
|
||||||
|
|
||||||
|
var position = 0.0;
|
||||||
|
if (channel != null) {
|
||||||
|
position = @:privateAccess channel.get_position();
|
||||||
|
}
|
||||||
|
|
||||||
|
return position;
|
||||||
|
#else
|
||||||
|
return 0.0;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user