diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 1d1254fd5c..99b8cead12 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -227,6 +227,7 @@ + diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index e2e514192e..cbf153a67d 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -22,7 +22,6 @@ namespace OpenRA.Traits { public readonly int HP = 0; public readonly ArmorType Armor = ArmorType.none; - public readonly int Sight = 0; public readonly string[] TargetType = {"Ground"}; } @@ -47,7 +46,7 @@ namespace OpenRA.Traits public object Create(ActorInitializer init) { return new Building(init); } } - public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace, IRadarSignature, IRevealShroud + public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace, IRadarSignature { readonly Actor self; public readonly BuildingInfo Info; diff --git a/OpenRA.Game/Traits/RevealsShroud.cs b/OpenRA.Game/Traits/RevealsShroud.cs new file mode 100644 index 0000000000..259158c854 --- /dev/null +++ b/OpenRA.Game/Traits/RevealsShroud.cs @@ -0,0 +1,40 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 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, + * see LICENSE. + */ +#endregion + +namespace OpenRA.Traits +{ + class RevealsShroudInfo : ITraitInfo + { + public readonly int Range = 0; + public object Create(ActorInitializer init) { return new RevealsShroud(this); } + } + + class RevealsShroud : ITick + { + RevealsShroudInfo Info; + int2 previousLocation; + + public RevealsShroud(RevealsShroudInfo info) + { + Info = info; + } + + public void Tick(Actor self) + { + if (!self.IsIdle && previousLocation != self.Location) + { + previousLocation = self.Location; + self.World.WorldActor.traits.Get().UpdateActor(self); + } + } + + public int RevealRange { get { return Info.Range; } } + } +} diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 9fe3948843..8c5a7cda1e 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -59,7 +59,6 @@ namespace OpenRA.Traits public interface IVisibilityModifier { bool IsVisible(Actor self); } public interface IRadarColorModifier { Color RadarColorOverride(Actor self); } - public interface IRevealShroud {} public interface IOccupySpace { int2 TopLeft { get; } diff --git a/OpenRA.Game/Traits/Unit.cs b/OpenRA.Game/Traits/Unit.cs index 28ec63260b..9b64f11f5b 100755 --- a/OpenRA.Game/Traits/Unit.cs +++ b/OpenRA.Game/Traits/Unit.cs @@ -23,22 +23,12 @@ namespace OpenRA.Traits public object Create( ActorInitializer init ) { return new Unit(); } } - public class Unit : INotifyDamage, IRadarSignature, IRevealShroud, ITick + public class Unit : INotifyDamage, IRadarSignature { [Sync] public int Facing; [Sync] public int Altitude; - - int2 previousLocation; - public void Tick(Actor self) - { - if (!self.IsIdle && previousLocation != self.Location) - { - previousLocation = self.Location; - self.World.WorldActor.traits.Get().UpdateActor(self); - } - } public void Damaged(Actor self, AttackInfo e) { diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 34893af6e1..4d2a563c34 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -64,9 +64,9 @@ namespace OpenRA.Traits void AddActor(Actor a) { - if (a.traits.WithInterface().Count() == 0) + if (!a.traits.Contains()) return; - + if (a.Owner == null || a.Owner.World.LocalPlayer == null || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; @@ -78,7 +78,7 @@ namespace OpenRA.Traits var v = new ActorVisibility { - range = a.Info.Traits.Get().Sight, + range = a.traits.Get().RevealRange, vis = GetVisOrigins(a).ToArray() }; diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index b83d58fe3f..711bc01c7b 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -53,7 +53,8 @@ Category: Infantry Unit: Armor: none - Sight: 4 + RevealsShroud: + Range: 4 Mobile: TerrainTypes: Clear, Rough, Road, Tree, Water, Rock, Wall, Ore, Beach, River TerrainSpeeds: 90%, 80%, 100%, 0%, 0%, 0%, 0%, 90%, 80%, 0% @@ -130,7 +131,6 @@ BuildSounds: hvydoor1.aud Capturable: false BaseNormal: no - Sight: 0 DamagedSound: xplos.aud DestroyedSound: xplobig4.aud Adjacent: 7 diff --git a/mods/cnc/infantry.yaml b/mods/cnc/infantry.yaml index 1ea2f0c777..f0226387fd 100644 --- a/mods/cnc/infantry.yaml +++ b/mods/cnc/infantry.yaml @@ -143,7 +143,8 @@ RMBO: Unit: HP: 200 Speed: 5 - Sight: 5 + RevealsShroud: + Range: 5 AttackBase: PrimaryWeapon: Sniper TakeCover: @@ -160,8 +161,9 @@ C1: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -175,8 +177,9 @@ C2: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -190,8 +193,9 @@ C3: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -205,8 +209,9 @@ C4: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -220,8 +225,9 @@ C5: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -235,8 +241,9 @@ C6: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -250,8 +257,9 @@ C7: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol C8: @@ -264,8 +272,9 @@ C8: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -279,8 +288,9 @@ C9: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol @@ -294,7 +304,8 @@ C10: Description: Technician Unit: HP: 20 - Sight: 2 Speed: 4 + RevealsShroud: + Range: 2 AttackBase: PrimaryWeapon: Pistol diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml index c2e30b6800..8c9860d710 100644 --- a/mods/cnc/structures.yaml +++ b/mods/cnc/structures.yaml @@ -10,7 +10,8 @@ FACT: Capturable: true HP: 800 Armor: wood - Sight: 5 + RevealsShroud: + Range: 5 Bib: Production: Produces: Building,Defense @@ -32,7 +33,8 @@ NUKE: Capturable: true HP: 400 Armor: wood - Sight: 4 + RevealsShroud: + Range: 4 Bib: PROC.proxy: @@ -52,7 +54,8 @@ PROC.proxy: Capturable: true HP: 900 Armor: wood - Sight: 6 + RevealsShroud: + Range: 6 ReplaceWithActor: Actor: proc @@ -69,7 +72,8 @@ PROC: Capturable: true HP: 900 Armor: wood - Sight: 6 + RevealsShroud: + Range: 6 Bib: OreRefinery: LocalStorage: yes @@ -110,7 +114,8 @@ SILO: Capturable: true HP: 300 Armor: wood - Sight: 4 + RevealsShroud: + Range: 4 RenderBuildingOre: StoresOre: PipCount: 5 @@ -137,7 +142,8 @@ PYLE: Capturable: true HP: 800 Armor: wood - Sight: 5 + RevealsShroud: + Range: 5 Bib: RallyPoint: Production: @@ -161,7 +167,8 @@ HAND: Capturable: true HP: 800 Armor: wood - Sight: 5 + RevealsShroud: + Range: 5 Bib: RallyPoint: Production: @@ -185,7 +192,8 @@ AFLD: Capturable: true HP: 1000 Armor: heavy - Sight: 7 + RevealsShroud: + Range: 7 Bib: RallyPoint: BelowUnits: @@ -210,7 +218,8 @@ WEAP: Capturable: true HP: 400 Armor: light - Sight: 4 + RevealsShroud: + Range: 4 Bib: RenderWarFactory: RallyPoint: @@ -236,7 +245,8 @@ HQ: Capturable: true HP: 1000 Armor: wood - Sight: 10 + RevealsShroud: + Range: 10 Bib: ProvidesRadar: DetectCloaked: @@ -259,7 +269,8 @@ NUK2: Capturable: true HP: 600 Armor: wood - Sight: 4 + RevealsShroud: + Range: 4 Bib: FIX: @@ -279,7 +290,8 @@ FIX: Capturable: true HP: 800 Armor: wood - Sight: 5 + RevealsShroud: + Range: 5 BelowUnits: Reservable: RepairsUnits: @@ -302,7 +314,8 @@ HPAD: Capturable: true HP: 800 Armor: wood - Sight: 5 + RevealsShroud: + Range: 5 Bib: Production: SpawnOffset: 0,-4 @@ -332,7 +345,8 @@ EYE: Capturable: true HP: 1000 Armor: wood - Sight: 10 + RevealsShroud: + Range: 10 Bib: ProvidesRadar: IonControl: @@ -357,7 +371,8 @@ TMPL: Capturable: false HP: 2000 Armor: light - Sight: 6 + RevealsShroud: + Range: 6 Bib: NukeSilo: MissileWeapon: atomic @@ -380,7 +395,8 @@ OBLI: Dimensions: 1,2 HP: 400 Armor: light - Sight: 8 + RevealsShroud: + Range: 8 RenderBuildingCharge: ChargeAudio: obelpowr.aud AttackOmni: @@ -458,7 +474,8 @@ GUN: Power: -20 HP: 400 Armor: heavy - Sight: 7 + RevealsShroud: + Range: 7 Turreted: ROT: 12 InitialFacing: 50 @@ -486,7 +503,8 @@ SAM: Dimensions: 2,1 HP: 400 Armor: heavy - Sight: 5 + RevealsShroud: + Range: 5 Turreted: ROT: 30 InitialFacing: 0 @@ -512,7 +530,8 @@ GTWR: Power: -10 HP: 400 Armor: wood - Sight: 6 + RevealsShroud: + Range: 6 AttackOmni: PrimaryWeapon: HighV AutoTarget: @@ -535,7 +554,8 @@ ATWR: Power: -20 HP: 600 Armor: light - Sight: 8 + RevealsShroud: + Range: 8 AttackOmni: PrimaryWeapon: Tomahawk SecondaryWeapon: Tomahawk diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index 02de243566..eb3ee4329e 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -13,8 +13,9 @@ MCV: Unit: HP: 600 Armor: light - Sight: 4 Speed: 6 + RevealsShroud: + Range: 4 TransformsOnDeploy: TransformsInto: fact Offset:-1,-1 @@ -44,8 +45,9 @@ HARV: Unit: HP: 600 Armor: light - Sight: 4 Speed: 6 + RevealsShroud: + Range: 4 RenderUnit: APC: @@ -62,8 +64,9 @@ APC: HP: 200 Armor: heavy ROT: 5 - Sight: 5 Speed: 15 + RevealsShroud: + Range: 5 AttackBase: PrimaryWeapon: MachineGun PrimaryOffset: 0,0,0,-4 @@ -90,8 +93,9 @@ ARTY: HP: 75 Armor: light ROT: 2 - Sight: 6 Speed: 6 + RevealsShroud: + Range: 6 AttackBase: PrimaryWeapon: Ballistic RenderUnit: @@ -112,8 +116,9 @@ FTNK: HP: 300 Armor: heavy ROT: 5 - Sight: 4 Speed: 9 + RevealsShroud: + Range: 4 AttackBase: PrimaryWeapon: BigFlamer PrimaryOffset: 0,0,0,-2 @@ -135,8 +140,9 @@ BGGY: HP: 140 Armor: light ROT: 10 - Sight: 5 Speed: 18 + RevealsShroud: + Range: 5 Turreted: ROT: 10 AttackTurreted: @@ -160,8 +166,9 @@ BIKE: HP: 160 Armor: none ROT: 10 - Sight: 7 Speed: 20 + RevealsShroud: + Range: 7 AttackBase: PrimaryWeapon: Rockets PrimaryOffset: 0,0,0,-2 @@ -186,8 +193,9 @@ JEEP: HP: 150 Armor: light ROT: 10 - Sight: 7 Speed: 15 + RevealsShroud: + Range: 7 Turreted: ROT: 10 AttackTurreted: @@ -210,8 +218,9 @@ LTNK: Unit: HP: 300 Armor: Heavy - Sight: 4 Speed: 9 + RevealsShroud: + Range: 4 Turreted: ROT: 5 AttackTurreted: @@ -238,8 +247,9 @@ MTNK: Unit: HP: 400 Armor: heavy - Sight: 5 Speed: 9 + RevealsShroud: + Range: 5 Turreted: ROT: 5 AttackTurreted: @@ -266,8 +276,9 @@ HTNK: Unit: HP: 600 Armor: heavy - Sight: 6 Speed: 3 + RevealsShroud: + Range: 6 Turreted: ROT: 2 AttackTurreted: @@ -300,8 +311,9 @@ MSAM: Unit: HP: 120 Armor: light - Sight: 6 Speed: 6 + RevealsShroud: + Range: 6 Turreted: ROT: 5 AttackTurreted: @@ -327,8 +339,9 @@ MLRS: Unit: HP: 120 Armor: light - Sight: 10 Speed: 6 + RevealsShroud: + Range: 10 Turreted: ROT: 5 AttackTurreted: @@ -350,8 +363,9 @@ STNK: Unit: HP: 110 Armor: light - Sight: 4 Speed: 15 + RevealsShroud: + Range: 4 Cloak: InitialDelay: .4 CloakDelay: 2.0 @@ -378,8 +392,9 @@ TRAN: Armor: light InitialFacing: 20 ROT: 5 - Sight: 8 Speed: 15 + RevealsShroud: + Range: 8 RenderUnitRotor: PrimaryOffset: 0,14,0,-4 SecondaryOffset: 0,-14,0,-2 @@ -404,8 +419,9 @@ HELI: Armor: heavy InitialFacing: 20 ROT: 4 - Sight: 8 Speed: 20 + RevealsShroud: + Range: 8 AttackBase: PrimaryWeapon: HighV SecondaryWeapon: HighV @@ -431,8 +447,9 @@ ORCA: Armor: heavy InitialFacing: 20 ROT: 4 - Sight: 8 Speed: 20 + RevealsShroud: + Range: 8 AttackBase: PrimaryWeapon: Rockets.Orca SecondaryWeapon: Rockets.Orca @@ -450,7 +467,6 @@ C17: HP: 25 Armor: light ROT: 5 - Sight: 0 Speed: 25 Plane: RenderUnit: @@ -467,7 +483,6 @@ A10: HP: 60 Armor: light ROT: 4 - Sight: 0 Speed: 25 Plane: RenderUnit: