diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 1fbd2e15de..803e0a5afa 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -1,4 +1,4 @@ - + Debug @@ -77,6 +77,7 @@ + diff --git a/OpenRA.Game/Traits/Render/HiddenUnderFog.cs b/OpenRA.Game/Traits/Render/HiddenUnderFog.cs new file mode 100644 index 0000000000..991ce0e3c6 --- /dev/null +++ b/OpenRA.Game/Traits/Render/HiddenUnderFog.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRA.Traits.Render +{ + class HiddenUnderFogInfo : ITraitInfo + { + public object Create(Actor self) { return new HiddenUnderFog(self); } + } + + class HiddenUnderFog : IRenderModifier + { + Shroud shroud; + + public HiddenUnderFog(Actor self) + { + shroud = self.World.WorldActor.traits.Get(); + } + + public IEnumerable ModifyRender(Actor self, IEnumerable r) + { + if (self.Owner == self.World.LocalPlayer || shroud.visibleCells[self.Location.X, self.Location.Y] > 0) + return r; + + return new Renderable[] { }; + } + } +} diff --git a/OpenRA.Game/Traits/Render/RenderUnit.cs b/OpenRA.Game/Traits/Render/RenderUnit.cs index b40a615fbf..4da320ed15 100644 --- a/OpenRA.Game/Traits/Render/RenderUnit.cs +++ b/OpenRA.Game/Traits/Render/RenderUnit.cs @@ -30,17 +30,13 @@ namespace OpenRA.Traits public override object Create(Actor self) { return new RenderUnit(self); } } - class RenderUnit : RenderSimple, INotifyDamage, IRenderModifier + class RenderUnit : RenderSimple, INotifyDamage { - Shroud shroud; - public RenderUnit(Actor self) : base(self, () => self.traits.Get().Facing) { anim.Play("idle"); anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) ); - - shroud = self.World.WorldActor.traits.Get(); } public void PlayCustomAnimation(Actor self, string newAnim, Action after) @@ -62,14 +58,5 @@ namespace OpenRA.Traits () => smoke.PlayBackwardsThen( "end", () => isSmoking = false ) ) ); } - - public IEnumerable ModifyRender(Actor self, IEnumerable r) - { - if (self.Owner == self.World.LocalPlayer || - shroud.visibleCells[self.Location.X, self.Location.Y] > 0) - return r; - - return new Renderable[] { }; - } } } diff --git a/OpenRA.Game/Traits/Unit.cs b/OpenRA.Game/Traits/Unit.cs index d7298546a0..0c948fdf53 100755 --- a/OpenRA.Game/Traits/Unit.cs +++ b/OpenRA.Game/Traits/Unit.cs @@ -36,7 +36,7 @@ namespace OpenRA.Traits [Sync] public int Altitude; - public Unit( Actor self ) { } + public Unit(Actor self) { } public void Damaged(Actor self, AttackInfo e) { diff --git a/mods/cnc/defaults.yaml b/mods/cnc/defaults.yaml index cc4b03defd..58e271ac70 100644 --- a/mods/cnc/defaults.yaml +++ b/mods/cnc/defaults.yaml @@ -10,6 +10,7 @@ Chronoshiftable: Passenger: IronCurtainable: + HiddenUnderFog: ^Infantry: Category: Infantry @@ -23,6 +24,7 @@ SquishByTank: AutoTarget: Passenger: + HiddenUnderFog: ^Ship: Category: Ship @@ -30,11 +32,13 @@ Mobile: MovementType: Float Selectable: + HiddenUnderFog: ^Plane: Category: Plane Unit: Selectable: + HiddenUnderFog: ^Building: Category: Building @@ -48,6 +52,7 @@ DamagedSound: xplos.aud DestroyedSound: xplobig4.aud RenderBuilding: + ^Tree: Category: Building RenderBuilding: @@ -55,6 +60,7 @@ Building: Footprint: __ x_ Dimensions: 2,2 + ^Wall: Category: Building Building: diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml index eef0389781..34b04c8be0 100644 --- a/mods/ra/defaults.yaml +++ b/mods/ra/defaults.yaml @@ -10,6 +10,7 @@ Chronoshiftable: Passenger: IronCurtainable: + HiddenUnderFog: ^Infantry: Category: Infantry @@ -23,6 +24,7 @@ SquishByTank: AutoTarget: Passenger: + HiddenUnderFog: ^Ship: Category: Ship @@ -30,12 +32,14 @@ Mobile: MovementType: Float Selectable: + HiddenUnderFog: ^Plane: Category: Plane Unit: TargetType: Air Selectable: + HiddenUnderFog: ^Building: Category: Building