@@ -493,7 +493,8 @@ public static WorldLocation UidLocation(UiD uid)
493
493
public class SoundSource : SoundSourceBase
494
494
{
495
495
/// <summary>
496
- /// Squeared cutoff distance. No sound is audible above that
496
+ /// Squared cutoff distance. No sound is audible above that, except for the actual player train,
497
+ /// where cutoff occurs at a distance wich is higher than the train length
497
498
/// </summary>
498
499
private const int CUTOFFDISTANCE = 4000000 ;
499
500
/// <summary>
@@ -1009,13 +1010,15 @@ public bool isOutOfDistance()
1009
1010
float . IsNaN ( WorldLocation . Location . Y ) ||
1010
1011
float . IsNaN ( WorldLocation . Location . Z ) )
1011
1012
{
1012
- DistanceSquared = CUTOFFDISTANCE + 1 ;
1013
+ DistanceSquared = ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1014
+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) : CUTOFFDISTANCE ) + 1 ;
1013
1015
return true ;
1014
1016
}
1015
1017
1016
1018
DistanceSquared = WorldLocation . GetDistanceSquared ( WorldLocation , Viewer . Camera . CameraWorldLocation ) ;
1017
1019
1018
- return DistanceSquared > CUTOFFDISTANCE ;
1020
+ return DistanceSquared > ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1021
+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) ;
1019
1022
}
1020
1023
1021
1024
/// <summary>
@@ -1034,7 +1037,8 @@ public bool Activate()
1034
1037
{
1035
1038
// (ActivationConditions.Distance == 0) means distance checking disabled
1036
1039
if ( ( ActivationConditions . Distance == 0 || DistanceSquared < ActivationConditions . Distance * ActivationConditions . Distance ) &&
1037
- DistanceSquared < CUTOFFDISTANCE )
1040
+ DistanceSquared < ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1041
+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) )
1038
1042
return true ;
1039
1043
}
1040
1044
else
@@ -1059,7 +1063,8 @@ public bool DeActivate()
1059
1063
if ( WorldLocation != WorldLocation . None )
1060
1064
{
1061
1065
if ( DeactivationConditions . Distance != 0 && DistanceSquared > DeactivationConditions . Distance * DeactivationConditions . Distance ||
1062
- DistanceSquared > CUTOFFDISTANCE )
1066
+ DistanceSquared > ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1067
+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) )
1063
1068
return true ;
1064
1069
}
1065
1070
0 commit comments