use TickRender() for RenderSprites and PaletteModifier

This commit is contained in:
Matthias Mailänder
2014-07-03 20:42:37 +02:00
parent 58cb603803
commit 87fd576b26
23 changed files with 48 additions and 43 deletions

4
OpenRA.Game/Traits/Render/RenderSprites.cs Executable file → Normal file
View File

@@ -31,7 +31,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new RenderSprites(init.self); } public virtual object Create(ActorInitializer init) { return new RenderSprites(init.self); }
} }
public class RenderSprites : IRender, ITick, INotifyOwnerChanged, INotifyEffectiveOwnerChanged public class RenderSprites : IRender, ITickRender, INotifyOwnerChanged, INotifyEffectiveOwnerChanged
{ {
class AnimationWrapper class AnimationWrapper
{ {
@@ -126,7 +126,7 @@ namespace OpenRA.Traits
} }
} }
public virtual void Tick(Actor self) public virtual void TickRender(WorldRenderer wr, Actor self)
{ {
foreach (var a in anims.Values) foreach (var a in anims.Values)
a.Animation.Animation.Tick(); a.Animation.Animation.Tick();

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA
public override object Create(ActorInitializer init) { return new AttackGarrisoned(init.self, this); } public override object Create(ActorInitializer init) { return new AttackGarrisoned(init.self, this); }
} }
public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender, ITickRender
{ {
public readonly FirePort[] Ports; public readonly FirePort[] Ports;
@@ -183,10 +183,8 @@ namespace OpenRA.Mods.RA
yield return r; yield return r;
} }
public override void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
base.Tick(self);
// Take a copy so that Tick() can remove animations // Take a copy so that Tick() can remove animations
foreach (var m in muzzles.ToList()) foreach (var m in muzzles.ToList())
m.Animation.Tick(); m.Animation.Tick();

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
{ {
class ChronoshiftPaletteEffectInfo : TraitInfo<ChronoshiftPaletteEffect> { } class ChronoshiftPaletteEffectInfo : TraitInfo<ChronoshiftPaletteEffect> { }
public class ChronoshiftPaletteEffect : IPaletteModifier, ITick public class ChronoshiftPaletteEffect : IPaletteModifier, ITickRender
{ {
const int chronoEffectLength = 60; const int chronoEffectLength = 60;
int remainingFrames; int remainingFrames;
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
remainingFrames = chronoEffectLength; remainingFrames = chronoEffectLength;
} }
public void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
if (remainingFrames > 0) if (remainingFrames > 0)
remainingFrames--; remainingFrames--;

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #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 * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
{ {
public class CloakPaletteEffectInfo : TraitInfo<CloakPaletteEffect> { } public class CloakPaletteEffectInfo : TraitInfo<CloakPaletteEffect> { }
public class CloakPaletteEffect : IPaletteModifier, ITick public class CloakPaletteEffect : IPaletteModifier, ITickRender
{ {
float t = 0; float t = 0;
string paletteName = "cloak"; string paletteName = "cloak";
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
} }
} }
public void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
t += 0.25f; t += 0.25f;
if (t >= 256) t = 0; if (t >= 256) t = 0;

0
OpenRA.Mods.RA/Effects/Bullet.cs Executable file → Normal file
View File

0
OpenRA.Mods.RA/Effects/Missile.cs Executable file → Normal file
View File

0
OpenRA.Mods.RA/Effects/NukeLaunch.cs Executable file → Normal file
View File

0
OpenRA.Mods.RA/Effects/RepairIndicator.cs Executable file → Normal file
View File

View File

@@ -23,10 +23,10 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new LightPaletteRotator(this); } public object Create(ActorInitializer init) { return new LightPaletteRotator(this); }
} }
class LightPaletteRotator : ITick, IPaletteModifier class LightPaletteRotator : ITickRender, IPaletteModifier
{ {
float t = 0; float t = 0;
public void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
t += .5f; t += .5f;
} }

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
{ {
class NukePaletteEffectInfo : TraitInfo<NukePaletteEffect> { } class NukePaletteEffectInfo : TraitInfo<NukePaletteEffect> { }
public class NukePaletteEffect : IPaletteModifier, ITick public class NukePaletteEffect : IPaletteModifier, ITickRender
{ {
const int nukeEffectLength = 20; const int nukeEffectLength = 20;
int remainingFrames; int remainingFrames;
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
remainingFrames = nukeEffectLength; remainingFrames = nukeEffectLength;
} }
public void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
if (remainingFrames > 0) if (remainingFrames > 0)
remainingFrames--; remainingFrames--;

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
@@ -43,9 +44,9 @@ namespace OpenRA.Mods.RA.Render
DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent); DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent);
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
base.Tick(self); base.TickRender(wr, self);
if (!dirty) if (!dirty)
return; return;

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Render
} }
} }
class RenderBuildingWarFactory : RenderBuilding, INotifyBuildComplete, ITick, INotifyProduction, INotifySold, ISync class RenderBuildingWarFactory : RenderBuilding, INotifyBuildComplete, ITickRender, INotifyProduction, INotifySold, ISync
{ {
Animation roof; Animation roof;
[Sync] bool isOpen; [Sync] bool isOpen;
@@ -62,9 +62,9 @@ namespace OpenRA.Mods.RA.Render
buildComplete = true; buildComplete = true;
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
base.Tick(self); base.TickRender(wr, self);
if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit).Any( a => a != self )) if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit).Any( a => a != self ))
{ {
isOpen = false; isOpen = false;

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Graphics;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
{ {
@@ -31,7 +32,7 @@ namespace OpenRA.Mods.RA.Render
intendedSprite = disguise.AsSprite; intendedSprite = disguise.AsSprite;
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
if (disguise.AsSprite != intendedSprite) if (disguise.AsSprite != intendedSprite)
{ {
@@ -40,7 +41,7 @@ namespace OpenRA.Mods.RA.Render
UpdatePalette(); UpdatePalette();
} }
base.Tick(self); base.TickRender(wr, self);
} }
} }
} }

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Render
new Animation(self.World, image); new Animation(self.World, image);
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
var desiredState = harv.Fullness * (info.ImagesByFullness.Length - 1) / 100; var desiredState = harv.Fullness * (info.ImagesByFullness.Length - 1) / 100;
var desiredImage = info.ImagesByFullness[desiredState]; var desiredImage = info.ImagesByFullness[desiredState];
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Render
if (DefaultAnimation.Name != desiredImage) if (DefaultAnimation.Name != desiredImage)
DefaultAnimation.ChangeImage(desiredImage, "idle"); DefaultAnimation.ChangeImage(desiredImage, "idle");
base.Tick(self); base.TickRender(wr, self);
} }
public void Harvested(Actor self, ResourceType resource) public void Harvested(Actor self, ResourceType resource)

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #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 * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using OpenRA.Graphics;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -79,9 +80,9 @@ namespace OpenRA.Mods.RA.Render
Attacking(self, target); Attacking(self, target);
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
base.Tick(self); base.TickRender(wr, self);
if ((State == AnimationState.Moving || dirty) && !move.IsMoving) if ((State == AnimationState.Moving || dirty) && !move.IsMoving)
{ {

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #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 * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
@@ -43,13 +44,13 @@ namespace OpenRA.Mods.RA.Render
return base.AllowIdleAnimation(self) && !sc.Panicking; return base.AllowIdleAnimation(self) && !sc.Panicking;
} }
public override void Tick (Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
if (wasPanic != sc.Panicking) if (wasPanic != sc.Panicking)
dirty = true; dirty = true;
wasPanic = sc.Panicking; wasPanic = sc.Panicking;
base.Tick(self); base.TickRender(wr, self);
} }
} }
} }

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA.Render
public bool ShouldBeOpen() public bool ShouldBeOpen()
{ {
if (self.CenterPosition.Z > 0 || move.IsMoving) if (self.CenterPosition.Z > 0 || move.IsMoving || cargo.CurrentAdjacentCells == null)
return false; return false;
return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c) return cargo.CurrentAdjacentCells.Any(c => self.World.Map.Contains(c)
@@ -70,14 +71,14 @@ namespace OpenRA.Mods.RA.Render
PlayCustomAnimBackwards(self, info.OpenAnim, null); PlayCustomAnimBackwards(self, info.OpenAnim, null);
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
if (ShouldBeOpen()) if (ShouldBeOpen())
Open(); Open();
else else
Close(); Close();
base.Tick(self); base.TickRender(wr, self);
} }
} }
} }

View File

@@ -9,6 +9,7 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
@@ -34,13 +35,13 @@ namespace OpenRA.Mods.RA.Render
.Single(a => a.Info.Name == info.Armament); .Single(a => a.Info.Name == info.Armament);
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
var sequence = (armament.IsReloading ? "empty-" : "") + (attack.IsAttacking ? "aim" : "idle"); var sequence = (armament.IsReloading ? "empty-" : "") + (attack.IsAttacking ? "aim" : "idle");
if (sequence != DefaultAnimation.CurrentSequence.Name) if (sequence != DefaultAnimation.CurrentSequence.Name)
DefaultAnimation.ReplaceAnim(sequence); DefaultAnimation.ReplaceAnim(sequence);
base.Tick(self); base.TickRender(wr, self);
} }
} }
} }

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Render
public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self, this); } public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self, this); }
} }
class WithMuzzleFlash : INotifyAttack, IRender, ITick class WithMuzzleFlash : INotifyAttack, IRender, ITickRender
{ {
Dictionary<Barrel, bool> visible = new Dictionary<Barrel, bool>(); Dictionary<Barrel, bool> visible = new Dictionary<Barrel, bool>();
Dictionary<Barrel, AnimationWithOffset> anims = new Dictionary<Barrel, AnimationWithOffset>(); Dictionary<Barrel, AnimationWithOffset> anims = new Dictionary<Barrel, AnimationWithOffset>();
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA.Render
} }
} }
public void Tick(Actor self) public void TickRender(WorldRenderer wr, Actor self)
{ {
foreach (var a in anims.Values) foreach (var a in anims.Values)
a.Animation.Tick(); a.Animation.Tick();

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information #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 * 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 * available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information, * as published by the Free Software Foundation. For more information,
@@ -9,6 +9,7 @@
#endregion #endregion
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Render; using OpenRA.Mods.RA.Render;
using OpenRA.Traits; using OpenRA.Traits;
@@ -98,13 +99,13 @@ namespace OpenRA.Mods.RA
return base.AllowIdleAnimation(self) && !tc.IsProne; return base.AllowIdleAnimation(self) && !tc.IsProne;
} }
public override void Tick(Actor self) public override void TickRender(WorldRenderer wr, Actor self)
{ {
if (wasProne != tc.IsProne) if (wasProne != tc.IsProne)
dirty = true; dirty = true;
wasProne = tc.IsProne; wasProne = tc.IsProne;
base.Tick(self); base.TickRender(wr, self);
} }
} }
} }

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); } public object Create(ActorInitializer init) { return new WaterPaletteRotation(init.world, this); }
} }
class WaterPaletteRotation : ITick, IPaletteModifier class WaterPaletteRotation : ITickRender, IPaletteModifier
{ {
float t = 0; float t = 0;
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA
this.info = info; this.info = info;
} }
public void Tick(Actor self) { t += .25f; } public void TickRender(WorldRenderer wr, Actor self) { t += .25f; }
uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */ uint[] temp = new uint[7]; /* allocating this on the fly actually hurts our profile */

0
OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs Executable file → Normal file
View File