From c749fcfce300fdfdede255c44e299611426e9f85 Mon Sep 17 00:00:00 2001 From: alzeih Date: Sun, 25 Jul 2010 18:14:05 +1200 Subject: [PATCH] Nearly There --- OpenRA.Game/Traits/Player/DeveloperMode.cs | 38 ++++++++++++------- OpenRA.Game/Traits/Player/PlayerResources.cs | 19 +++++++++- OpenRA.Game/Traits/Player/ProductionQueue.cs | 1 + OpenRA.Game/Traits/SupportPower.cs | 1 + .../Delegates/DeveloperModeDelegate.cs | 4 +- .../SupportPowers/AirstrikePower.cs | 2 +- 6 files changed, 48 insertions(+), 17 deletions(-) diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index fe3e4ed2bf..385c036142 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -13,34 +13,44 @@ namespace OpenRA.Traits { public class DeveloperModeInfo : ITraitInfo { - public int InitialCash = 20000; - public int BuildSpeed = 1; - public int ChargeTime = 1; - - public object Create(ActorInitializer init) { return new DeveloperMode(this); } + public int Cash = 20000; + public bool FastBuild = false; + public bool FastCharge = false; + public object Create (ActorInitializer init) { return new DeveloperMode(this); } } public class DeveloperMode : IResolveOrder { DeveloperModeInfo Info; - public DeveloperMode (DeveloperModeInfo info) + [Sync] + public bool FastCharge; + public bool FastBuild; + + public DeveloperMode(DeveloperModeInfo info) { Info = info; + FastBuild = Info.FastBuild; + FastCharge = Info.FastCharge; } - + public void ResolveOrder (Actor self, Order order) { - switch (order.OrderString) + switch(order.OrderString) { - case "DevModeGiveCash": - self.World.AddFrameEndTask( w => - { - self.Owner.PlayerActor.traits.Get().GiveCash(Info.InitialCash); - }); - break; + case "DevModeFastCharge": + { + FastCharge ^= true; + break; + } + case "DevModeFastBuild": + { + FastBuild ^= true; + break; + } } } + } } diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index d5fcac06d5..49d0def360 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -22,7 +22,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new PlayerResources(init.self); } } - public class PlayerResources : ITick + public class PlayerResources : ITick, IResolveOrder { Player Owner; int AdviceInterval; @@ -187,5 +187,22 @@ namespace OpenRA.Traits TickPower(); TickOre(self); } + + public void ResolveOrder (Actor self, Order order) + { + switch (order.OrderString) + { + case "DevModeGiveCash": + { + if (!Game.LobbyInfo.GlobalSettings.AllowCheats) break; + self.World.AddFrameEndTask( w => + { + var amt = order.Subject.Info.Traits.Get().Cash; + GiveCash(amt); + }); + } + break; + } + } } } diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index e21835cb26..301577538c 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -101,6 +101,7 @@ namespace OpenRA.Traits if (unit == null || ! unit.Traits.Contains()) return 0; + if (self.traits.Get().FastBuild) return 0; var ui = unit.Traits.Get(); var time = ui.Cost * self.Owner.PlayerActor.Info.Traits.Get().BuildSpeed /* todo: country-specific build speed bonus */ diff --git a/OpenRA.Game/Traits/SupportPower.cs b/OpenRA.Game/Traits/SupportPower.cs index d75da257ce..6345b5da29 100644 --- a/OpenRA.Game/Traits/SupportPower.cs +++ b/OpenRA.Game/Traits/SupportPower.cs @@ -69,6 +69,7 @@ namespace OpenRA.Traits if (IsAvailable && (!Info.RequiresPower || IsPowered())) { + if (self.traits.Get().FastCharge) RemainingTime = 0; if (RemainingTime > 0) --RemainingTime; if (!notifiedCharging) { diff --git a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs index f4aeb432d9..0fa4375fec 100644 --- a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs @@ -84,19 +84,21 @@ namespace OpenRA.Widgets.Delegates () => true; devmodeBG.GetWidget("SETTINGS_GIVE_CASH").OnMouseDown = mi => { + Game.IssueOrder(new Order("DevModeGiveCash", Game.world.LocalPlayer.PlayerActor)); return true; }; devmodeBG.GetWidget("SETTINGS_BUILD_SPEED").OnMouseDown = mi => { + Game.IssueOrder(new Order("DevModeFastBuild", Game.world.LocalPlayer.PlayerActor)); return true; }; devmodeBG.GetWidget("SETTINGS_BUILD_SPEED").Checked = () => true; - devmodeBG.GetWidget("SETTINGS_CHARGE_TIME").OnMouseDown = mi => { + Game.IssueOrder(new Order("DevModeFastCharge", Game.world.LocalPlayer.PlayerActor)); return true; }; devmodeBG.GetWidget("SETTINGS_CHARGE_TIME").Checked = diff --git a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs index fde886673e..eabe1d1ce7 100755 --- a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs @@ -16,7 +16,7 @@ using OpenRA.Traits.Activities; namespace OpenRA.Mods.RA { class AirstrikePowerInfo : SupportPowerInfo - { + { [ActorReference] public readonly string UnitType = "badr.bomber"; [ActorReference]