Fix an issue in EnemyWatcher.cs
This commit is contained in:
@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
lastKnownActorIds = new HashSet<uint>();
|
lastKnownActorIds = new HashSet<uint>();
|
||||||
discoveredPlayers = new HashSet<Player>();
|
discoveredPlayers = new HashSet<Player>();
|
||||||
this.info = info;
|
this.info = info;
|
||||||
rescanInterval = info.ScanInterval;
|
rescanInterval = 0;
|
||||||
ticksBeforeNextNotification = info.NotificationInterval;
|
ticksBeforeNextNotification = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here self is the player actor
|
// Here self is the player actor
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
rescanInterval--;
|
rescanInterval--;
|
||||||
ticksBeforeNextNotification--;
|
ticksBeforeNextNotification--;
|
||||||
|
|
||||||
if (rescanInterval > 0 || ticksBeforeNextNotification > 0)
|
if (rescanInterval > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rescanInterval = info.ScanInterval;
|
rescanInterval = info.ScanInterval;
|
||||||
@@ -86,11 +86,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (lastKnownActorIds.Contains(actor.Actor.ActorID))
|
if (lastKnownActorIds.Contains(actor.Actor.ActorID))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var notificationPlayed = playedNotifications.Contains(actor.Trait.Info.Notification);
|
// Should we play a sound notification?
|
||||||
|
var playNotification = !playedNotifications.Contains(actor.Trait.Info.Notification) && ticksBeforeNextNotification <= 0;
|
||||||
|
|
||||||
// Notify the actor that he has been discovered
|
// Notify the actor that he has been discovered
|
||||||
foreach (var trait in actor.Actor.TraitsImplementing<INotifyDiscovered>())
|
foreach (var trait in actor.Actor.TraitsImplementing<INotifyDiscovered>())
|
||||||
trait.OnDiscovered(actor.Actor, self.Owner, !notificationPlayed);
|
trait.OnDiscovered(actor.Actor, self.Owner, playNotification);
|
||||||
|
|
||||||
var discoveredPlayer = actor.Actor.Owner;
|
var discoveredPlayer = actor.Actor.Owner;
|
||||||
if (!discoveredPlayers.Contains(discoveredPlayer))
|
if (!discoveredPlayers.Contains(discoveredPlayer))
|
||||||
@@ -102,8 +103,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
discoveredPlayers.Add(discoveredPlayer);
|
discoveredPlayers.Add(discoveredPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have already played this type of notification
|
if (!playNotification)
|
||||||
if (notificationPlayed)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
playedNotifications.Add(actor.Trait.Info.Notification);
|
playedNotifications.Add(actor.Trait.Info.Notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user