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
DistanceToSpawnPoint
[JsonProperty]
public float DistanceToSpawnPoint
Field Value
Location
The location of the track.
[JsonProperty("File")]
public AssetLocation Location
Field Value
MaxHour
Latest to play the track.
[JsonProperty]
public float MaxHour
Field Value
MaxLatitude
[JsonProperty]
public float MaxLatitude
Field Value
MaxSeason
[JsonProperty]
public float MaxSeason
Field Value
MaxTemperature
[JsonProperty]
public float MaxTemperature
Field Value
MinHour
Earliest to play the track.
[JsonProperty]
public float MinHour
Field Value
MinLatitude
[JsonProperty]
public float MinLatitude
Field Value
MinRainFall
[JsonProperty]
public float MinRainFall
Field Value
MinSeason
[JsonProperty]
public float MinSeason
Field Value
MinSunlight
Minimum sunlight to play the track.
[JsonProperty]
public int MinSunlight
Field Value
OnPlayList
The current play style of the track
[JsonProperty]
public string OnPlayList
Field Value
OnPlayLists
public string[] OnPlayLists
Field Value
- string[]
ShouldPlayMusic
public static bool ShouldPlayMusic
Field Value
Sound
Get the current sound file.
public ILoadedSound Sound
Field Value
capi
Core client API.
protected ICoreClientAPI capi
Field Value
globalCooldownUntilMs
Global cooldown until next track
public static long globalCooldownUntilMs
Field Value
musicEngine
protected IMusicEngine musicEngine
Field Value
nowMaxHour
protected float nowMaxHour
Field Value
nowMinHour
protected float nowMinHour
Field Value
prevFrequency
Gets the previous frequency setting.
protected static int prevFrequency
Field Value
tracksCooldownUntilMs
Cooldown for each track by name.
public static Dictionary<string, long> tracksCooldownUntilMs
Field Value
Properties
IsActive
Is the current song actively playing or is it loading? (False if neither action.
public bool IsActive { get; }
Property Value
MusicFrequency
Gets the current Music Frequency setting.
public int MusicFrequency { get; }
Property Value
Name
The name of the track.
public string Name { get; }
Property Value
PositionString
public string PositionString { get; }
Property Value
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
StartPriority
The start priority of the track. A higher priority will leave active tracks playing.
public float StartPriority { get; set; }
Property Value
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
Methods
BeginPlay(TrackedPlayerProperties)
Begins playing the Music track.
public virtual void BeginPlay(TrackedPlayerProperties props)
Parameters
props
TrackedPlayerPropertiesPlayer 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
floatDelta Time/Change in time.
props
TrackedPlayerPropertiesTrack 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
floatThe duration of the fade out in seconds.
onFadedOut
ActionWhat 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
intThe new frequency
capi
ICoreClientAPIthe core client API
Initialize(IAssetManager, ICoreClientAPI, IMusicEngine)
Initialize the track.
public virtual void Initialize(IAssetManager assetManager, ICoreClientAPI capi, IMusicEngine musicEngine)
Parameters
assetManager
IAssetManagerthe global Asset Manager
capi
ICoreClientAPIThe Core Client API
musicEngine
IMusicEngine
SetCooldown(float)
Sets the cooldown of the current track.
public virtual void SetCooldown(float multiplier)
Parameters
multiplier
floatThe 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
TrackedPlayerPropertiesPlayer Properties
conds
ClimateConditionpos
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()