Table of Contents

Class CaveMusicTrack

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Represent a dynamically composed track made out of individual small pieces of music mixed together defined by specific rules Requirements:

  • Start/Stop Multiple Trackpieces
  • Set their volumne dynamically
  • Decide which Trackpieces to play
  • Allow individual rules per Trackpiece Specific examples:
  • Play Thunder ambient only if thunderlevel above 10
    • Thunder ambient volume based on thunderlevel (between 0.3 and 1.1?)
  • Play Aquatic Drone only when y below 60
  • Play Deep Drone only when y below 50
[JsonObject(MemberSerialization.OptIn)]
public class CaveMusicTrack : IMusicTrack
Inheritance
CaveMusicTrack
Implements
Inherited Members
Extension Methods

Fields

ShouldPlayCaveMusic

public static bool ShouldPlayCaveMusic

Field Value

bool

Properties

IsActive

Is the track active?

public bool IsActive { get; }

Property Value

bool

Name

The name of the music track.

public string Name { get; }

Property Value

string

PositionString

public string PositionString { get; }

Property Value

string

StartPriority

The start priority of the track. A higher priority will leave active tracks playing.

public float StartPriority { get; }

Property Value

float

Methods

BeginPlay(TrackedPlayerProperties)

Starts playing the track.

public void BeginPlay(TrackedPlayerProperties props)

Parameters

props TrackedPlayerProperties

The properties of the current track.

BeginSort()

Called before sorting by start priority happens

public void BeginSort()

ContinuePlay(float, TrackedPlayerProperties)

Do we continue playing this track?

public bool ContinuePlay(float dt, TrackedPlayerProperties props)

Parameters

dt float

Delta time or Change in time

props TrackedPlayerProperties

The properties of the current track.

Returns

bool

Are we still playing or do we stop?

FadeOut(float, Action)

Fade out the track to end.

public void FadeOut(float seconds, Action onFadedOut = null)

Parameters

seconds float

Seconds to fade out across.

onFadedOut Action

Delegate to have happen once the fade-out is done.

FastForward(float)

public void FastForward(float seconds)

Parameters

seconds float

Initialize(IAssetManager, ICoreClientAPI, IMusicEngine)

Initializes the music track

public void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)

Parameters

assetManager IAssetManager

the global Asset Manager

capi ICoreClientAPI

The Core Client API

musicEngine IMusicEngine

ShouldPlay(TrackedPlayerProperties, ClimateCondition, BlockPos)

Should the game play this track?

public bool ShouldPlay(TrackedPlayerProperties props, ClimateCondition conds, BlockPos pos)

Parameters

props TrackedPlayerProperties

The properties of the current track.

conds ClimateCondition
pos BlockPos

Returns

bool

Do we play this track?

UpdateVolume()

Updates the volume of the track.

public void UpdateVolume()