fix units being visible under fog

This commit is contained in:
Chris Forbes
2010-04-02 17:09:20 +13:00
parent ca0d993c1a
commit 37fd8f7c28
6 changed files with 44 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -77,6 +77,7 @@
<Compile Include="Chrome.cs" />
<Compile Include="GameRules\WeaponInfo.cs" />
<Compile Include="Traits\AI\ReturnOnIdle.cs" />
<Compile Include="Traits\Render\HiddenUnderFog.cs" />
<Compile Include="Traits\World\Shroud.cs" />
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />

View File

@@ -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<Shroud>();
}
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
if (self.Owner == self.World.LocalPlayer || shroud.visibleCells[self.Location.X, self.Location.Y] > 0)
return r;
return new Renderable[] { };
}
}
}

View File

@@ -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<Unit>().Facing)
{
anim.Play("idle");
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
shroud = self.World.WorldActor.traits.Get<Shroud>();
}
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
@@ -62,14 +58,5 @@ namespace OpenRA.Traits
() => smoke.PlayBackwardsThen( "end",
() => isSmoking = false ) ) );
}
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
if (self.Owner == self.World.LocalPlayer ||
shroud.visibleCells[self.Location.X, self.Location.Y] > 0)
return r;
return new Renderable[] { };
}
}
}

View File

@@ -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)
{

View File

@@ -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:

View File

@@ -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