add stats about current vehicle's radio

This commit is contained in:
in0finite 2020-05-05 14:02:35 +02:00
parent d29a1e1a4e
commit ea840f8b5e
3 changed files with 27 additions and 1 deletions

View file

@ -7,12 +7,18 @@ namespace SanAndreasUnity.Behaviours.Vehicles
public partial class Vehicle
{
private int m_currentRadioStationIndex;
public int CurrentRadioStationIndex => m_currentRadioStationIndex;
private AudioSource m_radioAudioSource;
public AudioSource RadioAudioSource => m_radioAudioSource;
bool m_isPlayingRadio = false;
public bool IsPlayingRadio => m_isPlayingRadio;
bool m_radio_pedAssignedToVehicleLastFrame = false;
bool m_isWaitingForNewRadioSound = false;
public bool IsWaitingForNewRadioSound => m_isWaitingForNewRadioSound;

View file

@ -106,6 +106,21 @@ namespace SanAndreasUnity.Stats
objects.Add(Vector3.Distance(closestSeat.position, ped.transform.position));
}
// radio
texts.Add("radio");
objects.Add("");
texts.AddRange(new string[] { "\tis playing", "\tstation index", "\tis waiting for new sound" });
objects.AddRange(new object[] { vehicle.IsPlayingRadio, vehicle.CurrentRadioStationIndex, vehicle.IsWaitingForNewRadioSound });
if (vehicle.RadioAudioSource != null && vehicle.RadioAudioSource.clip != null)
{
var clip = vehicle.RadioAudioSource.clip;
texts.AddRange(new string[] { "\tclip time", "\tclip length", "\tclip size" });
objects.AddRange(new object[] { vehicle.RadioAudioSource.time, clip.length, (Utilities.F.GetAudioClipSizeInBytes(clip) / 1024.0f) + " KB" });
}
sb.AppendFormat("Current vehicle:\n");
for (int i = 0; i < objects.Count; i++)

View file

@ -835,5 +835,10 @@ namespace SanAndreasUnity.Utilities
public static bool ScreenHasHighDensity => Application.isMobilePlatform;
public static int GetAudioClipSizeInBytes(AudioClip clip)
{
return clip.samples * sizeof(float);
}
}
}