Shift Sight onto its own trait. Only cnc for now.

This commit is contained in:
Paul Chote
2010-07-28 21:37:10 +12:00
parent 8fab45ae39
commit eaa80fab74
10 changed files with 144 additions and 69 deletions

View File

@@ -227,6 +227,7 @@
<Compile Include="Widgets\WorldInteractionControllerWidget.cs" />
<Compile Include="Widgets\ViewportScrollControllerWidget.cs" />
<Compile Include="Traits\Player\DeveloperMode.cs" />
<Compile Include="Traits\RevealsShroud.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

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

View File

@@ -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<Shroud>().UpdateActor(self);
}
}
public int RevealRange { get { return Info.Range; } }
}
}

View File

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

View File

@@ -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<Shroud>().UpdateActor(self);
}
}
public void Damaged(Actor self, AttackInfo e)
{

View File

@@ -64,9 +64,9 @@ namespace OpenRA.Traits
void AddActor(Actor a)
{
if (a.traits.WithInterface<IRevealShroud>().Count() == 0)
if (!a.traits.Contains<RevealsShroud>())
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<OwnedActorInfo>().Sight,
range = a.traits.Get<RevealsShroud>().RevealRange,
vis = GetVisOrigins(a).ToArray()
};