diff --git a/AUTHORS b/AUTHORS index 01787fff5a..f2870c679f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,6 +34,7 @@ Also thanks to: * D2k Sardaukar * Daniel Derejvanik (Harisson) * Danny Keary (Dan9550) + * DeadlySurprise * Erasmus Schroder (rasco) * Fahrradkette * Frank Razenberg (zzattack) diff --git a/OpenRA.Mods.RA/Activities/DonateSupplies.cs b/OpenRA.Mods.RA/Activities/DonateSupplies.cs index 30a1c2f5e3..7d19a8724b 100644 --- a/OpenRA.Mods.RA/Activities/DonateSupplies.cs +++ b/OpenRA.Mods.RA/Activities/DonateSupplies.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities self.Destroy(); if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) - self.World.AddFrameEndTask(w => w.Add(new CashTick(targetActor.CenterPosition, targetActor.Owner.Color.RGB, payload))); + self.World.AddFrameEndTask(w => w.Add(new FloatingText(targetActor.CenterPosition, targetActor.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30))); return this; } diff --git a/OpenRA.Mods.RA/Activities/Sell.cs b/OpenRA.Mods.RA/Activities/Sell.cs index 8a19e0e3b1..d342b9db2c 100755 --- a/OpenRA.Mods.RA/Activities/Sell.cs +++ b/OpenRA.Mods.RA/Activities/Sell.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Activities ns.Sold(self); if (refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer)) - self.World.AddFrameEndTask(w => w.Add(new CashTick(self.CenterPosition, self.Owner.Color.RGB, refund))); + self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(refund), 30))); self.Destroy(); return this; diff --git a/OpenRA.Mods.RA/CashTrickler.cs b/OpenRA.Mods.RA/CashTrickler.cs index 4a88413b87..2339b4e187 100644 --- a/OpenRA.Mods.RA/CashTrickler.cs +++ b/OpenRA.Mods.RA/CashTrickler.cs @@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA void MaybeAddCashTick(Actor self, int amount) { if (Info.ShowTicks) - self.World.AddFrameEndTask(w => w.Add(new CashTick(self.CenterPosition, self.Owner.Color.RGB, amount))); + self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(amount), 30))); } } } diff --git a/OpenRA.Mods.RA/CombatDebugOverlay.cs b/OpenRA.Mods.RA/CombatDebugOverlay.cs index 757ef8888c..b78566dcce 100644 --- a/OpenRA.Mods.RA/CombatDebugOverlay.cs +++ b/OpenRA.Mods.RA/CombatDebugOverlay.cs @@ -12,6 +12,7 @@ using System; using System.Drawing; using OpenRA.Graphics; using OpenRA.Traits; +using OpenRA.Mods.RA.Effects; namespace OpenRA.Mods.RA { @@ -20,7 +21,7 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new CombatDebugOverlay(init.self); } } - public class CombatDebugOverlay : IPostRender + public class CombatDebugOverlay : IPostRender, INotifyDamage { Lazy attack; Lazy coords; @@ -87,5 +88,19 @@ namespace OpenRA.Mods.RA } } } + + public void Damaged(Actor self, AttackInfo e) + { + if (devMode == null || !devMode.ShowCombatGeometry || e.Damage == 0) + return; + + var health = self.TraitOrDefault(); + if (health == null) + return; + + var damageText = "{0} ({1}%)".F(-e.Damage, e.Damage * 100 / health.MaxHP); + + self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color.RGB, damageText, 30))); + } } } diff --git a/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs index 2944b637d7..4bdf7178e6 100644 --- a/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveCashCrateAction.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA collector.Owner.PlayerActor.Trait().GiveCash(amount); if (crateInfo.UseCashTick) - w.Add(new CashTick(collector.CenterPosition, collector.Owner.Color.RGB, amount)); + w.Add(new FloatingText(collector.CenterPosition, collector.Owner.Color.RGB, FloatingText.FormatCashTick(amount), 30)); }); base.Activate(collector); diff --git a/OpenRA.Mods.RA/Effects/CashTick.cs b/OpenRA.Mods.RA/Effects/FloatingText.cs similarity index 71% rename from OpenRA.Mods.RA/Effects/CashTick.cs rename to OpenRA.Mods.RA/Effects/FloatingText.cs index 9e5d6c0613..d2a42db315 100644 --- a/OpenRA.Mods.RA/Effects/CashTick.cs +++ b/OpenRA.Mods.RA/Effects/FloatingText.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made @@ -17,23 +17,24 @@ using OpenRA.Mods.RA.Graphics; namespace OpenRA.Mods.RA.Effects { - class CashTick : IEffect + public class FloatingText : IEffect { readonly SpriteFont font; readonly string text; Color color; - int remaining = 30; + int remaining; WPos pos; - public CashTick(WPos pos, Color color, int value) + public FloatingText(WPos pos, Color color, string text, int duration) { this.font = Game.Renderer.Fonts["TinyBold"]; this.pos = pos; this.color = color; - this.text = "{0}${1}".F(value < 0 ? "-" : "+", Math.Abs(value)); + this.text = text; + this.remaining = duration; } - static readonly WVec velocity = new WVec(0,0,86); + static readonly WVec velocity = new WVec(0, 0, 86); public void Tick(World world) { if (--remaining <= 0) @@ -49,5 +50,10 @@ namespace OpenRA.Mods.RA.Effects yield return new TextRenderable(font, pos, 0, color, text); } + + public static string FormatCashTick(int cashAmount) + { + return "{0}${1}".F(cashAmount < 0 ? "-" : "+", Math.Abs(cashAmount)); + } } } diff --git a/OpenRA.Mods.RA/GivesBounty.cs b/OpenRA.Mods.RA/GivesBounty.cs index b60fd8822a..84dad89443 100644 --- a/OpenRA.Mods.RA/GivesBounty.cs +++ b/OpenRA.Mods.RA/GivesBounty.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA var bounty = cost * GetMultiplier(self) * info.Percentage / 10000; if (bounty > 0 && e.Attacker.Owner.IsAlliedWith(self.World.RenderPlayer)) - e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(self.CenterPosition, e.Attacker.Owner.Color.RGB, bounty))); + e.Attacker.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, e.Attacker.Owner.Color.RGB, FloatingText.FormatCashTick(bounty), 30))); e.Attacker.Owner.PlayerActor.Trait().GiveCash(bounty); } diff --git a/OpenRA.Mods.RA/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Infiltration/InfiltrateForCash.cs index 928f8e85f3..20361e60dc 100644 --- a/OpenRA.Mods.RA/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Infiltration/InfiltrateForCash.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Infiltration Sound.PlayToPlayer(self.Owner, info.SoundToVictim); - self.World.AddFrameEndTask(w => w.Add(new CashTick(self.CenterPosition, infiltrator.Owner.Color.RGB, toGive))); + self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color.RGB, FloatingText.FormatCashTick(toGive), 30))); } } } diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 1f231b7e5e..14d1ba8c2c 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -120,6 +120,8 @@ + + @@ -212,7 +214,6 @@ - @@ -534,7 +535,6 @@ - diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 50079bac08..315120d71e 100644 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA { var temp = currentDisplayValue; if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) - self.World.AddFrameEndTask(w => w.Add(new CashTick(self.CenterPosition, self.Owner.Color.RGB, temp))); + self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(temp), 30))); currentDisplayTick = Info.TickRate; currentDisplayValue = 0; }