Adds damage debug overlay
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -34,6 +34,7 @@ Also thanks to:
|
|||||||
* D2k Sardaukar
|
* D2k Sardaukar
|
||||||
* Daniel Derejvanik (Harisson)
|
* Daniel Derejvanik (Harisson)
|
||||||
* Danny Keary (Dan9550)
|
* Danny Keary (Dan9550)
|
||||||
|
* DeadlySurprise
|
||||||
* Erasmus Schroder (rasco)
|
* Erasmus Schroder (rasco)
|
||||||
* Fahrradkette
|
* Fahrradkette
|
||||||
* Frank Razenberg (zzattack)
|
* Frank Razenberg (zzattack)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
self.Destroy();
|
self.Destroy();
|
||||||
|
|
||||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
ns.Sold(self);
|
ns.Sold(self);
|
||||||
|
|
||||||
if (refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
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();
|
self.Destroy();
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA
|
|||||||
void MaybeAddCashTick(Actor self, int amount)
|
void MaybeAddCashTick(Actor self, int amount)
|
||||||
{
|
{
|
||||||
if (Info.ShowTicks)
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Mods.RA.Effects;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -20,7 +21,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new CombatDebugOverlay(init.self); }
|
public object Create(ActorInitializer init) { return new CombatDebugOverlay(init.self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CombatDebugOverlay : IPostRender
|
public class CombatDebugOverlay : IPostRender, INotifyDamage
|
||||||
{
|
{
|
||||||
Lazy<AttackBase> attack;
|
Lazy<AttackBase> attack;
|
||||||
Lazy<IBodyOrientation> coords;
|
Lazy<IBodyOrientation> 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<Health>();
|
||||||
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
|
|||||||
collector.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(amount);
|
collector.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(amount);
|
||||||
|
|
||||||
if (crateInfo.UseCashTick)
|
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);
|
base.Activate(collector);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
@@ -17,20 +17,21 @@ using OpenRA.Mods.RA.Graphics;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Effects
|
namespace OpenRA.Mods.RA.Effects
|
||||||
{
|
{
|
||||||
class CashTick : IEffect
|
public class FloatingText : IEffect
|
||||||
{
|
{
|
||||||
readonly SpriteFont font;
|
readonly SpriteFont font;
|
||||||
readonly string text;
|
readonly string text;
|
||||||
Color color;
|
Color color;
|
||||||
int remaining = 30;
|
int remaining;
|
||||||
WPos pos;
|
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.font = Game.Renderer.Fonts["TinyBold"];
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.color = color;
|
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);
|
||||||
@@ -49,5 +50,10 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
|
|
||||||
yield return new TextRenderable(font, pos, 0, color, text);
|
yield return new TextRenderable(font, pos, 0, color, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FormatCashTick(int cashAmount)
|
||||||
|
{
|
||||||
|
return "{0}${1}".F(cashAmount < 0 ? "-" : "+", Math.Abs(cashAmount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
var bounty = cost * GetMultiplier(self) * info.Percentage / 10000;
|
||||||
|
|
||||||
if (bounty > 0 && e.Attacker.Owner.IsAlliedWith(self.World.RenderPlayer))
|
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<PlayerResources>().GiveCash(bounty);
|
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Infiltration
|
|||||||
|
|
||||||
Sound.PlayToPlayer(self.Owner, info.SoundToVictim);
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,8 @@
|
|||||||
<Compile Include="Air\AttackPlane.cs" />
|
<Compile Include="Air\AttackPlane.cs" />
|
||||||
<Compile Include="AI\SupportPowerDecision.cs" />
|
<Compile Include="AI\SupportPowerDecision.cs" />
|
||||||
<Compile Include="Crates\DuplicateUnitCrateAction.cs" />
|
<Compile Include="Crates\DuplicateUnitCrateAction.cs" />
|
||||||
|
<Compile Include="Effects\FloatingText.cs" />
|
||||||
|
<Compile Include="Graphics\TextRenderable.cs" />
|
||||||
<Compile Include="Infiltration\InfiltrateForPowerOutage.cs" />
|
<Compile Include="Infiltration\InfiltrateForPowerOutage.cs" />
|
||||||
<Compile Include="Power\AffectedByPowerOutage.cs" />
|
<Compile Include="Power\AffectedByPowerOutage.cs" />
|
||||||
<Compile Include="Power\Power.cs" />
|
<Compile Include="Power\Power.cs" />
|
||||||
@@ -212,7 +214,6 @@
|
|||||||
<Compile Include="DemoTruck.cs" />
|
<Compile Include="DemoTruck.cs" />
|
||||||
<Compile Include="DetectCloaked.cs" />
|
<Compile Include="DetectCloaked.cs" />
|
||||||
<Compile Include="Effects\Bullet.cs" />
|
<Compile Include="Effects\Bullet.cs" />
|
||||||
<Compile Include="Effects\CashTick.cs" />
|
|
||||||
<Compile Include="Effects\Contrail.cs" />
|
<Compile Include="Effects\Contrail.cs" />
|
||||||
<Compile Include="Effects\Corpse.cs" />
|
<Compile Include="Effects\Corpse.cs" />
|
||||||
<Compile Include="Effects\CrateEffect.cs" />
|
<Compile Include="Effects\CrateEffect.cs" />
|
||||||
@@ -534,7 +535,6 @@
|
|||||||
<Compile Include="Render\RenderSprites.cs" />
|
<Compile Include="Render\RenderSprites.cs" />
|
||||||
<Compile Include="Graphics\BeamRenderable.cs" />
|
<Compile Include="Graphics\BeamRenderable.cs" />
|
||||||
<Compile Include="Graphics\ContrailRenderable.cs" />
|
<Compile Include="Graphics\ContrailRenderable.cs" />
|
||||||
<Compile Include="Graphics\TextRenderable.cs" />
|
|
||||||
<Compile Include="Graphics\VoxelRenderable.cs" />
|
<Compile Include="Graphics\VoxelRenderable.cs" />
|
||||||
<Compile Include="Air\FlyAwayOnIdle.cs" />
|
<Compile Include="Air\FlyAwayOnIdle.cs" />
|
||||||
<Compile Include="Buildings\ClonesProducedUnits.cs" />
|
<Compile Include="Buildings\ClonesProducedUnits.cs" />
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var temp = currentDisplayValue;
|
var temp = currentDisplayValue;
|
||||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
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;
|
currentDisplayTick = Info.TickRate;
|
||||||
currentDisplayValue = 0;
|
currentDisplayValue = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user