diff --git a/AUTHORS b/AUTHORS index df398d4025..dd142f5b54 100644 --- a/AUTHORS +++ b/AUTHORS @@ -56,6 +56,7 @@ Also thanks to: * Olaf van der Spek * Paolo Chiodi (paolochiodi) * Paul Dovydaitis (pdovy) + * Pizzaoverhead * Psydev * Raymond Martineau (mart0258) * Reaperrr diff --git a/CHANGELOG b/CHANGELOG index 824df5800c..81690d33d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ NEW: Added an Extras submenu for miscellaneous game extras. Engineers can now regain control over husks. A player's units, and allied units, now move out of the way when blocking production facilities. + Added cheat button to grow map resources. Dune 2000: Added the Atreides grenadier from the 1.06 patch. Added randomized tiles for Sand and Rock terrain. diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index b700326a38..0ac7f34259 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -13,6 +13,7 @@ namespace OpenRA.Traits public class DeveloperModeInfo : ITraitInfo { public int Cash = 20000; + public int ResourceGrowth = 100; public bool FastBuild = false; public bool FastCharge = false; public bool DisableShroud = false; @@ -79,6 +80,15 @@ namespace OpenRA.Traits self.Trait().GiveCash(Info.Cash); break; } + case "DevGrowResources": + { + foreach (var a in self.World.ActorsWithTrait()) + { + for (var i = 0; i < Info.ResourceGrowth; i++) + a.Trait.Seed(a.Actor); + } + break; + } case "DevShroudDisable": { DisableShroud ^= true; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 999d42b78e..4ec93f80e9 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -75,6 +75,7 @@ namespace OpenRA.Traits public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); } public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } public interface INotifyHarvest { void Harvested(Actor self, ResourceType resource); } + public interface ISeedableResource { void Seed(Actor self); } public interface IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); } public interface IDemolishable diff --git a/OpenRA.Mods.RA/SeedsResource.cs b/OpenRA.Mods.RA/SeedsResource.cs index f762b21117..a61e34c959 100644 --- a/OpenRA.Mods.RA/SeedsResource.cs +++ b/OpenRA.Mods.RA/SeedsResource.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA public readonly int AnimationInterval = 750; } - class SeedsResource : ITick + class SeedsResource : ITick, ISeedableResource { int ticks; int animationTicks; @@ -33,27 +33,8 @@ namespace OpenRA.Mods.RA { if (--ticks <= 0) { - var info = self.Info.Traits.Get(); - var resourceType = self.World.WorldActor - .TraitsImplementing() - .FirstOrDefault(t => t.Info.Name == info.ResourceType); - - if (resourceType == null) - throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType)); - - var resLayer = self.World.WorldActor.Trait(); - - var cell = RandomWalk(self.Location, self.World.SharedRandom) - .Take(info.MaxRange) - .SkipWhile(p => resLayer.GetResource(p) == resourceType && resLayer.IsFull(p.X, p.Y)) - .Cast().FirstOrDefault(); - - if (cell != null && self.World.Map.IsInMap(cell.Value) && - (resLayer.GetResource(cell.Value) == resourceType - || (resLayer.GetResource(cell.Value) == null && resLayer.AllowResourceAt(resourceType, cell.Value)))) - resLayer.AddResource(resourceType, cell.Value, 1); - - ticks = info.Interval; + Seed(self); + ticks = self.Info.Traits.Get().Interval; } if (--animationTicks <= 0) @@ -64,6 +45,30 @@ namespace OpenRA.Mods.RA } } + public void Seed(Actor self) + { + var info = self.Info.Traits.Get(); + var resourceType = self.World.WorldActor + .TraitsImplementing() + .FirstOrDefault(t => t.Info.Name == info.ResourceType); + + if (resourceType == null) + throw new InvalidOperationException("No such resource type `{0}`".F(info.ResourceType)); + + var resLayer = self.World.WorldActor.Trait(); + + var cell = RandomWalk(self.Location, self.World.SharedRandom) + .Take(info.MaxRange) + .SkipWhile(p => resLayer.GetResource(p) == resourceType && resLayer.IsFull(p.X, p.Y)) + .Cast().FirstOrDefault(); + + if (cell != null && self.World.Map.IsInMap(cell.Value) && + (resLayer.GetResource(cell.Value) == resourceType + || (resLayer.GetResource(cell.Value) == null && resLayer.AllowResourceAt(resourceType, cell.Value)))) + resLayer.AddResource(resourceType, cell.Value, 1); + + } + static IEnumerable RandomWalk(CPos p, Thirdparty.Random r) { for (; ; ) diff --git a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs index 7fd5e9e7ae..37b2ce9c34 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/CheatsLogic.cs @@ -43,6 +43,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic cashButton.OnClick = () => world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false)); + var growResourcesButton = widget.GetOrNull("GROW_RESOURCES"); + if (growResourcesButton != null) + growResourcesButton.OnClick = () => + world.IssueOrder(new Order("DevGrowResources", world.LocalPlayer.PlayerActor, false)); + var fastBuildCheckbox = widget.GetOrNull("INSTANT_BUILD"); if (fastBuildCheckbox != null) { diff --git a/mods/cnc/chrome/cheats.yaml b/mods/cnc/chrome/cheats.yaml index 7be077c94e..a8ce0f4e0c 100644 --- a/mods/cnc/chrome/cheats.yaml +++ b/mods/cnc/chrome/cheats.yaml @@ -64,53 +64,59 @@ Container@CHEATS_PANEL: Font:Regular Text:Disable Shroud & Fog Button@GIVE_CASH: - X:20 - Y:155 + X:90 + Y:145 Width:140 Height:35 Text:Give $20,000 + Button@GROW_RESOURCES: + X:271 + Y:145 + Width:140 + Height:35 + Text:Grow Resources Button@GIVE_EXPLORATION: - X:186 - Y:155 + X:90 + Y:195 Width:140 Height:35 Text:Clear Shroud Button@RESET_EXPLORATION: - X:352 - Y:155 + X:271 + Y:195 Width:140 Height:35 Text:Reset Shroud Label@VISUALIZATIONS_TITLE: - Y:215 + Y:255 Font:Bold Text:Visualizations Align:Center Width:PARENT_RIGHT Checkbox@SHOW_UNIT_PATHS: X:45 - Y:235 + Y:285 Width:200 Height:20 Font:Regular Text:Show Unit Paths Checkbox@SHOW_ASTAR: X:45 - Y:265 + Y:315 Height:20 Width:200 Font:Regular Text:Show A* Cost Checkbox@SHOW_COMBATOVERLAY: X:290 - Y:235 + Y:285 Height:20 Width:200 Font:Regular Text:Show Combat Geometry Checkbox@SHOW_GEOMETRY: X:290 - Y:265 + Y:315 Height:20 Width:200 Font:Regular diff --git a/mods/cnc/chrome/ingamemenu.yaml b/mods/cnc/chrome/ingamemenu.yaml index 1d5447483d..c1cbb08689 100644 --- a/mods/cnc/chrome/ingamemenu.yaml +++ b/mods/cnc/chrome/ingamemenu.yaml @@ -2,7 +2,7 @@ Container@INGAME_MENU_PANEL: X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:512 - Height:320 + Height:370 Children: Button@OBJECTIVES_BUTTON: Y:PARENT_BOTTOM - 1 diff --git a/mods/cnc/chrome/objectives.yaml b/mods/cnc/chrome/objectives.yaml index 334adda0ce..73f757d287 100644 --- a/mods/cnc/chrome/objectives.yaml +++ b/mods/cnc/chrome/objectives.yaml @@ -10,8 +10,8 @@ Container@CONQUEST_OBJECTIVES: Contrast:true Align:Center Background@bg: - Width:512 - Height:320 + Width:PARENT_RIGHT + Height:PARENT_BOTTOM Background:panel-black Children: Label@PRIMARY: @@ -80,7 +80,7 @@ Container@CONQUEST_OBJECTIVES: X:15 Y:105 Width:482 - Height:200 + Height:250 ItemSpacing:5 Children: Container@PLAYER_TEMPLATE: diff --git a/mods/ra/chrome/cheats.yaml b/mods/ra/chrome/cheats.yaml index fcb9c6bc1d..fdc81888de 100644 --- a/mods/ra/chrome/cheats.yaml +++ b/mods/ra/chrome/cheats.yaml @@ -41,10 +41,17 @@ Background@CHEATS_PANEL: Button@GIVE_CASH: X:30 Y:140 - Width:150 + Width:135 Height:20 Text: Give $20000 Cash Height:25 + Button@GROW_RESOURCES: + X:185 + Y:140 + Width:135 + Height:20 + Text: Grow Resources + Height:25 Checkbox@INSTANT_BUILD: X:30 Y:170