Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01633f3

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

23 files changed

+74
-74
lines changed

‎Assets/Scripts/Behaviours/MiniMap.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ public class MiniMap : StartupSingleton<MiniMap>
4545

4646
publicboolIsMinimapVisible=>_canvas.enabled&&this.gameObject.activeInHierarchy;
4747

48-
privatefloat_timeWhenRetrievedZoneName=0f;
48+
privatedouble_timeWhenRetrievedZoneName=0f;
4949

5050
privatestring_lastZoneName="";
5151

5252
privatestringZoneName
5353
{
5454
get
5555
{
56-
if(Time.time-_timeWhenRetrievedZoneName>2f)
56+
if(Time.timeAsDouble-_timeWhenRetrievedZoneName>2f)
5757
{
58-
_timeWhenRetrievedZoneName=Time.time;
58+
_timeWhenRetrievedZoneName=Time.timeAsDouble;
5959
_lastZoneName=Zone.GetZoneName(this.FocusPos);
6060
}
6161

‎Assets/Scripts/Behaviours/Ped/Ped.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,12 @@ private IEnumerator FindGroundCoroutine(FindGroundParams parameters)
334334

335335
// yield until you find ground beneath or above the player, or until timeout expires
336336

337-
floattimeStarted=Time.time;
337+
doubletimeStarted=Time.timeAsDouble;
338338
intnumAttempts=1;
339339

340340
while(true){
341341

342-
if(Time.time-timeStarted>4.0f){
342+
if(Time.timeAsDouble-timeStarted>4.0f){
343343
// timeout expired
344344
Debug.LogWarningFormat("Failed to find ground for ped {0} - timeout expired",this.DescriptionForLogging);
345345
yieldbreak;

‎Assets/Scripts/Behaviours/Ped/Ped_Damage.cs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public partial class Ped {
2929
/// </summary>
3030
publicDamageInfoKillingDamageInfo{get;set;}
3131

32-
publicfloatLastTimeWhenDamaged{get;privateset;}
33-
publicfloatTimeSinceDamaged=>Time.time-this.LastTimeWhenDamaged;
32+
publicdoubleLastTimeWhenDamaged{get;privateset;}
33+
publicdoubleTimeSinceDamaged=>Time.timeAsDouble-this.LastTimeWhenDamaged;
3434

3535
privateboolm_alreadyKilled=false;
3636

@@ -53,10 +53,10 @@ public DamageResult(float damageAmount)
5353
publicstructUnderAimInfo
5454
{
5555
publicDamageInfodamageInfo;
56-
publicfloattime;
56+
publicdoubletime;
5757
publicPedped;
5858

59-
publicUnderAimInfo(DamageInfodamageInfo,floattime,Pedped)
59+
publicUnderAimInfo(DamageInfodamageInfo,doubletime,Pedped)
6060
{
6161
this.damageInfo=damageInfo;
6262
this.time=time;
@@ -150,7 +150,7 @@ public void OnDamaged()
150150
if(this.Health<=0)
151151
return;
152152

153-
this.LastTimeWhenDamaged=Time.time;
153+
this.LastTimeWhenDamaged=Time.timeAsDouble;
154154

155155
vardamageInfo=this.Damageable.LastDamageInfo;
156156

@@ -168,7 +168,7 @@ public void SendDamagedEventToClients(DamageInfo damageInfo, float damageAmount)
168168

169169
publicvoidOnReceivedDamageEventFromServer(floatdamageAmount,PedattackingPed)
170170
{
171-
this.LastTimeWhenDamaged=Time.time;
171+
this.LastTimeWhenDamaged=Time.timeAsDouble;
172172

173173
if(attackingPed!=null&&attackingPed.IsControlledByLocalPlayer&&attackingPed!=this)
174174
{
@@ -210,19 +210,19 @@ public void OnUnderAimOfOtherPed(DamageInfo damageInfo)
210210
intindex=_underAimInfos.FindIndex(_=>_.ped==attackerPed);
211211
if(index>=0)
212212
{
213-
_underAimInfos[index]=newUnderAimInfo(damageInfo,Time.time,attackerPed);
213+
_underAimInfos[index]=newUnderAimInfo(damageInfo,Time.timeAsDouble,attackerPed);
214214
return;
215215
}
216216

217-
_underAimInfos.Add(newUnderAimInfo(damageInfo,Time.time,attackerPed));
217+
_underAimInfos.Add(newUnderAimInfo(damageInfo,Time.timeAsDouble,attackerPed));
218218
}
219219

220220
privateboolShouldUnderAimInfoBeRemoved(UnderAimInfounderAimInfo)
221221
{
222222
if(null==underAimInfo.ped)
223223
returntrue;
224224

225-
returnTime.time-underAimInfo.time>PedManager.Instance.timeIntervalToUpdateUnderAimStatus;
225+
returnTime.timeAsDouble-underAimInfo.time>PedManager.Instance.timeIntervalToUpdateUnderAimStatus;
226226
}
227227

228228
}

‎Assets/Scripts/Behaviours/Ped/States/BaseAimMovementState.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class BaseAimMovementState : BaseScriptState, IAimState
2626
publicvirtualfloatTimeUntilStateCanBeSwitchedToOtherAimMovementState=>PedManager.Instance.timeUntilAimMovementStateCanBeSwitchedToOtherAimMovementState;
2727
publicvirtualfloatTimeUntilStateCanBeEnteredFromOtherAimMovementState=>PedManager.Instance.timeUntilAimMovementStateCanBeEnteredFromOtherAimMovementState;
2828

29-
protectedfloatm_timeWhenDidUnderAimDetection=0f;
29+
protecteddoublem_timeWhenDidUnderAimDetection=0f;
3030

3131

3232

@@ -262,9 +262,9 @@ protected override void UpdateAnims ()
262262
this.UpdateAimAnim(state);
263263

264264
// do this right after UpdateAimAnim(), because that's the state when weapon conducts attack
265-
if(m_isServer&&Time.time-m_timeWhenDidUnderAimDetection>=PedManager.Instance.timeIntervalToUpdateUnderAimStatus)
265+
if(m_isServer&&Time.timeAsDouble-m_timeWhenDidUnderAimDetection>=PedManager.Instance.timeIntervalToUpdateUnderAimStatus)
266266
{
267-
m_timeWhenDidUnderAimDetection=Time.time;
267+
m_timeWhenDidUnderAimDetection=Time.timeAsDouble;
268268
UpdateUnderAimDetection(m_ped);
269269
}
270270
}

‎Assets/Scripts/Behaviours/Ped/States/BaseMovementState.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static bool EnoughTimePassedToSwitchToAimState(Ped ped)
120120

121121
for(inti=0;i<aimStates.Count;i++)
122122
{
123-
if(Time.time-aimStates[i].LastTimeWhenDeactivated<PedManager.Instance.minTimeToReturnToAimState)
123+
if(Time.timeAsDouble-aimStates[i].LastTimeWhenDeactivated<PedManager.Instance.minTimeToReturnToAimState)
124124
returnfalse;
125125
}
126126

‎Assets/Scripts/Behaviours/Ped/States/BaseScriptState.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public abstract class BaseScriptState : MonoBehaviour, IPedState
2222
protectedboolm_isClientOnly=>Net.NetStatus.IsClientOnly;
2323
protectedboolm_shouldSendButtonEvents{get{return!m_isServer&&m_ped.IsControlledByLocalPlayer;}}
2424

25-
publicfloatLastTimeWhenActivated{get;set;}=0f;
26-
publicfloatTimeSinceActivated=>Time.time-this.LastTimeWhenActivated;
27-
publicfloatLastTimeWhenDeactivated{get;set;}=0f;
28-
publicfloatTimeSinceDeactivated=>Time.time-this.LastTimeWhenDeactivated;
25+
publicdoubleLastTimeWhenActivated{get;set;}=0;
26+
publicdoubleTimeSinceActivated=>Time.timeAsDouble-this.LastTimeWhenActivated;
27+
publicdoubleLastTimeWhenDeactivated{get;set;}=0;
28+
publicdoubleTimeSinceDeactivated=>Time.timeAsDouble-this.LastTimeWhenDeactivated;
2929

3030

3131

‎Assets/Scripts/Behaviours/Ped/States/DriveByState.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public WeaponAttackParams WeaponAttackParams
5050
publicfloattimeUntilAbleToEnterState=0.5f;
5151
publicfloattimeUntilAbleToExitState=0.5f;
5252

53-
privatefloatm_lastTimeWhenChangedAnim=0f;
53+
privatedoublem_lastTimeWhenChangedAnim=0f;
5454
privatestringm_lastAnim=null;
5555
publicfloattimeUntilAbleToChangeAnim=0.5f;
5656

@@ -131,10 +131,10 @@ void UpdateAnimsInternal(bool bUpdateFiring)
131131

132132
stringGetAnimBasedOnAimDirSmoothed()
133133
{
134-
if(m_lastAnim!=null&&Time.time-m_lastTimeWhenChangedAnim<this.timeUntilAbleToChangeAnim)
134+
if(m_lastAnim!=null&&Time.timeAsDouble-m_lastTimeWhenChangedAnim<this.timeUntilAbleToChangeAnim)
135135
returnm_lastAnim;
136136

137-
m_lastTimeWhenChangedAnim=Time.time;
137+
m_lastTimeWhenChangedAnim=Time.timeAsDouble;
138138

139139
m_lastAnim=this.GetAnimBasedOnAimDir();
140140
returnm_lastAnim;

‎Assets/Scripts/Behaviours/Ped/States/PanicState.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class PanicState : BaseMovementState
1919
privateconstintkFemaleSoundIndexMin=88;
2020
privateconstintkFemaleSoundIndexMax=130;
2121

22-
privatefloat_timeWhenEmittedSound=0f;
22+
privatedouble_timeWhenEmittedSound=0;
2323
publicfloatrandomAverageTimeIntervalToEmitSound=10f;
2424
privatefloat_timeToEmitSound;
2525

@@ -65,14 +65,14 @@ private Audio.SoundId GetSoundToPlay()
6565

6666
privatevoidTryEmitSound()
6767
{
68-
if(Time.time-_timeWhenEmittedSound<_timeToEmitSound)
68+
if(Time.timeAsDouble-_timeWhenEmittedSound<_timeToEmitSound)
6969
return;
7070

7171
_timeToEmitSound=Random.Range(
7272
this.randomAverageTimeIntervalToEmitSound*0.5f,
7373
this.randomAverageTimeIntervalToEmitSound*1.5f);
7474

75-
_timeWhenEmittedSound=Time.time;
75+
_timeWhenEmittedSound=Time.timeAsDouble;
7676
m_ped.PlaySoundFromPedMouth(this.GetSoundToPlay());
7777
}
7878

‎Assets/Scripts/Behaviours/PedAI/ChaseState.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace SanAndreasUnity.Behaviours.Peds.AI
77
publicclassUpdateAttackParams
88
{
99
publicboolwasInRange=false;
10-
publicfloattimeWhenAddedFireOffset=0f;
10+
publicdoubletimeWhenAddedFireOffset=0;
1111
publicfloattimeUntilOffsetChanges=1f;
1212
publicVector3newFireOffset=Vector3.zero;
1313

@@ -136,9 +136,9 @@ public bool IsInRange(Ped ped)
136136

137137
publicvoidUpdateAttackOnPed(Pedped,UpdateAttackParamsupdateAttackParams)
138138
{
139-
if(Time.time-updateAttackParams.timeWhenAddedFireOffset>updateAttackParams.timeUntilOffsetChanges)
139+
if(Time.timeAsDouble-updateAttackParams.timeWhenAddedFireOffset>updateAttackParams.timeUntilOffsetChanges)
140140
{
141-
updateAttackParams.timeWhenAddedFireOffset=Time.time;
141+
updateAttackParams.timeWhenAddedFireOffset=Time.timeAsDouble;
142142
updateAttackParams.newFireOffset=Random.onUnitSphere*0.2f;
143143
}
144144

‎Assets/Scripts/Behaviours/PedAI/WalkAroundState.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class WalkAroundState : BaseState, IPathMovementState
1414

1515
privateChaseState_chaseState;
1616

17-
privatefloat_timeWhenStartedSurrendering=0f;
18-
publicfloatTimeSinceStartedSurrendering=>Time.time-_timeWhenStartedSurrendering;
19-
publicboolIsSurrendering=>this.TimeSinceStartedSurrendering<4f;
17+
privatedouble_timeWhenStartedSurrendering=0;
18+
publicdoubleTimeSinceStartedSurrendering=>Time.timeAsDouble-_timeWhenStartedSurrendering;
19+
publicboolIsSurrendering=>this.TimeSinceStartedSurrendering<4.0;
2020

2121
publicfloatnodeSearchRadius=500f;
2222

@@ -143,7 +143,7 @@ protected internal override void OnUnderAim(IReadOnlyList<Ped.UnderAimInfo> unde
143143
return;
144144
}
145145

146-
_timeWhenStartedSurrendering=Time.time;
146+
_timeWhenStartedSurrendering=Time.timeAsDouble;
147147
}
148148

149149
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp