Added debug cheat button to grow map resources.

This commit is contained in:
Pizzaoverhead
2014-02-15 17:30:36 +00:00
parent c3b5495177
commit e0b40e2088
10 changed files with 74 additions and 38 deletions

View File

@@ -56,6 +56,7 @@ Also thanks to:
* Olaf van der Spek * Olaf van der Spek
* Paolo Chiodi (paolochiodi) * Paolo Chiodi (paolochiodi)
* Paul Dovydaitis (pdovy) * Paul Dovydaitis (pdovy)
* Pizzaoverhead
* Psydev * Psydev
* Raymond Martineau (mart0258) * Raymond Martineau (mart0258)
* Reaperrr * Reaperrr

View File

@@ -9,6 +9,7 @@ NEW:
Added an Extras submenu for miscellaneous game extras. Added an Extras submenu for miscellaneous game extras.
Engineers can now regain control over husks. Engineers can now regain control over husks.
A player's units, and allied units, now move out of the way when blocking production facilities. 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: Dune 2000:
Added the Atreides grenadier from the 1.06 patch. Added the Atreides grenadier from the 1.06 patch.
Added randomized tiles for Sand and Rock terrain. Added randomized tiles for Sand and Rock terrain.

View File

@@ -13,6 +13,7 @@ namespace OpenRA.Traits
public class DeveloperModeInfo : ITraitInfo public class DeveloperModeInfo : ITraitInfo
{ {
public int Cash = 20000; public int Cash = 20000;
public int ResourceGrowth = 100;
public bool FastBuild = false; public bool FastBuild = false;
public bool FastCharge = false; public bool FastCharge = false;
public bool DisableShroud = false; public bool DisableShroud = false;
@@ -79,6 +80,15 @@ namespace OpenRA.Traits
self.Trait<PlayerResources>().GiveCash(Info.Cash); self.Trait<PlayerResources>().GiveCash(Info.Cash);
break; break;
} }
case "DevGrowResources":
{
foreach (var a in self.World.ActorsWithTrait<ISeedableResource>())
{
for (var i = 0; i < Info.ResourceGrowth; i++)
a.Trait.Seed(a.Actor);
}
break;
}
case "DevShroudDisable": case "DevShroudDisable":
{ {
DisableShroud ^= true; DisableShroud ^= true;

View File

@@ -75,6 +75,7 @@ namespace OpenRA.Traits
public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); } 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 INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); }
public interface INotifyHarvest { void Harvested(Actor self, ResourceType resource); } 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 IAcceptInfiltrator { void OnInfiltrate(Actor self, Actor infiltrator); }
public interface IDemolishable public interface IDemolishable

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
public readonly int AnimationInterval = 750; public readonly int AnimationInterval = 750;
} }
class SeedsResource : ITick class SeedsResource : ITick, ISeedableResource
{ {
int ticks; int ticks;
int animationTicks; int animationTicks;
@@ -33,27 +33,8 @@ namespace OpenRA.Mods.RA
{ {
if (--ticks <= 0) if (--ticks <= 0)
{ {
var info = self.Info.Traits.Get<SeedsResourceInfo>(); Seed(self);
var resourceType = self.World.WorldActor ticks = self.Info.Traits.Get<SeedsResourceInfo>().Interval;
.TraitsImplementing<ResourceType>()
.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<ResourceLayer>();
var cell = RandomWalk(self.Location, self.World.SharedRandom)
.Take(info.MaxRange)
.SkipWhile(p => resLayer.GetResource(p) == resourceType && resLayer.IsFull(p.X, p.Y))
.Cast<CPos?>().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;
} }
if (--animationTicks <= 0) if (--animationTicks <= 0)
@@ -64,6 +45,30 @@ namespace OpenRA.Mods.RA
} }
} }
public void Seed(Actor self)
{
var info = self.Info.Traits.Get<SeedsResourceInfo>();
var resourceType = self.World.WorldActor
.TraitsImplementing<ResourceType>()
.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<ResourceLayer>();
var cell = RandomWalk(self.Location, self.World.SharedRandom)
.Take(info.MaxRange)
.SkipWhile(p => resLayer.GetResource(p) == resourceType && resLayer.IsFull(p.X, p.Y))
.Cast<CPos?>().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<CPos> RandomWalk(CPos p, Thirdparty.Random r) static IEnumerable<CPos> RandomWalk(CPos p, Thirdparty.Random r)
{ {
for (; ; ) for (; ; )

View File

@@ -43,6 +43,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
cashButton.OnClick = () => cashButton.OnClick = () =>
world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false)); world.IssueOrder(new Order("DevGiveCash", world.LocalPlayer.PlayerActor, false));
var growResourcesButton = widget.GetOrNull<ButtonWidget>("GROW_RESOURCES");
if (growResourcesButton != null)
growResourcesButton.OnClick = () =>
world.IssueOrder(new Order("DevGrowResources", world.LocalPlayer.PlayerActor, false));
var fastBuildCheckbox = widget.GetOrNull<CheckboxWidget>("INSTANT_BUILD"); var fastBuildCheckbox = widget.GetOrNull<CheckboxWidget>("INSTANT_BUILD");
if (fastBuildCheckbox != null) if (fastBuildCheckbox != null)
{ {

View File

@@ -64,53 +64,59 @@ Container@CHEATS_PANEL:
Font:Regular Font:Regular
Text:Disable Shroud & Fog Text:Disable Shroud & Fog
Button@GIVE_CASH: Button@GIVE_CASH:
X:20 X:90
Y:155 Y:145
Width:140 Width:140
Height:35 Height:35
Text:Give $20,000 Text:Give $20,000
Button@GROW_RESOURCES:
X:271
Y:145
Width:140
Height:35
Text:Grow Resources
Button@GIVE_EXPLORATION: Button@GIVE_EXPLORATION:
X:186 X:90
Y:155 Y:195
Width:140 Width:140
Height:35 Height:35
Text:Clear Shroud Text:Clear Shroud
Button@RESET_EXPLORATION: Button@RESET_EXPLORATION:
X:352 X:271
Y:155 Y:195
Width:140 Width:140
Height:35 Height:35
Text:Reset Shroud Text:Reset Shroud
Label@VISUALIZATIONS_TITLE: Label@VISUALIZATIONS_TITLE:
Y:215 Y:255
Font:Bold Font:Bold
Text:Visualizations Text:Visualizations
Align:Center Align:Center
Width:PARENT_RIGHT Width:PARENT_RIGHT
Checkbox@SHOW_UNIT_PATHS: Checkbox@SHOW_UNIT_PATHS:
X:45 X:45
Y:235 Y:285
Width:200 Width:200
Height:20 Height:20
Font:Regular Font:Regular
Text:Show Unit Paths Text:Show Unit Paths
Checkbox@SHOW_ASTAR: Checkbox@SHOW_ASTAR:
X:45 X:45
Y:265 Y:315
Height:20 Height:20
Width:200 Width:200
Font:Regular Font:Regular
Text:Show A* Cost Text:Show A* Cost
Checkbox@SHOW_COMBATOVERLAY: Checkbox@SHOW_COMBATOVERLAY:
X:290 X:290
Y:235 Y:285
Height:20 Height:20
Width:200 Width:200
Font:Regular Font:Regular
Text:Show Combat Geometry Text:Show Combat Geometry
Checkbox@SHOW_GEOMETRY: Checkbox@SHOW_GEOMETRY:
X:290 X:290
Y:265 Y:315
Height:20 Height:20
Width:200 Width:200
Font:Regular Font:Regular

View File

@@ -2,7 +2,7 @@ Container@INGAME_MENU_PANEL:
X:(WINDOW_RIGHT - WIDTH)/2 X:(WINDOW_RIGHT - WIDTH)/2
Y:(WINDOW_BOTTOM - HEIGHT)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2
Width:512 Width:512
Height:320 Height:370
Children: Children:
Button@OBJECTIVES_BUTTON: Button@OBJECTIVES_BUTTON:
Y:PARENT_BOTTOM - 1 Y:PARENT_BOTTOM - 1

View File

@@ -10,8 +10,8 @@ Container@CONQUEST_OBJECTIVES:
Contrast:true Contrast:true
Align:Center Align:Center
Background@bg: Background@bg:
Width:512 Width:PARENT_RIGHT
Height:320 Height:PARENT_BOTTOM
Background:panel-black Background:panel-black
Children: Children:
Label@PRIMARY: Label@PRIMARY:
@@ -80,7 +80,7 @@ Container@CONQUEST_OBJECTIVES:
X:15 X:15
Y:105 Y:105
Width:482 Width:482
Height:200 Height:250
ItemSpacing:5 ItemSpacing:5
Children: Children:
Container@PLAYER_TEMPLATE: Container@PLAYER_TEMPLATE:

View File

@@ -41,10 +41,17 @@ Background@CHEATS_PANEL:
Button@GIVE_CASH: Button@GIVE_CASH:
X:30 X:30
Y:140 Y:140
Width:150 Width:135
Height:20 Height:20
Text: Give $20000 Cash Text: Give $20000 Cash
Height:25 Height:25
Button@GROW_RESOURCES:
X:185
Y:140
Width:135
Height:20
Text: Grow Resources
Height:25
Checkbox@INSTANT_BUILD: Checkbox@INSTANT_BUILD:
X:30 X:30
Y:170 Y:170