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:
@@ -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);
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
for (var x = scanStart.X; x < scanEnd.X; x++)
|
||||
{
|
||||
var pos = new CPos(x, y);
|
||||
var pos = new CPos(x, y);
|
||||
var at = bi.GetBuildingAt(pos);
|
||||
if (at == null || !at.IsInWorld || !at.HasTrait<GivesBuildableArea>())
|
||||
continue;
|
||||
|
||||
@@ -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,7 +42,8 @@ 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,
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
||||
() => false,
|
||||
p => WithTurret.ZOffsetFromCenter(self, p, 0)));
|
||||
}
|
||||
|
||||
public void Harvested(Actor self, ResourceType resource)
|
||||
|
||||
@@ -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,14 +38,17 @@ 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));
|
||||
overlay.PlayRepeating(info.Sequence);
|
||||
rs.anims.Add("idle_overlay_{0}".F(info.Sequence),
|
||||
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)
|
||||
|
||||
@@ -54,9 +54,10 @@ namespace OpenRA.Mods.RA.Render
|
||||
var muzzleFlash = new Animation(render.GetImage(self), getFacing);
|
||||
visible.Add(barrel, false);
|
||||
anims.Add(barrel,
|
||||
new AnimationWithOffset(muzzleFlash,
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user