Merge pull request #5138 from Mailaender/disable-idle-overlay
Fixed the Dune 2000 outpost radar dish rotating when powered down
This commit is contained in:
@@ -15,14 +15,16 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public class Animation
|
||||
{
|
||||
string name;
|
||||
public Sequence CurrentSequence { get; private set; }
|
||||
public bool IsDecoration = false;
|
||||
public Func<bool> Paused;
|
||||
|
||||
Func<int> facingFunc;
|
||||
|
||||
int frame = 0;
|
||||
bool backwards = false;
|
||||
bool tickAlways;
|
||||
|
||||
Func<int> facingFunc;
|
||||
string name;
|
||||
|
||||
public string Name { get { return name; } }
|
||||
|
||||
@@ -122,6 +124,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (Paused == null || !Paused())
|
||||
Tick(40); // tick one frame
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,19 @@ namespace OpenRA.Graphics
|
||||
public readonly Animation Animation;
|
||||
public readonly Func<WVec> OffsetFunc;
|
||||
public readonly Func<bool> DisableFunc;
|
||||
public readonly Func<bool> Paused;
|
||||
public readonly Func<WPos, int> ZOffset;
|
||||
|
||||
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable)
|
||||
: this(a, offset, disable, null) { }
|
||||
: this(a, offset, disable, () => false, null) { }
|
||||
|
||||
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, int zOffset)
|
||||
: this(a, offset, disable, _ => zOffset) { }
|
||||
: this(a, offset, disable, () => false, _ => zOffset) { }
|
||||
|
||||
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, Func<WPos, int> zOffset)
|
||||
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, Func<bool> pause, Func<WPos, int> zOffset)
|
||||
{
|
||||
this.Animation = a;
|
||||
this.Animation.Paused = pause;
|
||||
this.OffsetFunc = offset;
|
||||
this.DisableFunc = disable;
|
||||
this.ZOffset = zOffset;
|
||||
@@ -45,7 +47,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public static implicit operator AnimationWithOffset(Animation a)
|
||||
{
|
||||
return new AnimationWithOffset(a, null, null, null);
|
||||
return new AnimationWithOffset(a, null, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
get { return anims[""].Animation; }
|
||||
protected set { anims[""] = new AnimationWithOffset(value,
|
||||
anims[""].OffsetFunc, anims[""].DisableFunc, anims[""].ZOffset); }
|
||||
anims[""].OffsetFunc, anims[""].DisableFunc, anims[""].Paused, anims[""].ZOffset); }
|
||||
}
|
||||
|
||||
RenderSpritesInfo Info;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 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
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
var overlay = new Animation(rs.GetImage(init.self));
|
||||
overlay.PlayThen(info.Sequence, () => buildComplete = false);
|
||||
rs.anims.Add("make_overlay_{0}".F(info.Sequence),
|
||||
new AnimationWithOffset(overlay, null, () => !buildComplete, null));
|
||||
new AnimationWithOffset(overlay, null, () => !buildComplete));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ namespace OpenRA.Mods.RA
|
||||
var muzzleFlash = new AnimationWithOffset(muzzleAnim,
|
||||
() => PortOffset(self, port),
|
||||
() => false,
|
||||
() => false,
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 1024));
|
||||
|
||||
muzzles.Add(muzzleFlash);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
@@ -20,6 +21,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public class RenderBuildingInfo : RenderSimpleInfo, Requires<BuildingInfo>, IPlaceBuildingDecoration
|
||||
{
|
||||
public readonly bool HasMakeAnimation = true;
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderBuilding(init, this);}
|
||||
|
||||
@@ -35,6 +37,8 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
public class RenderBuilding : RenderSimple, INotifyDamageStateChanged
|
||||
{
|
||||
RenderBuildingInfo info;
|
||||
|
||||
public RenderBuilding(ActorInitializer init, RenderBuildingInfo info)
|
||||
: this(init, info, () => 0) { }
|
||||
|
||||
@@ -42,6 +46,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
: base(init.self, baseFacing)
|
||||
{
|
||||
var self = init.self;
|
||||
this.info = info;
|
||||
|
||||
// Work around a bogus crash
|
||||
anim.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||
@@ -59,6 +64,13 @@ namespace OpenRA.Mods.RA.Render
|
||||
anim.PlayRepeating(NormalizeSequence(self, "idle"));
|
||||
foreach (var x in self.TraitsImplementing<INotifyBuildComplete>())
|
||||
x.BuildingComplete(self);
|
||||
|
||||
if (info.PauseOnLowPower)
|
||||
{
|
||||
var disabled = self.TraitsImplementing<IDisable>();
|
||||
anim.Paused = () => disabled.Any(d => d.Disabled)
|
||||
&& anim.CurrentSequence.Name == NormalizeSequence(self, "idle");
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayCustomAnimThen(Actor self, string name, Action a)
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
rs.anims.Add("harvest_{0}".F(info.Sequence), new AnimationWithOffset(anim,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => !visible,
|
||||
() => false,
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 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
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
@@ -23,6 +24,8 @@ namespace OpenRA.Mods.RA.Render
|
||||
[Desc("Position relative to body")]
|
||||
public readonly WVec Offset = WVec.Zero;
|
||||
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithIdleOverlay(init.self, this); }
|
||||
}
|
||||
|
||||
@@ -35,6 +38,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<IBodyOrientation>();
|
||||
var disabled = self.TraitsImplementing<IDisable>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
overlay = new Animation(rs.GetImage(self));
|
||||
@@ -42,7 +46,9 @@ namespace OpenRA.Mods.RA.Render
|
||||
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
|
||||
new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => !buildComplete, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
() => !buildComplete,
|
||||
() => info.PauseOnLowPower && disabled.Any(d => d.Disabled),
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
new AnimationWithOffset(muzzleFlash,
|
||||
() => info.IgnoreOffset ? WVec.Zero : arm.MuzzleOffset(self, barrel),
|
||||
() => !visible[barrel],
|
||||
() => false,
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 2)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
rotorAnim.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add(info.Id, new AnimationWithOffset(rotorAnim,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
null, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
null, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 1)));
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
anim = new Animation(rs.GetImage(self), () => t.turretFacing);
|
||||
anim.Play(info.Sequence);
|
||||
rs.anims.Add("turret_{0}".F(info.Turret), new AnimationWithOffset(
|
||||
anim, () => TurretOffset(self), null, p => ZOffsetFromCenter(self, p, 1)));
|
||||
anim, () => TurretOffset(self), null, () => false, p => ZOffsetFromCenter(self, p, 1)));
|
||||
|
||||
// Restrict turret facings to match the sprite
|
||||
t.QuantizedFacings = anim.CurrentSequence.Facings;
|
||||
|
||||
@@ -368,6 +368,8 @@ HQ:
|
||||
RequiresPower:
|
||||
CanPowerDown:
|
||||
DisabledOverlay:
|
||||
RenderBuilding:
|
||||
PauseOnLowPower: yes
|
||||
Health:
|
||||
HP: 750
|
||||
RevealsShroud:
|
||||
@@ -441,6 +443,8 @@ EYE:
|
||||
RequiresPower:
|
||||
CanPowerDown:
|
||||
DisabledOverlay:
|
||||
RenderBuilding:
|
||||
PauseOnLowPower: yes
|
||||
Health:
|
||||
HP: 1200
|
||||
RevealsShroud:
|
||||
|
||||
@@ -339,6 +339,7 @@ CONCRETEB:
|
||||
Prerequisite: Outpost
|
||||
WithIdleOverlay@DISH:
|
||||
Sequence: idle-dish
|
||||
PauseOnLowPower: yes
|
||||
|
||||
^STARPORT:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -67,6 +67,8 @@ GAP:
|
||||
RequiresPower:
|
||||
CanPowerDown:
|
||||
DisabledOverlay:
|
||||
RenderBuilding:
|
||||
PauseOnLowPower: yes
|
||||
Health:
|
||||
HP: 1000
|
||||
Armor:
|
||||
|
||||
@@ -507,6 +507,7 @@ GARADR:
|
||||
Range: 10c0
|
||||
WithIdleOverlay@DISH:
|
||||
Sequence: idle-dish
|
||||
PauseOnLowPower: yes
|
||||
|
||||
NARADR:
|
||||
Inherits: ^Building
|
||||
@@ -543,6 +544,7 @@ NARADR:
|
||||
Range: 10c0
|
||||
WithIdleOverlay@DISH:
|
||||
Sequence: idle-dish
|
||||
PauseOnLowPower: yes
|
||||
|
||||
GATECH:
|
||||
Inherits: ^Building
|
||||
|
||||
Reference in New Issue
Block a user