diff --git a/OpenRa.Game/Traits/Activities/DeliverOre.cs b/OpenRa.Game/Traits/Activities/DeliverOre.cs index 677cb02556..784a78d8df 100644 --- a/OpenRa.Game/Traits/Activities/DeliverOre.cs +++ b/OpenRa.Game/Traits/Activities/DeliverOre.cs @@ -2,11 +2,12 @@ namespace OpenRa.Traits.Activities { - class DeliverOre : IActivity + public class DeliverOre : IActivity { public IActivity NextActivity { get; set; } bool isDone; + bool isDocking; Actor refinery; public DeliverOre() { } @@ -15,29 +16,19 @@ namespace OpenRa.Traits.Activities { this.refinery = refinery; } - - // TODO: This belongs on the refinery itself - static readonly int2 refineryDeliverOffset = new int2( 1, 2 ); public IActivity Tick( Actor self ) { var unit = self.traits.Get(); var mobile = self.traits.Get(); - if( isDone ) - { - self.traits.Get().Deliver( self, refinery ); - - refinery.traits.Get().OnDock(self); - return NextActivity ?? new Harvest(); - } - else if( NextActivity != null ) + if( NextActivity != null ) return NextActivity; if( refinery != null && refinery.IsDead ) refinery = null; - if( refinery == null || self.Location != refinery.Location + refineryDeliverOffset ) + if( refinery == null || self.Location != refinery.Location + refinery.traits.Get().DeliverOffset ) { var search = new PathSearch { @@ -49,25 +40,27 @@ namespace OpenRa.Traits.Activities .Where(x => x.traits.Contains()) .ToList(); if( refinery != null ) - search.AddInitialCell( self.World, refinery.Location + refineryDeliverOffset ); + search.AddInitialCell(self.World, refinery.Location + refinery.traits.Get().DeliverOffset); else foreach( var r in refineries ) - search.AddInitialCell( self.World, r.Location + refineryDeliverOffset ); + search.AddInitialCell(self.World, r.Location + r.traits.Get().DeliverOffset); var path = self.World.PathFinder.FindPath( search ); path.Reverse(); if( path.Count != 0 ) { - refinery = refineries.FirstOrDefault( x => x.Location + refineryDeliverOffset == path[ 0 ] ); + refinery = refineries.FirstOrDefault(x => x.Location + x.traits.Get().DeliverOffset == path[0]); return new Move( () => path ) { NextActivity = this }; } else // no refineries reachable? return this; } - // TODO: This belongs in the refinery trait - else if( unit.Facing != 64 ) - return new Turn( 64 ) { NextActivity = this }; + else if (!isDocking) + { + isDocking = true; + refinery.traits.Get().OnDock(self, this); + } var renderUnit = self.traits.Get(); if( renderUnit.anim.CurrentSequence.Name != "empty" ) diff --git a/OpenRa.Game/Traits/OreRefinery.cs b/OpenRa.Game/Traits/OreRefinery.cs index 744b17a5a7..19b5e00693 100644 --- a/OpenRa.Game/Traits/OreRefinery.cs +++ b/OpenRa.Game/Traits/OreRefinery.cs @@ -9,8 +9,10 @@ namespace OpenRa.Traits class OreRefinery : IAcceptOre { + Actor self; public OreRefinery(Actor self) { + this.self = self; self.World.AddFrameEndTask( w => { /* create the free harvester! */ @@ -21,7 +23,16 @@ namespace OpenRa.Traits harvester.QueueActivity(new Harvest()); }); } - - public void OnDock(Actor harv) {} + public int2 DeliverOffset { get { return new int2(1, 2); } } + public void OnDock(Actor harv, DeliverOre dockOrder) + { + var unit = harv.traits.Get(); + if (unit.Facing != 64) + harv.QueueActivity(new Turn(64)); + + // TODO: This should be delayed until the turn order is complete + harv.traits.Get().Deliver(harv, self); + harv.QueueActivity(new Harvest()); + } } } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index d8e26e5f44..0ecc27b89e 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -65,7 +65,7 @@ namespace OpenRa.Traits () => anim.PlayRepeating(GetPrefix(self) + "idle")); } - public void PlayCustomAnim(Actor self, string name, Action a) + public void PlayCustomAnimThen(Actor self, string name, Action a) { anim.PlayThen(GetPrefix(self) + name, () => { anim.PlayRepeating(GetPrefix(self) + "idle"); a(); }); diff --git a/OpenRa.Game/Traits/TiberiumRefinery.cs b/OpenRa.Game/Traits/TiberiumRefinery.cs index 1a70cb5613..7e9aa45d2c 100644 --- a/OpenRa.Game/Traits/TiberiumRefinery.cs +++ b/OpenRa.Game/Traits/TiberiumRefinery.cs @@ -16,7 +16,7 @@ namespace OpenRa.Traits self.World.AddFrameEndTask( w => { /* create the free harvester! */ - var harvester = w.CreateActor("harv", self.Location + new int2(1, 2), self.Owner); + var harvester = w.CreateActor("harv", self.Location + new int2(0, 2), self.Owner); var unit = harvester.traits.Get(); var mobile = harvester.traits.Get(); unit.Facing = 64; @@ -24,9 +24,19 @@ namespace OpenRa.Traits }); } - public void OnDock(Actor harv) + public int2 DeliverOffset { get { return new int2(0, 2); } } + public void OnDock(Actor harv, DeliverOre dockOrder) { - self.traits.Get().PlayCustomAnim(self, "active"); + var unit = harv.traits.Get(); + harv.QueueActivity(new Move(self.Location + DeliverOffset, self)); + harv.QueueActivity(new Turn(96)); + + // TODO: This should be delayed until the turn order is complete + self.traits.Get().PlayCustomAnimThen(self, "active", () => { + harv.traits.Get().Deliver(harv, self); + harv.QueueActivity(new Move(self.Location + DeliverOffset, self)); + harv.QueueActivity(new Harvest()); + }); } } } diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index bb39087406..534039cc47 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -3,6 +3,7 @@ using System.Drawing; using IjwFramework.Types; using OpenRa.GameRules; using OpenRa.Graphics; +using OpenRa.Traits.Activities; namespace OpenRa.Traits { @@ -21,7 +22,11 @@ namespace OpenRa.Traits public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyProduction { void UnitProduced(Actor self, Actor other); } - public interface IAcceptOre { void OnDock(Actor harv); } + public interface IAcceptOre + { + void OnDock(Actor harv, DeliverOre dockOrder); + int2 DeliverOffset { get; } + } public interface IAcceptThief { void OnSteal(Actor self, Actor thief); } public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } diff --git a/mods/cnc/minimal.ini b/mods/cnc/minimal.ini index 562c3ea8c0..a6d3813237 100644 --- a/mods/cnc/minimal.ini +++ b/mods/cnc/minimal.ini @@ -8,7 +8,7 @@ RefundPercent=50% ; percent of original cost to refund when building/unit RepairRate=.016 ; minutes between applying repair step URepairPercent=20% ; [units only] percent cost to fully repair as ratio of full cost URepairStep=10 ; [units only] hit points to heal per repair 'tick' for units -BuildSpeed=.8 ; general build speed [time (in minutes) to produce a 1000 credit cost item] +BuildSpeed=.1 ; general build speed [time (in minutes) to produce a 1000 credit cost item] OreGrows=yes ; Does ore grow denser over time? OreSpreads=yes ; Does ore spread into adjacent areas diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml index 6597e5bee1..d8bf52d8b5 100644 --- a/mods/cnc/structures.yaml +++ b/mods/cnc/structures.yaml @@ -46,7 +46,7 @@ PROC: LongDesc: Processes Tiberium into useable resources Building: Power: -30 - Footprint: ___ xxx x=x + Footprint: ___ xxx === Dimensions: 3,3 Capturable: true Bib: yes