From 51a99cb43cf275735ba6bd97b89a51ce4f1c25e2 Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Thu, 26 Jul 2018 20:22:22 +0200 Subject: [PATCH] Special-case the player actor on GCOnBotOwner. --- .../Traits/Conditions/GrantConditionOnBotOwner.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs index 27bb5199ca..2740ebf089 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnBotOwner.cs @@ -44,9 +44,16 @@ namespace OpenRA.Mods.Common.Traits void INotifyCreated.Created(Actor self) { - conditionManager = self.TraitOrDefault(); - if (conditionManager != null && self.Owner.IsBot && info.Bots.Contains(self.Owner.BotType)) - conditionToken = conditionManager.GrantCondition(self, info.Condition); + // Special case handling is required for the Player actor. + // Created is called before Player.IsBot is set, so we + // must use a different method to enable this trait if + // it's defined on the PlayerActor. + self.World.AddFrameEndTask(w => + { + conditionManager = self.TraitOrDefault(); + if (conditionManager != null && self.Owner.IsBot && info.Bots.Contains(self.Owner.BotType)) + conditionToken = conditionManager.GrantCondition(self, info.Condition); + }); } void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)