Steal docked harv on proc capture (needs multiplayer testing); framework for canceling dock on proc death/sell (needs further activity changes)

This commit is contained in:
Paul Chote
2010-06-16 19:47:15 +12:00
parent f0a2bf128c
commit 5ed8113d8e
2 changed files with 48 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc
{
class TiberiumRefineryDockActionInfo : TraitInfo<TiberiumRefineryDockAction> {}
class TiberiumRefineryDockAction : IAcceptOreDockAction, ITraitPrerequisite<IAcceptOre>
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite<IAcceptOre>
{
Actor dockedHarv = null;
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
@@ -64,5 +64,32 @@ namespace OpenRA.Mods.Cnc
}) );
}
void CancelDock(Actor self, Actor harv)
{
// Todo: Cancel the above activities that are non-cancelable
}
public void Selling (Actor self) { CancelDock(self, dockedHarv); }
public void Sold (Actor self) {}
public void Damaged (Actor self, AttackInfo e)
{
if (self.IsDead)
CancelDock(self, dockedHarv);
}
public void OnCapture (Actor self, Actor captor)
{
if (dockedHarv == null)
return;
dockedHarv.World.AddFrameEndTask(w =>
{
// momentarily remove from world so the ownership queries don't get confused
w.Remove(dockedHarv);
dockedHarv.Owner = captor.Owner;
w.Add(dockedHarv);
});
}
}
}