1using NaughtyAttributes;
4using System.Collections.Generic;
45 [HideInInspector]
public string name;
64 [CurveRange(0, 0, 1, 1)]
70 [Range(0, 500), SerializeField]
108 [SerializeField, Space(8), AllowNesting, OnValueChanged(
"CreateTrackLocal"), Dropdown(
"TrackNames")]
121 public Action<RadioTrackWrapper>
OnInit {
get;
set; } =
new(_ => { });
123 public Action<RadioTrackWrapper>
BeforeInit {
get;
set; } =
new(_ => { });
126 public Action<RadioBroadcaster, RadioTrackWrapper>
OnAddBroadcaster {
get;
set; } =
new((_, _) => { });
128 public Action<RadioBroadcaster, RadioTrackWrapper>
OnRemoveBroadcaster {
get;
set; } =
new((_, _) => { });
131 public Action<RadioInsulator, RadioTrackWrapper>
OnAddInsulator {
get;
set; } =
new((_, _) => { });
133 public Action<RadioInsulator, RadioTrackWrapper>
OnRemoveInsulator {
get;
set; } =
new((_, _) => { });
142 set =>
gain = value * 100f;
157 private static Type[] trackTypes;
176 private static string[] trackTypesAsStrings;
187 .Select(t => t.Name.Split(
".")[^1])
190 return trackTypesAsStrings;
196 private static string[] trackNames;
207 .Select(t => (
string)t.GetField(
"DISPLAY_NAME").GetValue(
null))
239 [InitializeOnLoadMethod]
240 public static void OnReload()
243 trackTypesAsStrings =
null;
321 track.AddToPlayerEndCallback(ref _callback);
346 if (_tune < range.x || _tune >
range.y)
350 float attenPower = 1f - (Mathf.Clamp01(_otherVolume) *
attenuation);
352 return tunePower * attenPower;
362 return track.GetSample(_sampleIndex);
365 public bool TryGetClip(out AudioClip _clip)
369 _clip = clipTrack.clip;
The central data object defining the radio. Contains the tracks and information required to play the ...
const float LOW_TUNE
The lower limit for tune on this radio. This may become non-const at some point.
const float HIGH_TUNE
The upper limit for tune on this radio. This may become non-const at some point.
Various utilities used throughout the project.
static Type[] FindDerivedTypes(Type _baseType)
Gets all types derived from a given one. Does not include:Interfaces Generic classes Abstract classes
A eventType of RadioTrack that plays from a chosen AudioClip object.
Action< RadioTrackWrapper > OnInit
An event called when the wrapper is initialised.
Action< RadioInsulator, RadioTrackWrapper > OnRemoveInsulator
An event called when an insulator is removed from this track.
void ScaleRange()
Limits the number of decimal points on the range This is called whenever the range is changed....
Action< RadioBroadcaster, RadioTrackWrapper > OnAddBroadcaster
An event called when a broadcaster is added to the track.
AnimationCurve rangeCurve
The curve defining the loudness of the track over its range. The progress between range....
Action< RadioBroadcaster, RadioTrackWrapper > OnRemoveBroadcaster
An event called when a broadcaster is removed from this track.
bool playOnInit
If true, this track plays on RadioData.Init() - usually on game start.
void AddToPlayerEndCallback(ref Action< RadioTrackPlayer > _callback)
Used if track needs to access a RadioTrackPlayer that it's linked to when that player ends,...
string id
The ID of this track- used to find and manipulate it in custom code.
bool forceGlobal
If true, this track ignores any RadioBroadcaster influence and plays everywhere.
float SampleRate
An alias for the track's SampleRate as other classes cannot access track directly.
Action< RadioInsulator, RadioTrackWrapper > OnAddInsulator
An event called when an insulator is added to the track.
int SampleCount
An alias for the track's SampleCount as other classes cannot access track directly.
float attenuation
The amount that this track gets quieter when another track is playing on top of it (and that other tr...
float GetSample(int _sampleIndex)
Get a sample from the contained track.
List< RadioBroadcaster > broadcasters
The broadcasters in the scene that have this track selected.
static string[] TrackNames
Static; the list of track types stored as their display names. This is shown as a dropdown for trackT...
float Gain
The gain value scaled down to ones- e.g gain at 200 is Gain at 2.
float GainDisplay
The gain value as it is displayed and modified in the editor- in the 100s.
static AnimationCurve DefaultRangeCurve
The default rangeCurve to use when an empty wrapper is created. It's a super basic and smooth closed ...
Vector2 range
The range of tunes in which this track can be heard. If a RadioOutput.Tune value is within this range...
RadioTrackWrapper()
Creates an empty wrapper.
static string GetTrackType(string _typeName)
Converts the typename (NOT display name) of a track eventType to the actual eventType.
void CreateTrackLocal()
Set track to a new track with eventType defined by trackType See also: CreateTrackEditor()
List< RadioInsulator > insulators
The insulators in the scene that have this track selected.
void Init()
Initialize this wrapper and its track.
IRadioTrack track
The actual RadioTrack in this wrapper, its eventType chosen in trackType.
string name
The name of this track for use (and easy identification) in the inspector. This is usually in the for...
Action< RadioTrackWrapper > BeforeInit
An event called just before the wrapper is initialised.
const float RANGE_DECIMAL_MULTIPLIER
The number of decimal places used in the range- the number of zeroes is the number of decimal points,...
static IRadioTrack CreateTrackEditor(string _name)
Static; creates a new track for a wrapper using the given track eventType's display name.
float gain
An added value to the volume of the track. This is applied before any other volume is calculated.
float GetTunePower(float _tune, float _otherVolume)
Calculates the power of this track when an Output is at a specific Tune value. It does this by findin...
string trackType
The eventType of track for this wrapper to contain, selectable in the inspector. This variable is sto...
override string ToString()
Changes the name of this class from "RadioTrackWrapper" to "Wrapper for `track.Name`".
static string[] TrackTypesAsStrings
Static; the list of available track types stored as their typename, NOT as their display names....
static Type[] TrackTypes
A list of each eventType of track that this wrapper can contain- this is anything that inherits from ...
Internal interface for a RadioTrack.
Components to be placed on scene objects, e.g: Outputs, Broadcasters, Observers.
Tracks to be used on a radio- includes base classes.