Shift Sight onto its own trait. Only cnc for now.
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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;
|
||||
|
||||
40
OpenRA.Game/Traits/RevealsShroud.cs
Normal file
40
OpenRA.Game/Traits/RevealsShroud.cs
Normal 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; } }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user