From d1e9d7d19d136b853b7c4541bb70a11a8d8952e0 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 1 Oct 2014 21:27:07 +0200 Subject: [PATCH] Harvester now autoharvest when produced --- OpenRA.Mods.RA/Buildable.cs | 3 +++ OpenRA.Mods.RA/Production.cs | 4 ++++ mods/cnc/rules/vehicles.yaml | 1 + mods/d2k/rules/vehicles.yaml | 1 + mods/ra/rules/vehicles.yaml | 1 + mods/ts/rules/vehicles.yaml | 1 + 6 files changed, 11 insertions(+) diff --git a/OpenRA.Mods.RA/Buildable.cs b/OpenRA.Mods.RA/Buildable.cs index 3e5e5aecdf..c6bdcbe1aa 100755 --- a/OpenRA.Mods.RA/Buildable.cs +++ b/OpenRA.Mods.RA/Buildable.cs @@ -33,6 +33,9 @@ namespace OpenRA.Mods.RA [Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")] public readonly int BuildLimit = 0; + [Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")] + public readonly string InitialActivity = null; + // TODO: UI fluff; doesn't belong here public readonly int BuildPaletteOrder = 9999; } diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index c08f01cbe1..e460773c50 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -103,6 +103,10 @@ namespace OpenRA.Mods.RA foreach (var notify in notifyOthers) notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit); + + var bi = newUnit.Info.Traits.GetOrDefault(); + if (bi != null && bi.InitialActivity != null) + newUnit.QueueActivity(Game.CreateObject(bi.InitialActivity)); }); } diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index a712574257..0df1495b2f 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -48,6 +48,7 @@ HARV: BuildPaletteOrder: 10 Prerequisites: proc Queue: Vehicle.GDI, Vehicle.Nod + InitialActivity: FindResources Selectable: Priority: 7 Bounds: 36,36 diff --git a/mods/d2k/rules/vehicles.yaml b/mods/d2k/rules/vehicles.yaml index 870929156c..d6a9565895 100644 --- a/mods/d2k/rules/vehicles.yaml +++ b/mods/d2k/rules/vehicles.yaml @@ -46,6 +46,7 @@ HARVESTER: Queue: Armor Prerequisites: ~heavy, refinery BuildPaletteOrder: 10 + InitialActivity: FindResources Valued: Cost: 1000 Tooltip: diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index c804276bf6..635b27ff44 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -240,6 +240,7 @@ HARV: Queue: Vehicle BuildPaletteOrder: 10 Prerequisites: proc, ~techlevel.infonly + InitialActivity: FindResources Valued: Cost: 1100 Tooltip: diff --git a/mods/ts/rules/vehicles.yaml b/mods/ts/rules/vehicles.yaml index 84ece718b9..3a5ee9db85 100644 --- a/mods/ts/rules/vehicles.yaml +++ b/mods/ts/rules/vehicles.yaml @@ -74,6 +74,7 @@ HARV: Queue: Vehicle BuildPaletteOrder: 10 Owner: gdi,nod + InitialActivity: FindResources Selectable: Priority: 7 Bounds: 36,36