New interface for things that show on radar; groundwork for future patches.
This commit is contained in:
@@ -126,10 +126,16 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
int* c = (int*)bitmapData.Scan0;
|
int* c = (int*)bitmapData.Scan0;
|
||||||
|
|
||||||
foreach (var a in world.Queries.WithTrait<Unit>().Where(a => a.Actor.Owner != null && a.Actor.IsVisible()))
|
foreach (var t in world.Queries.WithTraitMultiple<IRadarSignature>())
|
||||||
*(c + ((a.Actor.Location.Y - world.Map.TopLeft.Y)* bitmapData.Stride >> 2) + a.Actor.Location.X - world.Map.TopLeft.X) =
|
{
|
||||||
a.Actor.Owner.Color.ToArgb();
|
var color = t.Trait.RadarSignatureColor(t.Actor);
|
||||||
|
if (color == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach( var cell in t.Trait.RadarSignatureCells(t.Actor))
|
||||||
|
*(c + ((cell.Y - world.Map.TopLeft.Y)* bitmapData.Stride >> 2) + cell.X - world.Map.TopLeft.X) = color.ToArgb();
|
||||||
|
}
|
||||||
|
|
||||||
for (var x = 0; x < map.Width; x++)
|
for (var x = 0; x < map.Width; x++)
|
||||||
for (var y = 0; y < map.Height; y++)
|
for (var y = 0; y < map.Height; y++)
|
||||||
{
|
{
|
||||||
@@ -146,10 +152,6 @@ namespace OpenRA.Graphics
|
|||||||
*(c + (y * bitmapData.Stride >> 2) + x) = Util.LerpARGBColor(fogOpacity, *(c + (y * bitmapData.Stride >> 2) + x), shroud);
|
*(c + (y * bitmapData.Stride >> 2) + x) = Util.LerpARGBColor(fogOpacity, *(c + (y * bitmapData.Stride >> 2) + x), shroud);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var b = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(new int2(mapX, mapY));
|
|
||||||
if (b != null)
|
|
||||||
*(c + (y * bitmapData.Stride >> 2) + x) = b.Owner.Color.ToArgb();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
@@ -47,7 +48,7 @@ namespace OpenRA.Traits
|
|||||||
public object Create(ActorInitializer init) { return new Building(init); }
|
public object Create(ActorInitializer init) { return new Building(init); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace
|
public class Building : INotifyDamage, IResolveOrder, ITick, IRenderModifier, IOccupySpace, IRadarSignature
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
public readonly BuildingInfo Info;
|
public readonly BuildingInfo Info;
|
||||||
@@ -160,5 +161,15 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
return Footprint.UnpathableTiles( self.Info.Name, Info, TopLeft );
|
return Footprint.UnpathableTiles( self.Info.Name, Info, TopLeft );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
||||||
|
{
|
||||||
|
return Footprint.Tiles(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color RadarSignatureColor(Actor self)
|
||||||
|
{
|
||||||
|
return self.Owner.Color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ namespace OpenRA.Traits
|
|||||||
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
||||||
public interface INudge { void OnNudge(Actor self, Actor nudger); }
|
public interface INudge { void OnNudge(Actor self, Actor nudger); }
|
||||||
|
|
||||||
|
public interface IRadarSignature
|
||||||
|
{
|
||||||
|
IEnumerable<int2> RadarSignatureCells(Actor self);
|
||||||
|
Color RadarSignatureColor(Actor self);
|
||||||
|
}
|
||||||
|
|
||||||
public interface IOccupySpace
|
public interface IOccupySpace
|
||||||
{
|
{
|
||||||
int2 TopLeft { get; }
|
int2 TopLeft { get; }
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public class UnitInfo : OwnedActorInfo, ITraitInfo
|
public class UnitInfo : OwnedActorInfo, ITraitInfo
|
||||||
@@ -19,7 +22,7 @@ namespace OpenRA.Traits
|
|||||||
public object Create( ActorInitializer init ) { return new Unit(); }
|
public object Create( ActorInitializer init ) { return new Unit(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Unit : INotifyDamage
|
public class Unit : INotifyDamage, IRadarSignature
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync]
|
||||||
public int Facing;
|
public int Facing;
|
||||||
@@ -32,5 +35,15 @@ namespace OpenRA.Traits
|
|||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Sound.PlayVoice("Lost", self);
|
Sound.PlayVoice("Lost", self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<int2> RadarSignatureCells(Actor self)
|
||||||
|
{
|
||||||
|
yield return self.Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color RadarSignatureColor(Actor self)
|
||||||
|
{
|
||||||
|
return self.Owner.Color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user