Fix GrantConditionOnPrerequisite not refreshing when the actor's owner changes
This commit is contained in:
@@ -29,15 +29,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(init.Self, this); }
|
public object Create(ActorInitializer init) { return new GrantConditionOnPrerequisite(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GrantConditionOnPrerequisite : INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld
|
public class GrantConditionOnPrerequisite : INotifyCreated, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
readonly GrantConditionOnPrerequisiteInfo info;
|
readonly GrantConditionOnPrerequisiteInfo info;
|
||||||
readonly GrantConditionOnPrerequisiteManager globalManager;
|
|
||||||
|
|
||||||
ConditionManager conditionManager;
|
|
||||||
int conditionToken = ConditionManager.InvalidConditionToken;
|
|
||||||
|
|
||||||
bool wasAvailable;
|
bool wasAvailable;
|
||||||
|
ConditionManager conditionManager;
|
||||||
|
GrantConditionOnPrerequisiteManager globalManager;
|
||||||
|
int conditionToken = ConditionManager.InvalidConditionToken;
|
||||||
|
|
||||||
public GrantConditionOnPrerequisite(Actor self, GrantConditionOnPrerequisiteInfo info)
|
public GrantConditionOnPrerequisite(Actor self, GrantConditionOnPrerequisiteInfo info)
|
||||||
{
|
{
|
||||||
@@ -62,6 +61,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
globalManager.Unregister(self, this, info.Prerequisites);
|
globalManager.Unregister(self, this, info.Prerequisites);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
{
|
||||||
|
globalManager = newOwner.PlayerActor.Trait<GrantConditionOnPrerequisiteManager>();
|
||||||
|
}
|
||||||
|
|
||||||
public void PrerequisitesUpdated(Actor self, bool available)
|
public void PrerequisitesUpdated(Actor self, bool available)
|
||||||
{
|
{
|
||||||
if (available == wasAvailable || conditionManager == null)
|
if (available == wasAvailable || conditionManager == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user