proper dirty handling in new Shroud trait
This commit is contained in:
@@ -46,6 +46,8 @@ namespace OpenRA
|
||||
|
||||
sprites = new Sprite[map.MapSize, map.MapSize];
|
||||
fogSprites = new Sprite[map.MapSize, map.MapSize];
|
||||
|
||||
shroud.Dirty += () => dirty = true;
|
||||
}
|
||||
|
||||
public bool HasGPS
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.GameRules;
|
||||
using System.Drawing;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -38,6 +39,7 @@ namespace OpenRA.Traits
|
||||
public int[,] visibleCells;
|
||||
public bool[,] exploredCells;
|
||||
public Rectangle? exploredBounds;
|
||||
public event Action Dirty = () => { };
|
||||
|
||||
public Shroud(Actor self, ShroudInfo info)
|
||||
{
|
||||
@@ -78,6 +80,8 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
vis[a] = v;
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
static IEnumerable<int2> GetVisOrigins(Actor a)
|
||||
@@ -107,6 +111,8 @@ namespace OpenRA.Traits
|
||||
--visibleCells[q.X, q.Y];
|
||||
|
||||
vis.Remove(a);
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void UpdateActor(Actor a)
|
||||
@@ -123,6 +129,8 @@ namespace OpenRA.Traits
|
||||
var box = new Rectangle(center.X - range, center.Y - range, 2 * range + 1, 2 * range + 1);
|
||||
exploredBounds = exploredBounds.HasValue ?
|
||||
Rectangle.Union(exploredBounds.Value, box) : box;
|
||||
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public void ResetExploration() // for `hide map` crate
|
||||
@@ -130,6 +138,8 @@ namespace OpenRA.Traits
|
||||
for (var j = 0; j <= exploredCells.GetUpperBound(1); j++)
|
||||
for (var i = 0; i <= exploredCells.GetUpperBound(0); i++)
|
||||
exploredCells[i, j] = visibleCells[i, j] > 0;
|
||||
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
class SpyPlanePowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly int Range = 10;
|
||||
public readonly float RevealTime = .1f; // minutes
|
||||
public override object Create(Actor self) { return new SpyPlanePower(self,this); }
|
||||
}
|
||||
|
||||
@@ -58,9 +58,13 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
plane.CancelActivity();
|
||||
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
|
||||
plane.QueueActivity(new CallFunc(
|
||||
() => Owner.Shroud.Explore(Owner.World, order.TargetLocation,
|
||||
(Info as SpyPlanePowerInfo).Range)));
|
||||
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
||||
{
|
||||
|
||||
var camera = w.CreateActor("camera", order.TargetLocation, Owner);
|
||||
camera.QueueActivity(new Wait((int)(25 * 60 * (Info as SpyPlanePowerInfo).RevealTime)));
|
||||
camera.QueueActivity(new RemoveSelf());
|
||||
})));
|
||||
plane.QueueActivity(new FlyOffMap { Interruptible = false });
|
||||
plane.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
|
||||
@@ -2651,3 +2651,8 @@ WOOD:
|
||||
Building:
|
||||
HP: 100
|
||||
Armor: none
|
||||
|
||||
CAMERA:
|
||||
Unit:
|
||||
HP:1000
|
||||
Sight: 10
|
||||
Reference in New Issue
Block a user