From 7dbd9f1f762e2a092db8ee1a414bb67efeb9d572 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 12 May 2010 18:48:02 +1200 Subject: [PATCH] real class for a shake effect instance, rather than tuple --- OpenRA.Game/Traits/World/ScreenShaker.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index 53d0967ce4..f4db3d71fc 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -20,9 +20,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using OpenRA.FileFormats; - +using System.Linq; + namespace OpenRA.Traits { class ScreenShakerInfo : ITraitInfo @@ -33,18 +32,18 @@ namespace OpenRA.Traits public class ScreenShaker : ITick { int ticks = 0; - List> shakeEffects = new List>(); + List shakeEffects = new List(); public void Tick (Actor self) { Game.viewport.Scroll(getScrollOffset()); - shakeEffects.RemoveAll(t => t.a == ticks); + shakeEffects.RemoveAll(t => t.ExpiryTime == ticks); ticks++; } public void AddEffect(int time, float2 position, int intensity) - { - shakeEffects.Add(OpenRA.FileFormats.Tuple.New(ticks + time, position, intensity)); + { + shakeEffects.Add(new ShakeEffect { ExpiryTime = ticks + time, Position = position, Intensity = intensity }); } public float2 getScrollOffset() @@ -63,10 +62,11 @@ namespace OpenRA.Traits + .5f * new float2(Game.viewport.Width, Game.viewport.Height); var intensity = 24 * 24 * 100 * shakeEffects.Sum( - e => e.c / (e.b - cp).LengthSquared); + e => e.Intensity / (e.Position - cp).LengthSquared); return Math.Min(intensity, 10); } - - } + } + + class ShakeEffect { public int ExpiryTime; public float2 Position; public int Intensity; } }