Fix NRE when ProvidesPrerequisite is defined on the player actor.
This commit is contained in:
@@ -63,7 +63,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
protected override void Created(Actor self)
|
||||
{
|
||||
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||
// Special case handling is required for the Player actor.
|
||||
// Created is called before Player.PlayerActor is assigned,
|
||||
// so we must query other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
|
||||
techTree = playerActor.Trait<TechTree>();
|
||||
|
||||
Update();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user