Table of Contents

Class SurfaceMusicTrack

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Adds a basic music track.

[JsonObject(MemberSerialization.OptIn)]
public class SurfaceMusicTrack : IMusicTrack
Inheritance
SurfaceMusicTrack
Implements
Derived
Inherited Members
Extension Methods

Fields

Chance

[JsonProperty]
public float Chance

Field Value

float

DistanceToSpawnPoint

[JsonProperty]
public float DistanceToSpawnPoint

Field Value

float

Location

The location of the track.

[JsonProperty("File")]
public AssetLocation Location

Field Value

AssetLocation

MaxHour

Latest to play the track.

[JsonProperty]
public float MaxHour

Field Value

float

MaxLatitude

[JsonProperty]
public float MaxLatitude

Field Value

float

MaxSeason

[JsonProperty]
public float MaxSeason

Field Value

float

MaxTemperature

[JsonProperty]
public float MaxTemperature

Field Value

float

MinHour

Earliest to play the track.

[JsonProperty]
public float MinHour

Field Value

float

MinLatitude

[JsonProperty]
public float MinLatitude

Field Value

float

MinRainFall

[JsonProperty]
public float MinRainFall

Field Value

float

MinSeason

[JsonProperty]
public float MinSeason

Field Value

float

MinSunlight

Minimum sunlight to play the track.

[JsonProperty]
public int MinSunlight

Field Value

int

OnPlayList

The current play style of the track

[JsonProperty]
public string OnPlayList

Field Value

string

OnPlayLists

public string[] OnPlayLists

Field Value

string[]

ShouldPlayMusic

public static bool ShouldPlayMusic

Field Value

bool

Sound

Get the current sound file.

public ILoadedSound Sound

Field Value

ILoadedSound

capi

Core client API.

protected ICoreClientAPI capi

Field Value

ICoreClientAPI

globalCooldownUntilMs

Global cooldown until next track

public static long globalCooldownUntilMs

Field Value

long

musicEngine

protected IMusicEngine musicEngine

Field Value

IMusicEngine

nowMaxHour

protected float nowMaxHour

Field Value

float

nowMinHour

protected float nowMinHour

Field Value

float

prevFrequency

Gets the previous frequency setting.

protected static int prevFrequency

Field Value

int

tracksCooldownUntilMs

Cooldown for each track by name.

public static Dictionary<string, long> tracksCooldownUntilMs

Field Value

Dictionary<string, long>

Properties

IsActive

Is the current song actively playing or is it loading? (False if neither action.

public bool IsActive { get; }

Property Value

bool

MusicFrequency

Gets the current Music Frequency setting.

public int MusicFrequency { get; }

Property Value

int

Name

The name of the track.

public string Name { get; }

Property Value

string

PositionString

public string PositionString { get; }

Property Value

string

Priority

The current song's priority. If higher than 1, will stop other tracks and start this one

[JsonProperty]
public float Priority { get; set; }

Property Value

float

StartPriority

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

public float StartPriority { get; set; }

Property Value

float

StartPriorityRnd

The songs starting priority. If higher than 1, then it will be started first. But does not interrupt already running tracks. When reading a songs start priority the maximum of start priority and priority is used

[JsonProperty("StartPriority")]
public NatFloat StartPriorityRnd { get; set; }

Property Value

NatFloat

Methods

BeginPlay(TrackedPlayerProperties)

Begins playing the Music track.

public virtual void BeginPlay(TrackedPlayerProperties props)

Parameters

props TrackedPlayerProperties

Player Properties

BeginSort()

Called before sorting by start priority happens

public virtual void BeginSort()

ContinuePlay(float, TrackedPlayerProperties)

Is it cool for the current track to continue playing?

public virtual bool ContinuePlay(float dt, TrackedPlayerProperties props)

Parameters

dt float

Delta Time/Change in time.

props TrackedPlayerProperties

Track properties.

Returns

bool

Cool or not cool?

FadeOut(float, Action)

Fades out the current track.

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

Parameters

seconds float

The duration of the fade out in seconds.

onFadedOut Action

What to have happen after the track has faded out.

FastForward(float)

public virtual void FastForward(float seconds)

Parameters

seconds float

FrequencyChanged(int, ICoreClientAPI)

The Frequency change in the static system.

protected static void FrequencyChanged(int newFreq, ICoreClientAPI capi)

Parameters

newFreq int

The new frequency

capi ICoreClientAPI

the core client API

Initialize(IAssetManager, ICoreClientAPI, IMusicEngine)

Initialize the track.

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

Parameters

assetManager IAssetManager

the global Asset Manager

capi ICoreClientAPI

The Core Client API

musicEngine IMusicEngine

SetCooldown(float)

Sets the cooldown of the current track.

public virtual void SetCooldown(float multiplier)

Parameters

multiplier float

The multiplier for the cooldown.

ShouldPlay(TrackedPlayerProperties, ClimateCondition, BlockPos)

Should this current track play?

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

Parameters

props TrackedPlayerProperties

Player Properties

conds ClimateCondition
pos BlockPos

Returns

bool

Should we play the current track?

UpdateVolume()

Updates the volume of the current track provided Sound is not null. (effectively calls Sound.SetVolume)

public virtual void UpdateVolume()

selectMinMaxHour()

protected virtual void selectMinMaxHour()