Merge pull request #10886 from reaperrr/fix-gravitybomb
Fix GravityBomb crash when Image is null
This commit is contained in:
@@ -31,6 +31,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public readonly bool Shadow = false;
|
public readonly bool Shadow = false;
|
||||||
|
|
||||||
|
[PaletteReference] public readonly string ShadowPalette = "shadow";
|
||||||
|
|
||||||
public readonly WDist Velocity = WDist.Zero;
|
public readonly WDist Velocity = WDist.Zero;
|
||||||
|
|
||||||
[Desc("Value added to velocity every tick.")]
|
[Desc("Value added to velocity every tick.")]
|
||||||
@@ -56,10 +58,10 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Velocity);
|
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Velocity);
|
||||||
acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);
|
acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);
|
||||||
|
|
||||||
anim = new Animation(args.SourceActor.World, info.Image);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.Image))
|
if (!string.IsNullOrEmpty(info.Image))
|
||||||
{
|
{
|
||||||
|
anim = new Animation(args.SourceActor.World, info.Image);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.OpenSequence))
|
if (!string.IsNullOrEmpty(info.OpenSequence))
|
||||||
anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequence));
|
anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequence));
|
||||||
else
|
else
|
||||||
@@ -85,6 +87,9 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
|
if (anim == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
var world = args.SourceActor.World;
|
var world = args.SourceActor.World;
|
||||||
if (!world.FogObscures(pos))
|
if (!world.FogObscures(pos))
|
||||||
{
|
{
|
||||||
@@ -92,7 +97,7 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
{
|
{
|
||||||
var dat = world.Map.DistanceAboveTerrain(pos);
|
var dat = world.Map.DistanceAboveTerrain(pos);
|
||||||
var shadowPos = pos - new WVec(0, 0, dat.Length);
|
var shadowPos = pos - new WVec(0, 0, dat.Length);
|
||||||
foreach (var r in anim.Render(shadowPos, wr.Palette("shadow")))
|
foreach (var r in anim.Render(shadowPos, wr.Palette(info.ShadowPalette)))
|
||||||
yield return r;
|
yield return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user