Fix ProximityExternalCondition ignoring the owner change event

This commit is contained in:
Gustas
2022-12-05 17:08:14 +02:00
committed by Matthias Mailänder
parent e22d7b31f9
commit ae45707c84
3 changed files with 44 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new ExternalCondition(this); }
}
public class ExternalCondition : ITick, INotifyCreated
public class ExternalCondition : ITick, INotifyCreated, INotifyOwnerChanged
{
readonly struct TimedToken
{
@@ -222,6 +222,12 @@ namespace OpenRA.Mods.Common.Traits
bool Notifies(IConditionTimerWatcher watcher) { return watcher.Condition == Info.Condition; }
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
{
foreach (var pair in self.World.ActorsWithTrait<INotifyProximityOwnerChanged>())
pair.Trait.OnProximityOwnerChanged(self, oldOwner, newOwner);
}
void INotifyCreated.Created(Actor self)
{
watchers = self.TraitsImplementing<IConditionTimerWatcher>().Where(Notifies).ToArray();