Assign Player.IsBot before calling INotifyCreated.Created
This commit is contained in:
@@ -166,6 +166,9 @@ namespace OpenRA
|
||||
if (!Spectating)
|
||||
PlayerMask = new LongBitSet<PlayerBitMask>(InternalName);
|
||||
|
||||
// Set this property before running any Created callbacks on the player actor
|
||||
IsBot = BotType != null;
|
||||
|
||||
// Special case handling is required for the Player actor:
|
||||
// Since Actor.Created would be called before PlayerActor is assigned here
|
||||
// querying player traits in INotifyCreated.Created would crash.
|
||||
@@ -179,7 +182,6 @@ namespace OpenRA
|
||||
FrozenActorLayer = PlayerActor.TraitOrDefault<FrozenActorLayer>();
|
||||
|
||||
// Enable the bot logic on the host
|
||||
IsBot = BotType != null;
|
||||
if (IsBot && Game.IsHost)
|
||||
{
|
||||
var logic = PlayerActor.TraitsImplementing<IBot>().FirstOrDefault(b => b.Info.Type == BotType);
|
||||
|
||||
@@ -42,15 +42,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
// 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 =>
|
||||
{
|
||||
if (self.Owner.IsBot && info.Bots.Contains(self.Owner.BotType))
|
||||
conditionToken = self.GrantCondition(info.Condition);
|
||||
});
|
||||
if (self.Owner.IsBot && info.Bots.Contains(self.Owner.BotType))
|
||||
conditionToken = self.GrantCondition(info.Condition);
|
||||
}
|
||||
|
||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
|
||||
Reference in New Issue
Block a user