diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 6a5bb88a9b..f7777d7a4a 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -292,7 +292,6 @@ - diff --git a/OpenRA.Game/Traits/Cloak.cs b/OpenRA.Game/Traits/Cloak.cs deleted file mode 100644 index 9241ff16b3..0000000000 --- a/OpenRA.Game/Traits/Cloak.cs +++ /dev/null @@ -1,82 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System.Collections.Generic; -using System.Linq; - -namespace OpenRA.Traits -{ - class CloakInfo : ITraitInfo - { - public readonly float CloakDelay = 1.2f; // Seconds - public readonly string CloakSound = "appear1.aud"; - public readonly string UncloakSound = "appear1.aud"; - public object Create(Actor self) { return new Cloak(self); } - } - - class Cloak : IRenderModifier, INotifyAttack, ITick - { - [Sync] - int remainingUncloakTime = 2; /* setup for initial cloak */ - - Actor self; - public Cloak(Actor self) - { - this.self = self; - } - - public void Attacking(Actor self) - { - if (remainingUncloakTime <= 0) - OnCloak(); - - remainingUncloakTime = (int)(self.Info.Traits.Get().CloakDelay * 25); - } - - public IEnumerable - ModifyRender(Actor self, IEnumerable rs) - { - if (remainingUncloakTime > 0) - return rs; - - if (self.Owner == self.World.LocalPlayer) - return rs.Select(a => a.WithPalette("shadow")); - else - return new Renderable[] { }; - } - - public void Tick(Actor self) - { - if (remainingUncloakTime > 0) - if (--remainingUncloakTime <= 0) - OnUncloak(); - } - - void OnCloak() - { - Sound.Play(self.Info.Traits.Get().CloakSound, self.CenterLocation); - } - - void OnUncloak() - { - Sound.Play(self.Info.Traits.Get().UncloakSound, self.CenterLocation); - } - } -} diff --git a/OpenRA.Game/Traits/Submarine.cs b/OpenRA.Game/Traits/Submarine.cs index eb679351c7..7dfcbcf95e 100644 --- a/OpenRA.Game/Traits/Submarine.cs +++ b/OpenRA.Game/Traits/Submarine.cs @@ -23,31 +23,33 @@ using System.Linq; namespace OpenRA.Traits { - class SubmarineInfo : ITraitInfo + class CloakInfo : ITraitInfo { - public readonly float SubmergeDelay = 1.2f; // Seconds - public readonly string SubmergeSound = "subshow1.aud"; - public readonly string SurfaceSound = "subshow1.aud"; - public object Create(Actor self) { return new Submarine(self); } + public readonly float InitialDelay = .4f; // seconds + public readonly float CloakDelay = 1.2f; // Seconds + public readonly string CloakSound = "subshow1.aud"; + public readonly string UncloakSound = "subshow1.aud"; + public object Create(Actor self) { return new Cloak(self); } } - class Submarine : IRenderModifier, INotifyAttack, ITick, INotifyDamage + class Cloak : IRenderModifier, INotifyAttack, ITick, INotifyDamage { [Sync] - int remainingSurfaceTime = 2; /* setup for initial dive */ + int remainingTime; Actor self; - public Submarine(Actor self) + public Cloak(Actor self) { + remainingTime = (int)(self.Info.Traits.Get().InitialDelay * 25); this.self = self; } void DoSurface() { - if (remainingSurfaceTime <= 0) + if (remainingTime <= 0) OnSurface(); - remainingSurfaceTime = (int)(self.Info.Traits.Get().SubmergeDelay * 25); + remainingTime = (int)(self.Info.Traits.Get().CloakDelay * 25); } public void Attacking(Actor self) { DoSurface(); } @@ -56,7 +58,7 @@ namespace OpenRA.Traits public IEnumerable ModifyRender(Actor self, IEnumerable rs) { - if (remainingSurfaceTime > 0) + if (remainingTime > 0) return rs; if (self.Owner == self.World.LocalPlayer) @@ -67,19 +69,21 @@ namespace OpenRA.Traits public void Tick(Actor self) { - if (remainingSurfaceTime > 0) - if (--remainingSurfaceTime <= 0) + if (remainingTime > 0) + if (--remainingTime <= 0) OnDive(); } void OnSurface() { - Sound.Play(self.Info.Traits.Get().SurfaceSound, self.CenterLocation); + Sound.Play(self.Info.Traits.Get().UncloakSound, self.CenterLocation); } void OnDive() { - Sound.Play(self.Info.Traits.Get().SubmergeSound, self.CenterLocation); + Sound.Play(self.Info.Traits.Get().CloakSound, self.CenterLocation); } + + public bool Cloaked { get { return remainingTime > 0; } } } } diff --git a/mods/aftermath/rules.yaml b/mods/aftermath/rules.yaml index cf03c104a0..bc39d6f09e 100644 --- a/mods/aftermath/rules.yaml +++ b/mods/aftermath/rules.yaml @@ -114,7 +114,11 @@ MSUB: PrimaryWeapon: SubSCUD FireDelay: 2 RenderUnit: - Submarine: + Cloak: + InitialDelay: .4 + CloakDelay: 2.0 + CloakSound: subshow1.aud + UncloakSound: subshow1.aud Chronoshiftable: SHOK: diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index efd16c675b..671290a380 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -375,6 +375,10 @@ STNK: Sight: 4 Speed: 15 Cloak: + InitialDelay: .4 + CloakDelay: 2.0 + CloakSound: appear1.aud + UncloakSound: appear1.aud Mobile: MovementType: Track AttackBase: diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index af559f70e6..7771e2be1f 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -392,7 +392,11 @@ SS: WaterBound: yes TargetType: Sub RenderUnit: - Submarine: + Cloak: + InitialDelay: .4 + CloakDelay: 2.0 + CloakSound: subshow1.aud + UncloakSound: subshow1.aud AttackBase: PrimaryWeapon: TorpTube FireDelay: 2