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
* Paolo Chiodi (paolochiodi)
* Paul Dovydaitis (pdovy)
* Pizzaoverhead
* Psydev
* Raymond Martineau (mart0258)
* Reaperrr

View File

@@ -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.

View File

@@ -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<PlayerResources>().GiveCash(Info.Cash);
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":
{
DisableShroud ^= true;

View File

@@ -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

View File

@@ -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<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);
ticks = info.Interval;
Seed(self);
ticks = self.Info.Traits.Get<SeedsResourceInfo>().Interval;
}
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)
{
for (; ; )

View File

@@ -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<ButtonWidget>("GROW_RESOURCES");
if (growResourcesButton != null)
growResourcesButton.OnClick = () =>
world.IssueOrder(new Order("DevGrowResources", world.LocalPlayer.PlayerActor, false));
var fastBuildCheckbox = widget.GetOrNull<CheckboxWidget>("INSTANT_BUILD");
if (fastBuildCheckbox != null)
{

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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