diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 89f6a2aabf..b4362408f3 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -1,4 +1,4 @@ - + Debug @@ -284,6 +284,7 @@ + diff --git a/OpenRA.Game/Traits/HasUnitOnBuild.cs b/OpenRA.Game/Traits/HasUnitOnBuild.cs new file mode 100644 index 0000000000..5ebdcc66e5 --- /dev/null +++ b/OpenRA.Game/Traits/HasUnitOnBuild.cs @@ -0,0 +1,35 @@ + +using System; + +namespace OpenRA.Traits +{ + + class HasUnitOnBuildInfo : ITraitInfo + { + public readonly string Unit = null; + public readonly string InitialActivity = null; + public readonly int2 SpawnOffset = int2.Zero; + public readonly int Facing = 0; + + public object Create( Actor self ) { return new HasUnitOnBuild(self); } + } + + public class HasUnitOnBuild + { + + public HasUnitOnBuild(Actor self) + { + var info = self.Info.Traits.Get(); + + self.World.AddFrameEndTask( + w => + { + var unit = w.CreateActor(info.Unit, self.Location + + info.SpawnOffset, self.Owner); + var unitTrait = unit.traits.Get(); + unitTrait.Facing = info.Facing; + //unit.QueueActivity( new Harvest() ); + }); + } + } +} diff --git a/OpenRA.Game/Traits/OreRefinery.cs b/OpenRA.Game/Traits/OreRefinery.cs index c118922e93..468ad14b29 100644 --- a/OpenRA.Game/Traits/OreRefinery.cs +++ b/OpenRA.Game/Traits/OreRefinery.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -33,15 +33,6 @@ namespace OpenRA.Traits public OreRefinery(Actor self) { this.self = self; - self.World.AddFrameEndTask( - w => - { /* create the free harvester! */ - var harvester = w.CreateActor("harv", self.Location - + new int2(1, 2), self.Owner); - var unit = harvester.traits.Get(); - unit.Facing = 64; - harvester.QueueActivity(new Harvest()); - }); } public int2 DeliverOffset { get { return new int2(1, 2); } } public void OnDock(Actor harv, DeliverOre dockOrder) diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index e4cc7d6351..9610490aaa 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -1475,6 +1475,11 @@ PROC: IronCurtainable: CustomSellValue: Value: 600 + HasUnitOnBuild: + Unit: HARV + InitialActivity: Harvest + SpawnOffset: 1,2 + Facing: 64 SILO: Inherits: ^Building