diff --git a/OpenRA.Game/Graphics/Animation.cs b/OpenRA.Game/Graphics/Animation.cs index d851c20094..25b97440eb 100644 --- a/OpenRA.Game/Graphics/Animation.cs +++ b/OpenRA.Game/Graphics/Animation.cs @@ -69,12 +69,6 @@ namespace OpenRA.Graphics return Render(pos, WVec.Zero, 0, palette, 1f); } - public void Initialize(string sequenceName) - { - CurrentSequence = sequenceProvider.GetSequence(name, sequenceName); - tickAlways = true; - } - public void Play(string sequenceName) { PlayThen(sequenceName, null); diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index b8aa4b690d..c32870654a 100644 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2011 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, @@ -102,15 +102,15 @@ namespace OpenRA.Network var client = orderManager.LobbyInfo.ClientWithIndex(clientId); if (client != null) { - var pauseState = order.TargetString == "Pause" ? World.PauseState.Paused : World.PauseState.Active; - if (orderManager.world.Paused != pauseState && !world.LobbyInfo.IsSinglePlayer) + var pause = order.TargetString == "Pause"; + if (orderManager.world.Paused != pause && !world.LobbyInfo.IsSinglePlayer) { - var pausetext = "The game is {0} by {1}.".F(pauseState == World.PauseState.Paused ? "paused" : "un-paused", client.Name); + var pausetext = "The game is {0} by {1}".F(pause ? "paused" : "un-paused", client.Name); Game.AddChatLine(Color.White, "", pausetext); } - orderManager.world.Paused = pauseState; - orderManager.world.PredictedPaused = pauseState; + orderManager.world.Paused = pause; + orderManager.world.PredictedPaused = pause; } break; } diff --git a/OpenRA.Game/Traits/DebugPauseState.cs b/OpenRA.Game/Traits/DebugPauseState.cs index bbaff35512..d7ec732273 100644 --- a/OpenRA.Game/Traits/DebugPauseState.cs +++ b/OpenRA.Game/Traits/DebugPauseState.cs @@ -18,7 +18,7 @@ namespace OpenRA.Traits public class DebugPauseState : ISync { World world; - [Sync] public bool Paused { get { return world.Paused == World.PauseState.Paused; } } + [Sync] public bool Paused { get { return world.Paused; } } public DebugPauseState(World world) { this.world = world; } } } diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index a1dae7459f..032eb4edd5 100755 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -41,7 +41,7 @@ namespace OpenRA.Traits public RenderSimple(Actor self) : this(self, MakeFacingFunc(self)) { - DefaultAnimation.PlayRepeating("idle"); + DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")); self.Trait().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings); } diff --git a/OpenRA.Game/Traits/Render/RenderSprites.cs b/OpenRA.Game/Traits/Render/RenderSprites.cs old mode 100644 new mode 100755 index e8c4fb93b5..3faad9748d --- a/OpenRA.Game/Traits/Render/RenderSprites.cs +++ b/OpenRA.Game/Traits/Render/RenderSprites.cs @@ -31,7 +31,7 @@ namespace OpenRA.Traits public virtual object Create(ActorInitializer init) { return new RenderSprites(init.self); } } - public class RenderSprites : IRender, ITickRender, INotifyOwnerChanged, INotifyEffectiveOwnerChanged + public class RenderSprites : IRender, ITick, INotifyOwnerChanged, INotifyEffectiveOwnerChanged { class AnimationWrapper { @@ -126,11 +126,8 @@ namespace OpenRA.Traits } } - public virtual void TickRender(WorldRenderer wr, Actor self) + public virtual void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - foreach (var a in anims.Values) a.Animation.Animation.Tick(); } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 7dc0ac36ae..f798ea70da 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -199,7 +199,7 @@ namespace OpenRA.Widgets var key = Hotkey.FromKeyInput(e); if (key == Game.Settings.Keys.PauseKey && World.LocalPlayer != null) // Disable pausing for spectators - World.SetPauseState(World.Paused != World.PauseState.Paused); + World.SetPauseState(!World.Paused); else if (key == Game.Settings.Keys.SelectAllUnitsKey) { var ownUnitsOnScreen = SelectActorsInBox(World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 15cc7984f3..6d1aa45475 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -203,9 +203,8 @@ namespace OpenRA public event Action ActorAdded = _ => { }; public event Action ActorRemoved = _ => { }; - public enum PauseState { Active, Paused, Editor } - public PauseState Paused { get; internal set; } - public PauseState PredictedPaused { get; internal set; } + public bool Paused { get; internal set; } + public bool PredictedPaused { get; internal set; } public bool PauseStateLocked { get; set; } public bool IsShellmap = false; public int WorldTick { get; private set; } @@ -216,17 +215,17 @@ namespace OpenRA return; IssueOrder(Order.PauseGame(paused)); - PredictedPaused = paused ? PauseState.Paused : PauseState.Active; + PredictedPaused = paused; } public void SetLocalPauseState(bool paused) { - Paused = PredictedPaused = paused ? PauseState.Paused : PauseState.Active; + Paused = PredictedPaused = paused; } public void Tick() { - if (Paused != PauseState.Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap)) + if (!Paused && (!IsShellmap || Game.Settings.Game.ShowShellmap)) { WorldTick++; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs index 77dbdb11d3..d4c03a05d1 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic public void OptionsClicked() { - var cachedPause = world.PredictedPaused == World.PauseState.Paused; + var cachedPause = world.PredictedPaused; ingameRoot.IsVisible = () => false; if (world.LobbyInfo.IsSinglePlayer) diff --git a/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs b/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs index 9b4475622b..dc45b82673 100644 --- a/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs +++ b/OpenRA.Mods.D2k/Render/WithCrumbleOverlay.cs @@ -34,16 +34,19 @@ namespace OpenRA.Mods.RA.Render public WithCrumbleOverlay(ActorInitializer init, WithCrumbleOverlayInfo info) { + if (init.Contains()) + return; + + var key = "make_overlay_{0}".F(info.Sequence); var rs = init.self.Trait(); - if (!init.Contains()) - { - var overlay = new Animation(init.world, rs.GetImage(init.self)); - overlay.PlayThen(info.Sequence, () => buildComplete = false); - rs.Add("make_overlay_{0}".F(info.Sequence), - new AnimationWithOffset(overlay, null, () => !buildComplete), - info.Palette, info.IsPlayerPalette); - } + var overlay = new Animation(init.world, rs.GetImage(init.self)); + + // Remove the animation once it is complete + overlay.PlayThen(info.Sequence, () => init.world.AddFrameEndTask(w => rs.Remove(key))); + + rs.Add(key, new AnimationWithOffset(overlay, null, () => !buildComplete), + info.Palette, info.IsPlayerPalette); } public void BuildingComplete(Actor self) diff --git a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs index ce0bc91849..123f1dc0b5 100644 --- a/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs +++ b/OpenRA.Mods.RA/Attack/AttackGarrisoned.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA public override object Create(ActorInitializer init) { return new AttackGarrisoned(init.self, this); } } - public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender, ITickRender + public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender { public readonly FirePort[] Ports; @@ -183,10 +183,9 @@ namespace OpenRA.Mods.RA yield return r; } - public void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; + base.Tick(self); // Take a copy so that Tick() can remove animations foreach (var m in muzzles.ToList()) diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index a467b7c288..839fad50f0 100644 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; +using OpenRA.Mods.RA.Render; namespace OpenRA.Mods.RA.Buildings { @@ -100,12 +101,13 @@ namespace OpenRA.Mods.RA.Buildings } } - public class Building : INotifyDamage, IOccupySpace, INotifyCapture, INotifyBuildComplete, INotifySold, INotifyTransform, ISync, ITechTreePrerequisite, INotifyAddedToWorld, INotifyRemovedFromWorld + public class Building : INotifyDamage, IOccupySpace, INotifyCapture, ITick, INotifySold, INotifyTransform, ISync, ITechTreePrerequisite, INotifyAddedToWorld, INotifyRemovedFromWorld { public readonly BuildingInfo Info; public bool BuildComplete { get; private set; } [Sync] readonly CPos topLeft; readonly Actor self; + readonly bool skipMakeAnimation; PowerManager PlayerPower; @@ -139,7 +141,7 @@ namespace OpenRA.Mods.RA.Buildings .Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info); - BuildComplete = init.Contains(); + skipMakeAnimation = init.Contains(); } public int GetPowerUsage() @@ -180,10 +182,22 @@ namespace OpenRA.Mods.RA.Buildings self.World.ScreenMap.Remove(self); } - public void BuildingComplete(Actor self) + public void Tick(Actor self) { + if (!BuildComplete && (skipMakeAnimation || !self.HasTrait())) + NotifyBuildingComplete(self); + } + + public void NotifyBuildingComplete(Actor self) + { + if (BuildComplete) + return; + BuildComplete = true; Locked = false; + + foreach (var notify in self.TraitsImplementing()) + notify.BuildingComplete(self); } public void Selling(Actor self) @@ -193,6 +207,7 @@ namespace OpenRA.Mods.RA.Buildings BuildComplete = false; } + public void Sold(Actor self) { } public void BeforeTransform(Actor self) diff --git a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs index 19c99528e8..9565e37892 100644 --- a/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs +++ b/OpenRA.Mods.RA/ChronoshiftPaletteEffect.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { class ChronoshiftPaletteEffectInfo : TraitInfo { } - public class ChronoshiftPaletteEffect : IPaletteModifier, ITickRender + public class ChronoshiftPaletteEffect : IPaletteModifier, ITick { const int chronoEffectLength = 60; int remainingFrames; @@ -27,11 +27,8 @@ namespace OpenRA.Mods.RA remainingFrames = chronoEffectLength; } - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (remainingFrames > 0) remainingFrames--; } diff --git a/OpenRA.Mods.RA/CloakPaletteEffect.cs b/OpenRA.Mods.RA/CloakPaletteEffect.cs index 306041e60d..d7da7419b6 100644 --- a/OpenRA.Mods.RA/CloakPaletteEffect.cs +++ b/OpenRA.Mods.RA/CloakPaletteEffect.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2011 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, @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { public class CloakPaletteEffectInfo : TraitInfo { } - public class CloakPaletteEffect : IPaletteModifier, ITickRender + public class CloakPaletteEffect : IPaletteModifier, ITick { float t = 0; string paletteName = "cloak"; @@ -41,11 +41,8 @@ namespace OpenRA.Mods.RA } } - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - t += 0.25f; if (t >= 256) t = 0; } diff --git a/OpenRA.Mods.RA/Console/PlayerCommands.cs b/OpenRA.Mods.RA/Console/PlayerCommands.cs index 4e19552236..fd88f94912 100644 --- a/OpenRA.Mods.RA/Console/PlayerCommands.cs +++ b/OpenRA.Mods.RA/Console/PlayerCommands.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA { case "pause": world.IssueOrder(new Order("PauseGame", null, false) - { TargetString = world.Paused == World.PauseState.Paused ? "UnPause" : "Pause" }); + { TargetString = world.Paused ? "UnPause" : "Pause" }); break; case "surrender": world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)); diff --git a/OpenRA.Mods.RA/Effects/Bullet.cs b/OpenRA.Mods.RA/Effects/Bullet.cs old mode 100644 new mode 100755 diff --git a/OpenRA.Mods.RA/Effects/InvulnEffect.cs b/OpenRA.Mods.RA/Effects/InvulnEffect.cs index 62e8ed7992..dc26ac5b76 100644 --- a/OpenRA.Mods.RA/Effects/InvulnEffect.cs +++ b/OpenRA.Mods.RA/Effects/InvulnEffect.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Effects this.b = a.Trait(); } - public void Tick(World world) + public void Tick( World world ) { if (a.IsDead() || b.GetDamageModifier(null, null) > 0) world.AddFrameEndTask(w => w.Remove(this)); diff --git a/OpenRA.Mods.RA/Effects/Missile.cs b/OpenRA.Mods.RA/Effects/Missile.cs old mode 100644 new mode 100755 diff --git a/OpenRA.Mods.RA/Effects/NukeLaunch.cs b/OpenRA.Mods.RA/Effects/NukeLaunch.cs old mode 100644 new mode 100755 diff --git a/OpenRA.Mods.RA/Effects/RepairIndicator.cs b/OpenRA.Mods.RA/Effects/RepairIndicator.cs old mode 100644 new mode 100755 diff --git a/OpenRA.Mods.RA/Effects/TeslaZap.cs b/OpenRA.Mods.RA/Effects/TeslaZap.cs index cfaefbefde..d26d947028 100644 --- a/OpenRA.Mods.RA/Effects/TeslaZap.cs +++ b/OpenRA.Mods.RA/Effects/TeslaZap.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Effects public readonly string Palette = "effect"; public readonly int BrightZaps = 1; public readonly int DimZaps = 2; - public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); } + public IEffect Create(ProjectileArgs args) { return new TeslaZap( this, args ); } } class TeslaZap : IEffect diff --git a/OpenRA.Mods.RA/LightPaletteRotator.cs b/OpenRA.Mods.RA/LightPaletteRotator.cs index 0cfecfee7b..49033f0e48 100644 --- a/OpenRA.Mods.RA/LightPaletteRotator.cs +++ b/OpenRA.Mods.RA/LightPaletteRotator.cs @@ -23,14 +23,11 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new LightPaletteRotator(this); } } - class LightPaletteRotator : ITickRender, IPaletteModifier + class LightPaletteRotator : ITick, IPaletteModifier { float t = 0; - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - t += .5f; } diff --git a/OpenRA.Mods.RA/NukePaletteEffect.cs b/OpenRA.Mods.RA/NukePaletteEffect.cs index e1ddf805d5..b028c06757 100644 --- a/OpenRA.Mods.RA/NukePaletteEffect.cs +++ b/OpenRA.Mods.RA/NukePaletteEffect.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { class NukePaletteEffectInfo : TraitInfo { } - public class NukePaletteEffect : IPaletteModifier, ITickRender + public class NukePaletteEffect : IPaletteModifier, ITick { const int nukeEffectLength = 20; int remainingFrames; @@ -27,11 +27,8 @@ namespace OpenRA.Mods.RA remainingFrames = nukeEffectLength; } - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (remainingFrames > 0) remainingFrames--; } diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 97d229d7d7..199837eac9 100644 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Orders IEnumerable InnerOrder(World world, CPos xy, MouseInput mi) { - if (world.Paused == World.PauseState.Paused) + if (world.Paused) yield break; if (mi.Button == MouseButton.Left) diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs index e30569fbf5..b0d6efc02c 100755 --- a/OpenRA.Mods.RA/Render/RenderBuilding.cs +++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs @@ -36,8 +36,6 @@ namespace OpenRA.Mods.RA.Render public class RenderBuilding : RenderSimple, INotifyDamageStateChanged, INotifyBuildComplete { RenderBuildingInfo info; - bool buildComplete; - bool skipMakeAnimation; public RenderBuilding(ActorInitializer init, RenderBuildingInfo info) : this(init, info, () => 0) { } @@ -47,29 +45,12 @@ namespace OpenRA.Mods.RA.Render { var self = init.self; this.info = info; - skipMakeAnimation = init.Contains(); - DefaultAnimation.Initialize(NormalizeSequence(self, "idle")); + DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")); self.Trait().SetAutodetectedFacings(DefaultAnimation.CurrentSequence.Facings); } - public override void TickRender(WorldRenderer wr, Actor self) - { - if (wr.world.Paused == World.PauseState.Paused) - return; - - base.TickRender(wr, self); - - if (buildComplete) - return; - - buildComplete = true; - if (!self.HasTrait() || skipMakeAnimation) - foreach (var notify in self.TraitsImplementing()) - notify.BuildingComplete(self); - } - public virtual void BuildingComplete(Actor self) { DefaultAnimation.PlayRepeating(NormalizeSequence(self, "idle")); @@ -108,7 +89,7 @@ namespace OpenRA.Mods.RA.Render public virtual void DamageStateChanged(Actor self, AttackInfo e) { if (DefaultAnimation.CurrentSequence != null) - DefaultAnimation.ReplaceAnim(NormalizeSequence(self, "idle")); + DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name)); } } } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs index 62bf58e486..f6152f8112 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs @@ -9,7 +9,6 @@ #endregion using System.Linq; -using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render @@ -22,7 +21,7 @@ namespace OpenRA.Mods.RA.Render public override object Create(ActorInitializer init) { return new RenderBuildingWall(init, this); } } - class RenderBuildingWall : RenderBuilding, INotifyAddedToWorld, INotifyRemovedFromWorld, ITick + class RenderBuildingWall : RenderBuilding, INotifyAddedToWorld, INotifyRemovedFromWorld { readonly RenderBuildingWallInfo info; int adjacent = 0; @@ -45,16 +44,10 @@ namespace OpenRA.Mods.RA.Render DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent); } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; + base.Tick(self); - base.TickRender(wr, self); - } - - public void Tick(Actor self) - { if (!dirty) return; diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs index 828fba2229..204426465d 100755 --- a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Render } } - class RenderBuildingWarFactory : RenderBuilding, INotifyBuildComplete, ITickRender, INotifyProduction, INotifySold, ISync + class RenderBuildingWarFactory : RenderBuilding, INotifyBuildComplete, ITick, INotifyProduction, INotifySold, ISync { Animation roof; [Sync] bool isOpen; @@ -62,13 +62,9 @@ namespace OpenRA.Mods.RA.Render buildComplete = true; } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - - base.TickRender(wr, self); - + base.Tick(self); if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit).Any( a => a != self )) { isOpen = false; diff --git a/OpenRA.Mods.RA/Render/RenderDisguise.cs b/OpenRA.Mods.RA/Render/RenderDisguise.cs index a1d35fa16c..26277cf12e 100644 --- a/OpenRA.Mods.RA/Render/RenderDisguise.cs +++ b/OpenRA.Mods.RA/Render/RenderDisguise.cs @@ -9,7 +9,6 @@ #endregion using OpenRA.Traits; -using OpenRA.Graphics; namespace OpenRA.Mods.RA.Render { @@ -32,11 +31,8 @@ namespace OpenRA.Mods.RA.Render intendedSprite = disguise.AsSprite; } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (disguise.AsSprite != intendedSprite) { intendedSprite = disguise.AsSprite; @@ -44,7 +40,7 @@ namespace OpenRA.Mods.RA.Render UpdatePalette(); } - base.TickRender(wr, self); + base.Tick(self); } } } diff --git a/OpenRA.Mods.RA/Render/RenderHarvester.cs b/OpenRA.Mods.RA/Render/RenderHarvester.cs index 9a048aa776..cecbe613ba 100644 --- a/OpenRA.Mods.RA/Render/RenderHarvester.cs +++ b/OpenRA.Mods.RA/Render/RenderHarvester.cs @@ -35,18 +35,15 @@ namespace OpenRA.Mods.RA.Render new Animation(self.World, image); } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - var desiredState = harv.Fullness * (info.ImagesByFullness.Length - 1) / 100; var desiredImage = info.ImagesByFullness[desiredState]; if (DefaultAnimation.Name != desiredImage) DefaultAnimation.ChangeImage(desiredImage, "idle"); - base.TickRender(wr, self); + base.Tick(self); } public void Harvested(Actor self, ResourceType resource) diff --git a/OpenRA.Mods.RA/Render/RenderInfantry.cs b/OpenRA.Mods.RA/Render/RenderInfantry.cs index 835c81ce17..a3948dc3e5 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantry.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantry.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2013 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,7 +8,6 @@ */ #endregion -using OpenRA.Graphics; using OpenRA.Mods.RA.Effects; using OpenRA.Traits; @@ -80,12 +79,9 @@ namespace OpenRA.Mods.RA.Render Attacking(self, target); } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - - base.TickRender(wr, self); + base.Tick(self); if ((State == AnimationState.Moving || dirty) && !move.IsMoving) { diff --git a/OpenRA.Mods.RA/Render/RenderInfantryPanic.cs b/OpenRA.Mods.RA/Render/RenderInfantryPanic.cs index 8a47624d43..8d3e424ded 100644 --- a/OpenRA.Mods.RA/Render/RenderInfantryPanic.cs +++ b/OpenRA.Mods.RA/Render/RenderInfantryPanic.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2011 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,7 +8,6 @@ */ #endregion -using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render @@ -44,16 +43,13 @@ namespace OpenRA.Mods.RA.Render return base.AllowIdleAnimation(self) && !sc.Panicking; } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick (Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (wasPanic != sc.Panicking) dirty = true; wasPanic = sc.Panicking; - base.TickRender(wr, self); + base.Tick(self); } } } diff --git a/OpenRA.Mods.RA/Render/RenderLandingCraft.cs b/OpenRA.Mods.RA/Render/RenderLandingCraft.cs index 50b6e9b55d..100c5a4a3f 100644 --- a/OpenRA.Mods.RA/Render/RenderLandingCraft.cs +++ b/OpenRA.Mods.RA/Render/RenderLandingCraft.cs @@ -9,7 +9,6 @@ #endregion using System.Linq; -using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render @@ -42,7 +41,7 @@ namespace OpenRA.Mods.RA.Render public bool ShouldBeOpen() { - if (self.CenterPosition.Z > 0 || move.IsMoving || cargo.CurrentAdjacentCells == null) + if (self.CenterPosition.Z > 0 || move.IsMoving) return false; return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c) @@ -71,17 +70,14 @@ namespace OpenRA.Mods.RA.Render PlayCustomAnimBackwards(self, info.OpenAnim, null); } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (ShouldBeOpen()) Open(); else Close(); - base.TickRender(wr, self); + base.Tick(self); } } } diff --git a/OpenRA.Mods.RA/Render/RenderUnitReload.cs b/OpenRA.Mods.RA/Render/RenderUnitReload.cs index b9c817fa81..fefa5b0fe1 100755 --- a/OpenRA.Mods.RA/Render/RenderUnitReload.cs +++ b/OpenRA.Mods.RA/Render/RenderUnitReload.cs @@ -9,7 +9,6 @@ #endregion using System.Linq; -using OpenRA.Graphics; using OpenRA.Traits; namespace OpenRA.Mods.RA.Render @@ -35,16 +34,13 @@ namespace OpenRA.Mods.RA.Render .Single(a => a.Info.Name == info.Armament); } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - var sequence = (armament.IsReloading ? "empty-" : "") + (attack.IsAttacking ? "aim" : "idle"); if (sequence != DefaultAnimation.CurrentSequence.Name) DefaultAnimation.ReplaceAnim(sequence); - base.TickRender(wr, self); + base.Tick(self); } } } diff --git a/OpenRA.Mods.RA/Render/WithActiveAnimation.cs b/OpenRA.Mods.RA/Render/WithActiveAnimation.cs index 84eb04877c..dec588eb60 100644 --- a/OpenRA.Mods.RA/Render/WithActiveAnimation.cs +++ b/OpenRA.Mods.RA/Render/WithActiveAnimation.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Render public object Create(ActorInitializer init) { return new WithActiveAnimation(init.self, this); } } - public class WithActiveAnimation : ITickRender, INotifyBuildComplete, INotifySold + public class WithActiveAnimation : ITick, INotifyBuildComplete, INotifySold { readonly IEnumerable disabled; readonly WithActiveAnimationInfo info; @@ -42,11 +42,8 @@ namespace OpenRA.Mods.RA.Render } int ticks; - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (!buildComplete) return; diff --git a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs index dd8fd06b5d..d53d1ca9a4 100644 --- a/OpenRA.Mods.RA/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.RA/Render/WithMakeAnimation.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Render { - public class WithMakeAnimationInfo : ITraitInfo, Requires + public class WithMakeAnimationInfo : ITraitInfo, Requires, Requires { [Desc("Sequence name to use")] public readonly string Sequence = "make"; @@ -26,40 +26,35 @@ namespace OpenRA.Mods.RA.Render public object Create(ActorInitializer init) { return new WithMakeAnimation(init, this); } } - public class WithMakeAnimation : ITickRender + public class WithMakeAnimation { - WithMakeAnimationInfo info; - RenderBuilding building; - bool buildComplete; + readonly WithMakeAnimationInfo info; + readonly RenderBuilding renderBuilding; public WithMakeAnimation(ActorInitializer init, WithMakeAnimationInfo info) { - building = init.self.Trait(); this.info = info; - buildComplete = init.Contains(); - } + var self = init.self; + renderBuilding = self.Trait(); - public void TickRender(WorldRenderer wr, Actor self) - { - if (wr.world.Paused == World.PauseState.Paused) - return; - - if (self.IsDead() || buildComplete) - return; - - buildComplete = true; - - building.PlayCustomAnimThen(self, info.Sequence, () => + var building = self.Trait(); + if (!init.Contains()) { - foreach (var notify in self.TraitsImplementing()) - notify.BuildingComplete(self); - }); + renderBuilding.PlayCustomAnimThen(self, info.Sequence, () => + { + building.NotifyBuildingComplete(self); + }); + } + else + building.NotifyBuildingComplete(self); } public void Reverse(Actor self, Activity activity) { - building.PlayCustomAnimBackwards(self, info.Sequence, () => { - building.PlayCustomAnim(self, info.Sequence); // avoids visual glitches as we wait for the actor to get destroyed + renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () => + { + // avoids visual glitches as we wait for the actor to get destroyed + renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0); self.QueueActivity(activity); }); } diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index 50984d7d1b..0d6d785082 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self, this); } } - class WithMuzzleFlash : INotifyAttack, IRender, ITickRender + class WithMuzzleFlash : INotifyAttack, IRender, ITick { Dictionary visible = new Dictionary(); Dictionary anims = new Dictionary(); @@ -95,11 +95,8 @@ namespace OpenRA.Mods.RA.Render } } - public void TickRender(WorldRenderer wr, Actor self) + public void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - foreach (var a in anims.Values) a.Animation.Tick(); } diff --git a/OpenRA.Mods.RA/TakeCover.cs b/OpenRA.Mods.RA/TakeCover.cs index 57f47e60b7..5e6fdc14c4 100644 --- a/OpenRA.Mods.RA/TakeCover.cs +++ b/OpenRA.Mods.RA/TakeCover.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2011 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,7 +9,6 @@ #endregion using OpenRA.GameRules; -using OpenRA.Graphics; using OpenRA.Mods.RA.Render; using OpenRA.Traits; @@ -53,7 +52,6 @@ namespace OpenRA.Mods.RA public override void Tick(Actor self) { base.Tick(self); - if (IsProne && --remainingProneTime == 0) LocalOffset = WVec.Zero; } @@ -100,17 +98,13 @@ namespace OpenRA.Mods.RA return base.AllowIdleAnimation(self) && !tc.IsProne; } - public override void TickRender(WorldRenderer wr, Actor self) + public override void Tick(Actor self) { - if (wr.world.Paused == World.PauseState.Paused) - return; - if (wasProne != tc.IsProne) dirty = true; wasProne = tc.IsProne; - - base.TickRender(wr, self); + base.Tick(self); } } } diff --git a/OpenRA.Mods.RA/WaterPaletteRotation.cs b/OpenRA.Mods.RA/WaterPaletteRotation.cs index 1eefcc87e2..9437b64384 100644 --- a/OpenRA.Mods.RA/WaterPaletteRotation.cs +++ b/OpenRA.Mods.RA/WaterPaletteRotation.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); } } - class WaterPaletteRotation : ITickRender, IPaletteModifier + class WaterPaletteRotation : ITick, IPaletteModifier { float t = 0; @@ -36,13 +36,7 @@ namespace OpenRA.Mods.RA this.info = info; } - public void TickRender(WorldRenderer wr, Actor self) - { - if (wr.world.Paused == World.PauseState.Paused) - return; - - t += .25f; - } + public void Tick(Actor self) { t += .25f; } uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */ diff --git a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs index c637d3e588..8233b9eda7 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/GameTimerLogic.cs @@ -27,12 +27,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var startTick = Ui.LastTickTime; // Blink the status line - status.IsVisible = () => (world.Paused == World.PauseState.Paused || world.Timestep != Game.Timestep) + status.IsVisible = () => (world.Paused || world.Timestep != Game.Timestep) && (Ui.LastTickTime - startTick) / 1000 % 2 == 0; status.GetText = () => { - if (world.Paused == World.PauseState.Paused || world.Timestep == 0) + if (world.Paused || world.Timestep == 0) return "Paused"; if (world.Timestep == 1) diff --git a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs index d356cb5e17..5bae5362b1 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/IngameChromeLogic.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic optionsBG.Visible ^= true; if (optionsBG.Visible) { - cachedPause = world.PredictedPaused == World.PauseState.Paused; + cachedPause = world.PredictedPaused; if (world.LobbyInfo.IsSinglePlayer) world.SetPauseState(true); diff --git a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs old mode 100644 new mode 100755 diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 367cf35587..a6568dfc79 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -493,6 +493,7 @@ WALL: DetectCloaked: Range: 5 -WithCrumbleOverlay: + -WithMakeAnimation: LineBuildNode: Types: turret @@ -544,6 +545,7 @@ WALL: DetectCloaked: Range: 6 -WithCrumbleOverlay: + -WithMakeAnimation: LineBuildNode: Types: turret