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:
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
class TiberiumRefineryDockActionInfo : TraitInfo<TiberiumRefineryDockAction> {}
|
class TiberiumRefineryDockActionInfo : TraitInfo<TiberiumRefineryDockAction> {}
|
||||||
|
|
||||||
class TiberiumRefineryDockAction : IAcceptOreDockAction, ITraitPrerequisite<IAcceptOre>
|
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite<IAcceptOre>
|
||||||
{
|
{
|
||||||
Actor dockedHarv = null;
|
Actor dockedHarv = null;
|
||||||
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class OreRefineryDockActionInfo : TraitInfo<OreRefineryDockAction> {}
|
class OreRefineryDockActionInfo : TraitInfo<OreRefineryDockAction> {}
|
||||||
|
|
||||||
class OreRefineryDockAction : IAcceptOreDockAction
|
class OreRefineryDockAction : IAcceptOreDockAction, INotifyCapture
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Actor dockedHarv = null;
|
||||||
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
||||||
{
|
{
|
||||||
var unit = harv.traits.Get<Unit>();
|
var unit = harv.traits.Get<Unit>();
|
||||||
@@ -41,17 +43,33 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
harv.QueueActivity (new CallFunc (() =>
|
harv.QueueActivity (new CallFunc (() =>
|
||||||
{
|
{
|
||||||
|
dockedHarv = harv;
|
||||||
var renderUnit = harv.traits.Get<RenderUnit> ();
|
var renderUnit = harv.traits.Get<RenderUnit> ();
|
||||||
if (renderUnit.anim.CurrentSequence.Name != "empty")
|
if (renderUnit.anim.CurrentSequence.Name != "empty")
|
||||||
renderUnit.PlayCustomAnimation (harv, "empty", () =>
|
renderUnit.PlayCustomAnimation (harv, "empty", () =>
|
||||||
{
|
{
|
||||||
harvester.Deliver(harv, self);
|
harvester.Deliver(harv, self);
|
||||||
|
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
||||||
|
|
||||||
if (harvester.LastHarvestedCell != int2.Zero)
|
if (harvester.LastHarvestedCell != int2.Zero)
|
||||||
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
||||||
|
|
||||||
harv.QueueActivity( new Harvest() );
|
harv.QueueActivity( new Harvest() );
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user