Use IRender.ScreenBounds in ScreenMap.
Traits are now required to trigger a ScreenMap update whenever they believe that their ScreenBounds have changed.
This commit is contained in:
@@ -31,7 +31,6 @@ namespace OpenRA.Traits
|
||||
{
|
||||
public readonly PPos[] Footprint;
|
||||
public readonly WPos CenterPosition;
|
||||
public readonly Rectangle RenderBounds;
|
||||
public readonly Rectangle SelectableBounds;
|
||||
public readonly HashSet<string> TargetTypes;
|
||||
readonly Actor actor;
|
||||
@@ -51,7 +50,10 @@ namespace OpenRA.Traits
|
||||
public bool Shrouded { get; private set; }
|
||||
public bool NeedRenderables { get; set; }
|
||||
public IRenderable[] Renderables = NoRenderables;
|
||||
public Rectangle[] ScreenBounds = NoBounds;
|
||||
|
||||
static readonly IRenderable[] NoRenderables = new IRenderable[0];
|
||||
static readonly Rectangle[] NoBounds = new Rectangle[0];
|
||||
|
||||
int flashTicks;
|
||||
|
||||
@@ -78,7 +80,6 @@ namespace OpenRA.Traits
|
||||
footprint.Select(p => shroud.Contains(p).ToString()).JoinWith("|")));
|
||||
|
||||
CenterPosition = self.CenterPosition;
|
||||
RenderBounds = self.RenderBounds;
|
||||
SelectableBounds = self.SelectableBounds;
|
||||
TargetTypes = self.GetEnabledTargetTypes().ToHashSet();
|
||||
|
||||
|
||||
@@ -61,22 +61,6 @@ namespace OpenRA.Traits
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr) { worldRenderer = wr; }
|
||||
|
||||
Rectangle FrozenActorBounds(FrozenActor fa)
|
||||
{
|
||||
var pos = worldRenderer.ScreenPxPosition(fa.CenterPosition);
|
||||
var bounds = fa.RenderBounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
Rectangle ActorBounds(Actor a)
|
||||
{
|
||||
var pos = worldRenderer.ScreenPxPosition(a.CenterPosition);
|
||||
var bounds = a.RenderBounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public void AddOrUpdate(Player viewer, FrozenActor fa)
|
||||
{
|
||||
if (removeFrozenActors[viewer].Contains(fa))
|
||||
@@ -200,11 +184,23 @@ namespace OpenRA.Traits
|
||||
return partitionedFrozenActors[p].InBox(r).Where(frozenActorIsValid);
|
||||
}
|
||||
|
||||
Rectangle AggregateBounds(IEnumerable<Rectangle> screenBounds)
|
||||
{
|
||||
if (!screenBounds.Any())
|
||||
return Rectangle.Empty;
|
||||
|
||||
var bounds = screenBounds.First();
|
||||
foreach (var b in screenBounds.Skip(1))
|
||||
bounds = Rectangle.Union(bounds, b);
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
foreach (var a in addOrUpdateActors)
|
||||
{
|
||||
var bounds = ActorBounds(a);
|
||||
var bounds = AggregateBounds(a.ScreenBounds(worldRenderer));
|
||||
if (!bounds.Size.IsEmpty)
|
||||
{
|
||||
if (partitionedActors.Contains(a))
|
||||
@@ -226,7 +222,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
foreach (var fa in kv.Value)
|
||||
{
|
||||
var bounds = FrozenActorBounds(fa);
|
||||
var bounds = AggregateBounds(fa.ScreenBounds);
|
||||
if (!bounds.Size.IsEmpty)
|
||||
{
|
||||
if (partitionedFrozenActors[kv.Key].Contains(fa))
|
||||
|
||||
Reference in New Issue
Block a user