replace Time.time with Time.timeAsDouble - fix problems with floating-point numbers precision when game uptime is high (eg. 1 month)

This commit is contained in:
in0finite 2022-05-06 17:08:48 +02:00
parent cc79defb97
commit 01633f3817
23 changed files with 74 additions and 74 deletions

View file

@ -45,7 +45,7 @@ namespace SanAndreasUnity.Behaviours
public bool IsMinimapVisible => _canvas.enabled && this.gameObject.activeInHierarchy; public bool IsMinimapVisible => _canvas.enabled && this.gameObject.activeInHierarchy;
private float _timeWhenRetrievedZoneName = 0f; private double _timeWhenRetrievedZoneName = 0f;
private string _lastZoneName = ""; private string _lastZoneName = "";
@ -53,9 +53,9 @@ namespace SanAndreasUnity.Behaviours
{ {
get get
{ {
if (Time.time - _timeWhenRetrievedZoneName > 2f) if (Time.timeAsDouble - _timeWhenRetrievedZoneName > 2f)
{ {
_timeWhenRetrievedZoneName = Time.time; _timeWhenRetrievedZoneName = Time.timeAsDouble;
_lastZoneName = Zone.GetZoneName(this.FocusPos); _lastZoneName = Zone.GetZoneName(this.FocusPos);
} }

View file

@ -334,12 +334,12 @@ namespace SanAndreasUnity.Behaviours
// yield until you find ground beneath or above the player, or until timeout expires // yield until you find ground beneath or above the player, or until timeout expires
float timeStarted = Time.time; double timeStarted = Time.timeAsDouble;
int numAttempts = 1; int numAttempts = 1;
while (true) { while (true) {
if (Time.time - timeStarted > 4.0f) { if (Time.timeAsDouble - timeStarted > 4.0f) {
// timeout expired // timeout expired
Debug.LogWarningFormat("Failed to find ground for ped {0} - timeout expired", this.DescriptionForLogging); Debug.LogWarningFormat("Failed to find ground for ped {0} - timeout expired", this.DescriptionForLogging);
yield break; yield break;

View file

@ -29,8 +29,8 @@ namespace SanAndreasUnity.Behaviours
/// </summary> /// </summary>
public DamageInfo KillingDamageInfo { get; set; } public DamageInfo KillingDamageInfo { get; set; }
public float LastTimeWhenDamaged { get; private set; } public double LastTimeWhenDamaged { get; private set; }
public float TimeSinceDamaged => Time.time - this.LastTimeWhenDamaged; public double TimeSinceDamaged => Time.timeAsDouble - this.LastTimeWhenDamaged;
private bool m_alreadyKilled = false; private bool m_alreadyKilled = false;
@ -53,10 +53,10 @@ namespace SanAndreasUnity.Behaviours
public struct UnderAimInfo public struct UnderAimInfo
{ {
public DamageInfo damageInfo; public DamageInfo damageInfo;
public float time; public double time;
public Ped ped; public Ped ped;
public UnderAimInfo(DamageInfo damageInfo, float time, Ped ped) public UnderAimInfo(DamageInfo damageInfo, double time, Ped ped)
{ {
this.damageInfo = damageInfo; this.damageInfo = damageInfo;
this.time = time; this.time = time;
@ -150,7 +150,7 @@ namespace SanAndreasUnity.Behaviours
if (this.Health <= 0) if (this.Health <= 0)
return; return;
this.LastTimeWhenDamaged = Time.time; this.LastTimeWhenDamaged = Time.timeAsDouble;
var damageInfo = this.Damageable.LastDamageInfo; var damageInfo = this.Damageable.LastDamageInfo;
@ -168,7 +168,7 @@ namespace SanAndreasUnity.Behaviours
public void OnReceivedDamageEventFromServer(float damageAmount, Ped attackingPed) public void OnReceivedDamageEventFromServer(float damageAmount, Ped attackingPed)
{ {
this.LastTimeWhenDamaged = Time.time; this.LastTimeWhenDamaged = Time.timeAsDouble;
if (attackingPed != null && attackingPed.IsControlledByLocalPlayer && attackingPed != this) if (attackingPed != null && attackingPed.IsControlledByLocalPlayer && attackingPed != this)
{ {
@ -210,11 +210,11 @@ namespace SanAndreasUnity.Behaviours
int index = _underAimInfos.FindIndex(_ => _.ped == attackerPed); int index = _underAimInfos.FindIndex(_ => _.ped == attackerPed);
if (index >= 0) if (index >= 0)
{ {
_underAimInfos[index] = new UnderAimInfo(damageInfo, Time.time, attackerPed); _underAimInfos[index] = new UnderAimInfo(damageInfo, Time.timeAsDouble, attackerPed);
return; return;
} }
_underAimInfos.Add(new UnderAimInfo(damageInfo, Time.time, attackerPed)); _underAimInfos.Add(new UnderAimInfo(damageInfo, Time.timeAsDouble, attackerPed));
} }
private bool ShouldUnderAimInfoBeRemoved(UnderAimInfo underAimInfo) private bool ShouldUnderAimInfoBeRemoved(UnderAimInfo underAimInfo)
@ -222,7 +222,7 @@ namespace SanAndreasUnity.Behaviours
if (null == underAimInfo.ped) if (null == underAimInfo.ped)
return true; return true;
return Time.time - underAimInfo.time > PedManager.Instance.timeIntervalToUpdateUnderAimStatus; return Time.timeAsDouble - underAimInfo.time > PedManager.Instance.timeIntervalToUpdateUnderAimStatus;
} }
} }

View file

@ -26,7 +26,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public virtual float TimeUntilStateCanBeSwitchedToOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState; public virtual float TimeUntilStateCanBeSwitchedToOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState;
public virtual float TimeUntilStateCanBeEnteredFromOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState; public virtual float TimeUntilStateCanBeEnteredFromOtherAimMovementState => PedManager.Instance.timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState;
protected float m_timeWhenDidUnderAimDetection = 0f; protected double m_timeWhenDidUnderAimDetection = 0f;
@ -262,9 +262,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
this.UpdateAimAnim (state); this.UpdateAimAnim (state);
// do this right after UpdateAimAnim(), because that's the state when weapon conducts attack // do this right after UpdateAimAnim(), because that's the state when weapon conducts attack
if (m_isServer && Time.time - m_timeWhenDidUnderAimDetection >= PedManager.Instance.timeIntervalToUpdateUnderAimStatus) if (m_isServer && Time.timeAsDouble - m_timeWhenDidUnderAimDetection >= PedManager.Instance.timeIntervalToUpdateUnderAimStatus)
{ {
m_timeWhenDidUnderAimDetection = Time.time; m_timeWhenDidUnderAimDetection = Time.timeAsDouble;
UpdateUnderAimDetection(m_ped); UpdateUnderAimDetection(m_ped);
} }
} }

View file

@ -120,7 +120,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
for (int i = 0; i < aimStates.Count; i++) for (int i = 0; i < aimStates.Count; i++)
{ {
if (Time.time - aimStates[i].LastTimeWhenDeactivated < PedManager.Instance.minTimeToReturnToAimState) if (Time.timeAsDouble - aimStates[i].LastTimeWhenDeactivated < PedManager.Instance.minTimeToReturnToAimState)
return false; return false;
} }

View file

@ -22,10 +22,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
protected bool m_isClientOnly => Net.NetStatus.IsClientOnly; protected bool m_isClientOnly => Net.NetStatus.IsClientOnly;
protected bool m_shouldSendButtonEvents { get { return !m_isServer && m_ped.IsControlledByLocalPlayer; } } protected bool m_shouldSendButtonEvents { get { return !m_isServer && m_ped.IsControlledByLocalPlayer; } }
public float LastTimeWhenActivated { get; set; } = 0f; public double LastTimeWhenActivated { get; set; } = 0;
public float TimeSinceActivated => Time.time - this.LastTimeWhenActivated; public double TimeSinceActivated => Time.timeAsDouble - this.LastTimeWhenActivated;
public float LastTimeWhenDeactivated { get; set; } = 0f; public double LastTimeWhenDeactivated { get; set; } = 0;
public float TimeSinceDeactivated => Time.time - this.LastTimeWhenDeactivated; public double TimeSinceDeactivated => Time.timeAsDouble - this.LastTimeWhenDeactivated;

View file

@ -50,7 +50,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public float timeUntilAbleToEnterState = 0.5f; public float timeUntilAbleToEnterState = 0.5f;
public float timeUntilAbleToExitState = 0.5f; public float timeUntilAbleToExitState = 0.5f;
private float m_lastTimeWhenChangedAnim = 0f; private double m_lastTimeWhenChangedAnim = 0f;
private string m_lastAnim = null; private string m_lastAnim = null;
public float timeUntilAbleToChangeAnim = 0.5f; public float timeUntilAbleToChangeAnim = 0.5f;
@ -131,10 +131,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
string GetAnimBasedOnAimDirSmoothed() string GetAnimBasedOnAimDirSmoothed()
{ {
if (m_lastAnim != null && Time.time - m_lastTimeWhenChangedAnim < this.timeUntilAbleToChangeAnim) if (m_lastAnim != null && Time.timeAsDouble - m_lastTimeWhenChangedAnim < this.timeUntilAbleToChangeAnim)
return m_lastAnim; return m_lastAnim;
m_lastTimeWhenChangedAnim = Time.time; m_lastTimeWhenChangedAnim = Time.timeAsDouble;
m_lastAnim = this.GetAnimBasedOnAimDir(); m_lastAnim = this.GetAnimBasedOnAimDir();
return m_lastAnim; return m_lastAnim;

View file

@ -19,7 +19,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
private const int kFemaleSoundIndexMin = 88; private const int kFemaleSoundIndexMin = 88;
private const int kFemaleSoundIndexMax = 130; private const int kFemaleSoundIndexMax = 130;
private float _timeWhenEmittedSound = 0f; private double _timeWhenEmittedSound = 0;
public float randomAverageTimeIntervalToEmitSound = 10f; public float randomAverageTimeIntervalToEmitSound = 10f;
private float _timeToEmitSound; private float _timeToEmitSound;
@ -65,14 +65,14 @@ namespace SanAndreasUnity.Behaviours.Peds.States
private void TryEmitSound() private void TryEmitSound()
{ {
if (Time.time - _timeWhenEmittedSound < _timeToEmitSound) if (Time.timeAsDouble - _timeWhenEmittedSound < _timeToEmitSound)
return; return;
_timeToEmitSound = Random.Range( _timeToEmitSound = Random.Range(
this.randomAverageTimeIntervalToEmitSound * 0.5f, this.randomAverageTimeIntervalToEmitSound * 0.5f,
this.randomAverageTimeIntervalToEmitSound * 1.5f); this.randomAverageTimeIntervalToEmitSound * 1.5f);
_timeWhenEmittedSound = Time.time; _timeWhenEmittedSound = Time.timeAsDouble;
m_ped.PlaySoundFromPedMouth(this.GetSoundToPlay()); m_ped.PlaySoundFromPedMouth(this.GetSoundToPlay());
} }

View file

@ -7,7 +7,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
public class UpdateAttackParams public class UpdateAttackParams
{ {
public bool wasInRange = false; public bool wasInRange = false;
public float timeWhenAddedFireOffset = 0f; public double timeWhenAddedFireOffset = 0;
public float timeUntilOffsetChanges = 1f; public float timeUntilOffsetChanges = 1f;
public Vector3 newFireOffset = Vector3.zero; public Vector3 newFireOffset = Vector3.zero;
@ -136,9 +136,9 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
public void UpdateAttackOnPed(Ped ped, UpdateAttackParams updateAttackParams) public void UpdateAttackOnPed(Ped ped, UpdateAttackParams updateAttackParams)
{ {
if (Time.time - updateAttackParams.timeWhenAddedFireOffset > updateAttackParams.timeUntilOffsetChanges) if (Time.timeAsDouble - updateAttackParams.timeWhenAddedFireOffset > updateAttackParams.timeUntilOffsetChanges)
{ {
updateAttackParams.timeWhenAddedFireOffset = Time.time; updateAttackParams.timeWhenAddedFireOffset = Time.timeAsDouble;
updateAttackParams.newFireOffset = Random.onUnitSphere * 0.2f; updateAttackParams.newFireOffset = Random.onUnitSphere * 0.2f;
} }

View file

@ -14,9 +14,9 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
private ChaseState _chaseState; private ChaseState _chaseState;
private float _timeWhenStartedSurrendering = 0f; private double _timeWhenStartedSurrendering = 0;
public float TimeSinceStartedSurrendering => Time.time - _timeWhenStartedSurrendering; public double TimeSinceStartedSurrendering => Time.timeAsDouble - _timeWhenStartedSurrendering;
public bool IsSurrendering => this.TimeSinceStartedSurrendering < 4f; public bool IsSurrendering => this.TimeSinceStartedSurrendering < 4.0;
public float nodeSearchRadius = 500f; public float nodeSearchRadius = 500f;
@ -143,7 +143,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
return; return;
} }
_timeWhenStartedSurrendering = Time.time; _timeWhenStartedSurrendering = Time.timeAsDouble;
} }
} }

View file

@ -14,7 +14,7 @@ namespace SanAndreasUnity.Behaviours
public bool spawnPlayerWhenConnected = true; public bool spawnPlayerWhenConnected = true;
public bool IsSpawningPaused { get; set; } = false; public bool IsSpawningPaused { get; set; } = false;
public float spawnInterval = 4f; public float spawnInterval = 4f;
float m_lastSpawnTime = 0f; double m_lastSpawnTime = 0;
public bool addWeaponsToSpawnedPlayers = true; public bool addWeaponsToSpawnedPlayers = true;
@ -77,10 +77,10 @@ namespace SanAndreasUnity.Behaviours
if (this.IsSpawningPaused) if (this.IsSpawningPaused)
return; return;
if (Time.time - m_lastSpawnTime >= this.spawnInterval) if (Time.timeAsDouble - m_lastSpawnTime >= this.spawnInterval)
{ {
// enough time passed // enough time passed
m_lastSpawnTime = Time.time; m_lastSpawnTime = Time.timeAsDouble;
F.RunExceptionSafe(() => this.SpawnPlayers()); F.RunExceptionSafe(() => this.SpawnPlayers());
} }

View file

@ -420,7 +420,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
return; return;
m_lastPreparedPeds[index] = ped; m_lastPreparedPeds[index] = ped;
seat.TimeWhenPedChanged = Time.time; seat.TimeWhenPedChanged = Time.timeAsDouble;
this.OnPedAssignedToVehicle_Radio(ped, seat); this.OnPedAssignedToVehicle_Radio(ped, seat);
@ -437,7 +437,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
int index = this.Seats.FindIndex(s => s == seat); int index = this.Seats.FindIndex(s => s == seat);
m_lastPreparedPeds[index] = null; m_lastPreparedPeds[index] = null;
seat.TimeWhenPedChanged = Time.time; seat.TimeWhenPedChanged = Time.timeAsDouble;
} }

View file

@ -23,8 +23,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
bool m_alreadyExploded = false; bool m_alreadyExploded = false;
public bool ExplodedThisFrame => m_alreadyExploded; public bool ExplodedThisFrame => m_alreadyExploded;
public float TimeWhenBecameUnderFlame { get; private set; } = float.NegativeInfinity; public double TimeWhenBecameUnderFlame { get; private set; } = double.NegativeInfinity;
public float TimeSinceBecameUnderFlame => Time.time - this.TimeWhenBecameUnderFlame; public double TimeSinceBecameUnderFlame => Time.timeAsDouble - this.TimeWhenBecameUnderFlame;
GameObject m_smokeGameObject; GameObject m_smokeGameObject;
GameObject m_flameGameObject; GameObject m_flameGameObject;
@ -85,12 +85,12 @@ namespace SanAndreasUnity.Behaviours.Vehicles
// flame status changed // flame status changed
this.IsUnderFlame = shouldBeUnderFlame; this.IsUnderFlame = shouldBeUnderFlame;
if (this.IsUnderFlame) if (this.IsUnderFlame)
this.TimeWhenBecameUnderFlame = Time.time; this.TimeWhenBecameUnderFlame = Time.timeAsDouble;
// update vfx // update vfx
this.UpdateFlameVfx(); this.UpdateFlameVfx();
} }
if (this.IsUnderFlame && Time.time - this.TimeWhenBecameUnderFlame >= 5) if (this.IsUnderFlame && Time.timeAsDouble - this.TimeWhenBecameUnderFlame >= 5)
{ {
// enough time passed since vehicle flamed - explode it // enough time passed since vehicle flamed - explode it
if (NetStatus.IsServer) if (NetStatus.IsServer)

View file

@ -21,8 +21,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
bool m_isWaitingForNewRadioSound = false; bool m_isWaitingForNewRadioSound = false;
public bool IsWaitingForNewRadioSound => m_isWaitingForNewRadioSound; public bool IsWaitingForNewRadioSound => m_isWaitingForNewRadioSound;
public float TimeWhenRadioStationChanged { get; private set; } = float.NegativeInfinity; public double TimeWhenRadioStationChanged { get; private set; } = double.NegativeInfinity;
public float TimeSinceRadioStationChanged => Time.time - this.TimeWhenRadioStationChanged; public double TimeSinceRadioStationChanged => Time.timeAsDouble - this.TimeWhenRadioStationChanged;
@ -237,7 +237,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
if (m_currentRadioStationIndex == index) if (m_currentRadioStationIndex == index)
return; return;
this.TimeWhenRadioStationChanged = Time.time; this.TimeWhenRadioStationChanged = Time.timeAsDouble;
this.StopPlayingRadio(); this.StopPlayingRadio();

View file

@ -243,8 +243,8 @@ namespace SanAndreasUnity.Behaviours.Vehicles
/// <summary> Ped that is occupying this seat. </summary> /// <summary> Ped that is occupying this seat. </summary>
public Ped OccupyingPed { get; internal set; } public Ped OccupyingPed { get; internal set; }
public float TimeWhenPedChanged { get; internal set; } = float.NegativeInfinity; public double TimeWhenPedChanged { get; internal set; } = double.NegativeInfinity;
public float TimeSincePedChanged => Time.time - this.TimeWhenPedChanged; public double TimeSincePedChanged => Time.timeAsDouble - this.TimeWhenPedChanged;
public bool IsTaken { get { return this.OccupyingPed != null; } } public bool IsTaken { get { return this.OccupyingPed != null; } }

View file

@ -122,8 +122,8 @@ namespace SanAndreasUnity.Behaviours
public AnimationState AimAnimState { get; set; } public AnimationState AimAnimState { get; set; }
public Transform GunFlash { get; private set; } public Transform GunFlash { get; private set; }
public float LastTimeWhenFired { get; protected set; } = float.NegativeInfinity; public double LastTimeWhenFired { get; protected set; } = double.NegativeInfinity;
public float TimeSinceFired => Time.time - this.LastTimeWhenFired; public double TimeSinceFired => Time.timeAsDouble - this.LastTimeWhenFired;
// weapon sounds are located in SFX -> GENRL -> BANK 137 // weapon sounds are located in SFX -> GENRL -> BANK 137
@ -677,7 +677,7 @@ namespace SanAndreasUnity.Behaviours
public virtual void FireProjectile (Vector3 firePos, Vector3 fireDir, WeaponAttackParams parameters) public virtual void FireProjectile (Vector3 firePos, Vector3 fireDir, WeaponAttackParams parameters)
{ {
this.LastTimeWhenFired = Time.time; this.LastTimeWhenFired = Time.timeAsDouble;
F.RunExceptionSafe(() => this.PlayFireSound()); F.RunExceptionSafe(() => this.PlayFireSound());

View file

@ -27,8 +27,8 @@ namespace SanAndreasUnity.Behaviours.World
private float m_timeSinceTimeAdvanced = 0; private float m_timeSinceTimeAdvanced = 0;
public float TimeWhenTimeWasSet { get; private set; } = 0; public double TimeWhenTimeWasSet { get; private set; } = 0;
public float TimeSinceTimeWasSet => Time.time - this.TimeWhenTimeWasSet; public double TimeSinceTimeWasSet => Time.timeAsDouble - this.TimeWhenTimeWasSet;
public float timeScale = 1; public float timeScale = 1;
@ -126,7 +126,7 @@ namespace SanAndreasUnity.Behaviours.World
this.CurrentTimeMinutes = minutes; this.CurrentTimeMinutes = minutes;
m_timeSinceTimeAdvanced = 0; m_timeSinceTimeAdvanced = 0;
this.TimeWhenTimeWasSet = Time.time; this.TimeWhenTimeWasSet = Time.timeAsDouble;
float curveTime = this.CurrentCurveTimeStepped; float curveTime = this.CurrentCurveTimeStepped;

View file

@ -36,7 +36,7 @@ namespace SanAndreasUnity.Behaviours.World
public WorldSystem.FocusPoint focusPoint; public WorldSystem.FocusPoint focusPoint;
public Transform transform; public Transform transform;
public float timeToKeepRevealingAfterRemoved; public float timeToKeepRevealingAfterRemoved;
public float timeWhenRemoved; public double timeWhenRemoved;
public bool hasRevealRadius; public bool hasRevealRadius;
} }
@ -82,7 +82,7 @@ namespace SanAndreasUnity.Behaviours.World
if (focusPoint.timeToKeepRevealingAfterRemoved > 0) if (focusPoint.timeToKeepRevealingAfterRemoved > 0)
{ {
focusPoint.timeWhenRemoved = Time.time; focusPoint.timeWhenRemoved = Time.timeAsDouble;
_focusPointsToRemoveAfterTimeout.Add(focusPoint); _focusPointsToRemoveAfterTimeout.Add(focusPoint);
_focusPoints.RemoveAt(index); _focusPoints.RemoveAt(index);
return; return;
@ -94,7 +94,7 @@ namespace SanAndreasUnity.Behaviours.World
public void Update() public void Update()
{ {
float timeNow = Time.time; double timeNow = Time.timeAsDouble;
UnityEngine.Profiling.Profiler.BeginSample("Update focus points"); UnityEngine.Profiling.Profiler.BeginSample("Update focus points");
this._focusPoints.RemoveAll(f => this._focusPoints.RemoveAll(f =>

View file

@ -25,7 +25,7 @@ namespace SanAndreasUnity.Commands
private struct PlayerData private struct PlayerData
{ {
public float timeWhenLastExecutedCommand; public double timeWhenLastExecutedCommand;
} }
readonly Dictionary<Player, PlayerData> m_perPlayerData = new Dictionary<Player, PlayerData>(); readonly Dictionary<Player, PlayerData> m_perPlayerData = new Dictionary<Player, PlayerData>();
@ -224,10 +224,10 @@ namespace SanAndreasUnity.Commands
{ {
m_perPlayerData.TryGetValue(context.player, out PlayerData playerData); m_perPlayerData.TryGetValue(context.player, out PlayerData playerData);
if (commandInfo.limitInterval > 0 && Time.time - playerData.timeWhenLastExecutedCommand < commandInfo.limitInterval) if (commandInfo.limitInterval > 0 && Time.timeAsDouble - playerData.timeWhenLastExecutedCommand < commandInfo.limitInterval)
return ProcessCommandResult.LimitInterval(commandInfo.limitInterval); return ProcessCommandResult.LimitInterval(commandInfo.limitInterval);
playerData.timeWhenLastExecutedCommand = Time.time; playerData.timeWhenLastExecutedCommand = Time.timeAsDouble;
m_perPlayerData[context.player] = playerData; m_perPlayerData[context.player] = playerData;
} }

View file

@ -169,13 +169,13 @@ namespace SanAndreasUnity.UI
if (LanTabIndex == m_currentTabIndex) if (LanTabIndex == m_currentTabIndex)
{ {
GUI.enabled = ! m_netDiscoveryHUD.IsRefreshing; GUI.enabled = ! m_netDiscoveryHUD.IsRefreshing;
buttonText = m_netDiscoveryHUD.IsRefreshing ? ( "Refreshing." + new string('.', (int) ((Time.time * 2) % 3)) ) : "Refresh LAN"; buttonText = m_netDiscoveryHUD.IsRefreshing ? ( "Refreshing." + new string('.', (int) ((Time.timeAsDouble * 2) % 3)) ) : "Refresh LAN";
buttonAction = () => m_netDiscoveryHUD.Refresh(); buttonAction = () => m_netDiscoveryHUD.Refresh();
} }
else if (InternetTabIndex == m_currentTabIndex) else if (InternetTabIndex == m_currentTabIndex)
{ {
GUI.enabled = !_isRefreshingMasterServerList; GUI.enabled = !_isRefreshingMasterServerList;
buttonText = _isRefreshingMasterServerList ? ( "Refreshing." + new string('.', (int) ((Time.time * 2) % 3)) ) : "Refresh servers"; buttonText = _isRefreshingMasterServerList ? ( "Refreshing." + new string('.', (int) ((Time.timeAsDouble * 2) % 3)) ) : "Refresh servers";
buttonAction = async () => await RefreshMasterServersButtonPressed(); buttonAction = async () => await RefreshMasterServersButtonPressed();
} }
} }

View file

@ -11,10 +11,10 @@ public class GLDebug : MonoBehaviour
public Vector3 start; public Vector3 start;
public Vector3 end; public Vector3 end;
public Color color; public Color color;
public float startTime; public double startTime;
public float duration; public float duration;
public Line (Vector3 start, Vector3 end, Color color, float startTime, float duration) public Line (Vector3 start, Vector3 end, Color color, double startTime, float duration)
{ {
this.start = start; this.start = start;
this.end = end; this.end = end;
@ -31,7 +31,7 @@ public class GLDebug : MonoBehaviour
GL.Vertex (start); GL.Vertex (start);
GL.Vertex (end); GL.Vertex (end);
} }
return Time.time - startTime >= duration; return Time.timeAsDouble - startTime >= duration;
} }
} }
@ -149,9 +149,9 @@ public class GLDebug : MonoBehaviour
if (start == end) if (start == end)
return; return;
if (depthTest) if (depthTest)
instance.linesZOn.Add (new Line (start, end, color, Time.time, duration)); instance.linesZOn.Add (new Line (start, end, color, Time.timeAsDouble, duration));
else else
instance.linesZOff.Add (new Line (start, end, color, Time.time, duration)); instance.linesZOff.Add (new Line (start, end, color, Time.timeAsDouble, duration));
} }
/// <summary> /// <summary>

View file

@ -15,8 +15,8 @@ namespace SanAndreasUnity.Utilities
object ParameterForEnteringState { set; } object ParameterForEnteringState { set; }
float LastTimeWhenActivated { get; set; } double LastTimeWhenActivated { get; set; }
float LastTimeWhenDeactivated { get; set; } double LastTimeWhenDeactivated { get; set; }
} }
} }

View file

@ -8,7 +8,7 @@ namespace SanAndreasUnity.Utilities
IState m_currentState; IState m_currentState;
public IState CurrentState { get { return m_currentState; } } public IState CurrentState { get { return m_currentState; } }
bool m_isSwitchingState = false; bool m_isSwitchingState = false;
public float TimeWhenSwitchedState { get; private set; } public double TimeWhenSwitchedState { get; private set; }
public long FrameWhenSwitchedState { get; private set; } public long FrameWhenSwitchedState { get; private set; }
@ -33,20 +33,20 @@ namespace SanAndreasUnity.Utilities
// no longer be possible to switch states, because 'm_isSwitchingState' is true // no longer be possible to switch states, because 'm_isSwitchingState' is true
F.RunExceptionSafe(() => F.RunExceptionSafe(() =>
{ {
oldState.LastTimeWhenDeactivated = Time.time; oldState.LastTimeWhenDeactivated = Time.timeAsDouble;
oldState.OnBecameInactive(); oldState.OnBecameInactive();
}); });
} }
m_isSwitchingState = false; m_isSwitchingState = false;
this.TimeWhenSwitchedState = Time.time; this.TimeWhenSwitchedState = Time.timeAsDouble;
this.FrameWhenSwitchedState = Time.frameCount; this.FrameWhenSwitchedState = Time.frameCount;
if (m_currentState != null) if (m_currentState != null)
{ {
m_currentState.ParameterForEnteringState = parameterForEnteringState; m_currentState.ParameterForEnteringState = parameterForEnteringState;
m_currentState.LastTimeWhenActivated = Time.time; m_currentState.LastTimeWhenActivated = Time.timeAsDouble;
m_currentState.OnBecameActive(); m_currentState.OnBecameActive();
} }
} }