Fix remaining tech tree issues.
This commit is contained in:
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public virtual object Create(ActorInitializer init) { return new ProductionQueue(init, init.self.Owner.PlayerActor, this); }
|
public virtual object Create(ActorInitializer init) { return new ProductionQueue(init, init.self.Owner.PlayerActor, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProductionQueue : IResolveOrder, ITick, ITechTreeElement, INotifyCapture, INotifyKilled, INotifySold, ISync, INotifyTransform
|
public class ProductionQueue : IResolveOrder, ITick, ITechTreeElement, INotifyOwnerChanged, INotifyKilled, INotifySold, ISync, INotifyTransform
|
||||||
{
|
{
|
||||||
public readonly ProductionQueueInfo Info;
|
public readonly ProductionQueueInfo Info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
@@ -105,15 +105,16 @@ namespace OpenRA.Mods.RA
|
|||||||
queue.Clear();
|
queue.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
playerPower = newOwner.PlayerActor.Trait<PowerManager>();
|
playerPower = newOwner.PlayerActor.Trait<PowerManager>();
|
||||||
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
playerResources = newOwner.PlayerActor.Trait<PlayerResources>();
|
||||||
ClearQueue();
|
ClearQueue();
|
||||||
|
|
||||||
// Regenerate the produceables and tech tree state
|
// Regenerate the produceables and tech tree state
|
||||||
|
oldOwner.PlayerActor.Trait<TechTree>().Remove(this);
|
||||||
CacheProduceables(newOwner.PlayerActor);
|
CacheProduceables(newOwner.PlayerActor);
|
||||||
self.Owner.PlayerActor.Trait<TechTree>().Update();
|
newOwner.PlayerActor.Trait<TechTree>().Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Killed(Actor killed, AttackInfo e) { if (killed == self) ClearQueue(); }
|
public void Killed(Actor killed, AttackInfo e) { if (killed == self) ClearQueue(); }
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ namespace OpenRA.Mods.RA
|
|||||||
watchers.RemoveAll(x => x.Key == key);
|
watchers.RemoveAll(x => x.Key == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Remove(ITechTreeElement tte)
|
||||||
|
{
|
||||||
|
watchers.RemoveAll(x => x.RegisteredBy == tte);
|
||||||
|
}
|
||||||
|
|
||||||
static Cache<string, List<Actor>> GatherOwnedPrerequisites(Player player)
|
static Cache<string, List<Actor>> GatherOwnedPrerequisites(Player player)
|
||||||
{
|
{
|
||||||
var ret = new Cache<string, List<Actor>>(x => new List<Actor>());
|
var ret = new Cache<string, List<Actor>>(x => new List<Actor>());
|
||||||
@@ -94,6 +99,7 @@ namespace OpenRA.Mods.RA
|
|||||||
class Watcher
|
class Watcher
|
||||||
{
|
{
|
||||||
public readonly string Key;
|
public readonly string Key;
|
||||||
|
public ITechTreeElement RegisteredBy { get { return watcher; } }
|
||||||
|
|
||||||
// Strings may be either actor type, or "alternate name" key
|
// Strings may be either actor type, or "alternate name" key
|
||||||
readonly string[] prerequisites;
|
readonly string[] prerequisites;
|
||||||
|
|||||||
Reference in New Issue
Block a user