Skip to content

Class: MockSoundObject

Mock of the X-Ray engine sound object.

Implements

  • sound_object

Constructors

Constructor

ts
new MockSoundObject(path: string): MockSoundObject;

Parameters

ParameterType
pathstring

Returns

MockSoundObject

Methods

asObject()

ts
static asObject(sound: sound_object | null | undefined): MockSoundObject;

Parameters

ParameterType
soundsound_object | null | undefined

Returns

MockSoundObject


create()

ts
static create(path: string): MockSoundObject;

Parameters

ParameterType
pathstring

Returns

MockSoundObject


mock()

ts
static mock(path: string): sound_object;

Parameters

ParameterType
pathstring

Returns

sound_object


resetRegistry()

ts
static resetRegistry(): void;

Returns

void

Properties

attach_tail

ts
attach_tail: Mock<UnknownFunction>;

Append a tail sound played after this sound ends.

Remarks

The tail path is passed to the engine sound handle as-is. Use a game sound resource path without extension.

Param

sound_path

Sound resource path without extension.

Implementation of

ts
sound_object.attach_tail

frequency

ts
frequency: number = 1;

Playback frequency multiplier.

Implementation of

ts
sound_object.frequency

get_position

ts
get_position: Mock<() => MockVector>;

Get the current playback position.

Remarks

Logs an engine script error and returns a zero vector if the sound was not launched.

Returns

Current sound position.

Implementation of

ts
sound_object.get_position

isPlaying

ts
isPlaying: boolean = false;

length

ts
length: Mock<() => number>;

Get sound length in milliseconds.

Remarks

Reads the engine sound handle. Do not use it as a file-existence check after construction logged a missing file.

Returns

Sound duration.

Implementation of

ts
sound_object.length

max_distance

ts
max_distance: number = 1;

Maximum audible distance in meters.

Implementation of

ts
sound_object.max_distance

min_distance

ts
min_distance: number = 0;

Minimum distance before attenuation starts.

Implementation of

ts
sound_object.min_distance

path

ts
path: string;

play

ts
play: Mock<() => void>;

Play the sound attached to an object, or globally when object is null.

Throws

If the sound handle was not created.

Param

object

Object used as sound owner.

Implementation of

ts
sound_object.play

play_at_pos

ts
play_at_pos: Mock<() => void>;

Play the sound at a fixed world position.

Throws

If the sound handle was not created.

Param

object

Optional object used as sound owner.

Param

position

World position for playback.

Implementation of

ts
sound_object.play_at_pos

play_no_feedback

ts
play_no_feedback: Mock<() => void>;

Play without tracking feedback.

Remarks

This starts playback without storing feedback on the sound_object, so playing() will not describe this playback instance.

Throws

If the sound handle was not created.

Param

object

Optional object used as sound owner.

Param

flags

Playback flags.

Param

delay

Delay in seconds.

Param

position

Optional playback position.

Param

volume

Optional playback volume.

Implementation of

ts
sound_object.play_no_feedback

playing

ts
playing: Mock<() => boolean>;

Check whether the sound has active playback feedback.

Remarks

Sounds started with play_no_feedback are intentionally not tracked by feedback.

Returns

Whether the sound is currently playing.

Implementation of

ts
sound_object.playing

position

ts
position: MockVector;

set_position

ts
set_position: Mock<(position: MockVector) => void>;

Move the sound emitter.

Throws

If the sound handle was not created.

Param

position

New world position.

Implementation of

ts
sound_object.set_position

soundLength

ts
soundLength: number = 30;

stop

ts
stop: Mock<() => void>;

Stop playback immediately.

Throws

If the sound handle was not created.

Implementation of

ts
sound_object.stop

stop_deferred

ts
stop_deferred: Mock<() => void>;

Stop playback through the engine deferred-stop path.

Remarks

Preferred spelling. stop_deffered is kept for script compatibility.

Throws

If the sound handle was not created.

Implementation of

ts
sound_object.stop_deferred

stop_deffered

ts
stop_deffered: Mock<() => void>;

Stop playback through the engine deferred-stop path.

Remarks

Legacy misspelled alias for stop_deferred.

Throws

If the sound handle was not created.

Implementation of

ts
sound_object.stop_deffered

volume

ts
volume: number = 0;

Playback volume.

Implementation of

ts
sound_object.volume

SOUND_OBJECT_REGISTRY

ts
readonly static SOUND_OBJECT_REGISTRY: MockSoundObject[] = [];