From 15ab0738c7d43ef368be2463e512d5c968497c8d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Dec 2009 22:05:34 -0800 Subject: [PATCH] Add Aftermath units; most without special logic. Seperate Cloaking from Submarine behavior. Fix crash when selecting unit with no speedmodifier traits. Add "Cannot deploy here" build notification. --- OpenRa.Game/Traits/Submarine.cs | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 OpenRa.Game/Traits/Submarine.cs diff --git a/OpenRa.Game/Traits/Submarine.cs b/OpenRa.Game/Traits/Submarine.cs new file mode 100644 index 0000000000..f831b7acdb --- /dev/null +++ b/OpenRa.Game/Traits/Submarine.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Linq; +using OpenRa.Game.Graphics; + +namespace OpenRa.Game.Traits +{ + class Submarine : IRenderModifier, INotifyAttack, ITick + { + int remainingSurfaceTime = 2; /* setup for initial dive */ + + public Submarine(Actor self) { } + + public void Attacking(Actor self) + { + if (remainingSurfaceTime <= 0) + OnSurface(); + + remainingSurfaceTime = (int)(Rules.General.SubmergeDelay * 60 * 25); + } + + public IEnumerable> + ModifyRender(Actor self, IEnumerable> rs) + { + if (remainingSurfaceTime > 0) + return rs; + + if (self.Owner == Game.LocalPlayer) + return rs.Select(a => Tuple.New(a.a, a.b, 8)); + else + return new Tuple[] { }; + } + + public void Tick(Actor self) + { + if (remainingSurfaceTime > 0) + if (--remainingSurfaceTime <= 0) + OnDive(); + } + + void OnSurface() + { + Sound.Play("subshow1.aud"); + } + + void OnDive() + { + Sound.Play("subshow1.aud"); /* is this the right sound?? */ + } + } +}