much better building support; phantom selection is dead AGAIN.
This commit is contained in:
@@ -8,5 +8,6 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
IEnumerable<Order> Order( int2 xy, bool lmb );
|
IEnumerable<Order> Order( int2 xy, bool lmb );
|
||||||
void PrepareOverlay( int2 xy );
|
void PrepareOverlay( int2 xy );
|
||||||
|
void Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Game.Tick();
|
Game.Tick();
|
||||||
Game.viewport.cursor = Game.controller.ChooseCursor();
|
Game.viewport.cursor = Game.controller.ChooseCursor();
|
||||||
|
if (Game.controller.orderGenerator != null)
|
||||||
|
Game.controller.orderGenerator.Tick();
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,5 +49,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Game.worldRenderer.uiOverlay.SetCurrentOverlay(xy, Name);
|
Game.worldRenderer.uiOverlay.SetCurrentOverlay(xy, Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Tick() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,12 +86,14 @@ namespace OpenRa.Game
|
|||||||
public int RemainingCost { get; private set; }
|
public int RemainingCost { get; private set; }
|
||||||
|
|
||||||
public bool Paused = false, Done = false;
|
public bool Paused = false, Done = false;
|
||||||
|
public Action OnComplete;
|
||||||
|
|
||||||
public ProductionItem( string item, int time, int cost )
|
public ProductionItem( string item, int time, int cost, Action onComplete )
|
||||||
{
|
{
|
||||||
Item = item;
|
Item = item;
|
||||||
RemainingTime = TotalTime = time;
|
RemainingTime = TotalTime = time;
|
||||||
RemainingCost = TotalCost = cost;
|
RemainingCost = TotalCost = cost;
|
||||||
|
OnComplete = onComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Player player )
|
public void Tick( Player player )
|
||||||
@@ -107,6 +109,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
// item finished; do whatever needs done.
|
// item finished; do whatever needs done.
|
||||||
Done = true;
|
Done = true;
|
||||||
|
if (OnComplete != null)
|
||||||
|
OnComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
SpriteRenderer spriteRenderer, clockRenderer;
|
SpriteRenderer spriteRenderer, clockRenderer;
|
||||||
Sprite blank;
|
Sprite blank;
|
||||||
|
Animation ready;
|
||||||
|
Animation cantBuild;
|
||||||
readonly GRegion region;
|
readonly GRegion region;
|
||||||
|
|
||||||
public GRegion Region { get { return region; } }
|
public GRegion Region { get { return region; } }
|
||||||
@@ -49,6 +51,11 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
blank = SheetBuilder.Add(new Size((int)spriteWidth, (int)spriteHeight), 16);
|
blank = SheetBuilder.Add(new Size((int)spriteWidth, (int)spriteHeight), 16);
|
||||||
|
ready = new Animation("pips");
|
||||||
|
ready.PlayRepeating("ready");
|
||||||
|
|
||||||
|
cantBuild = new Animation("clock");
|
||||||
|
cantBuild.PlayFetchIndex("idle", () => 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int NumClockFrames = 54;
|
const int NumClockFrames = 54;
|
||||||
@@ -125,7 +132,12 @@ namespace OpenRa.Game
|
|||||||
void Paint()
|
void Paint()
|
||||||
{
|
{
|
||||||
PopulateItemList();
|
PopulateItemList();
|
||||||
foreach( SidebarItem i in items )
|
|
||||||
|
foreach( var i in items ) /* draw the buttons */
|
||||||
|
i.Paint(spriteRenderer, region.Location);
|
||||||
|
spriteRenderer.Flush();
|
||||||
|
|
||||||
|
foreach( var i in items ) /* draw the status overlays */
|
||||||
{
|
{
|
||||||
var group = Rules.UnitCategory[ i.Tag ];
|
var group = Rules.UnitCategory[ i.Tag ];
|
||||||
var producing = player.Producing( group );
|
var producing = player.Producing( group );
|
||||||
@@ -133,8 +145,12 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
clockAnimations[ group ].Tick();
|
clockAnimations[ group ].Tick();
|
||||||
clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 );
|
clockRenderer.DrawSprite( clockAnimations[ group ].Image, region.Location.ToFloat2() + i.location, 0 );
|
||||||
|
|
||||||
|
if (producing.Done)
|
||||||
|
clockRenderer.DrawSprite(ready.Image, region.Location.ToFloat2() + i.location + new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||||
}
|
}
|
||||||
i.Paint( spriteRenderer, region.Location );
|
else if (producing != null)
|
||||||
|
clockRenderer.DrawSprite(cantBuild.Image, region.Location.ToFloat2() + i.location, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X, buildPos + region.Location.Y));
|
Fill(region.Size.Y + region.Location.Y, new float2(region.Location.X, buildPos + region.Location.Y));
|
||||||
@@ -153,6 +169,11 @@ namespace OpenRa.Game
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsAutoCompleting(string group)
|
||||||
|
{
|
||||||
|
return group != "Building";
|
||||||
|
}
|
||||||
|
|
||||||
void MouseHandler(MouseInput mi)
|
void MouseHandler(MouseInput mi)
|
||||||
{
|
{
|
||||||
var point = mi.Location.ToFloat2();
|
var point = mi.Location.ToFloat2();
|
||||||
@@ -172,17 +193,21 @@ namespace OpenRa.Game
|
|||||||
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||||
/ 1000;
|
/ 1000;
|
||||||
|
|
||||||
|
Action complete = null;
|
||||||
|
if (IsAutoCompleting(group)) complete = () => Build(item);
|
||||||
|
|
||||||
player.BeginProduction(group,
|
player.BeginProduction(group,
|
||||||
new ProductionItem(item.Tag, (int)time, ui.Cost));
|
new ProductionItem(item.Tag, (int)time, ui.Cost, complete));
|
||||||
//Build(item);
|
|
||||||
}
|
}
|
||||||
else if (producing.Item == item.Tag)
|
else if (producing.Item == item.Tag && producing.Done)
|
||||||
{
|
{
|
||||||
Build(item);
|
Build(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
|
else if (mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down)
|
||||||
|
{
|
||||||
player.CancelProduction(Rules.UnitCategory[item.Tag]);
|
player.CancelProduction(Rules.UnitCategory[item.Tag]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
selection.RemoveAll(a => a.IsDead);
|
||||||
|
}
|
||||||
|
|
||||||
public void PrepareOverlay(int2 xy) {}
|
public void PrepareOverlay(int2 xy) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- openra/sequences.xml
|
<!-- openra/sequences.xml
|
||||||
|
|
||||||
this file describes animation sequences for structures and units.
|
this file describes animation sequences for structures and units.
|
||||||
@@ -468,4 +468,12 @@
|
|||||||
<unit name="lst">
|
<unit name="lst">
|
||||||
<sequence name="idle" start="0" length="1" />
|
<sequence name="idle" start="0" length="1" />
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit name="pips">
|
||||||
|
<sequence name="groups" start="8" length="10" />
|
||||||
|
<sequence name="ore" start="0" length="2" />
|
||||||
|
<sequence name="cargo" start="5" length="3" />
|
||||||
|
<sequence name="medic" start="20" length="1" />
|
||||||
|
<sequence name="ready" start="3" length="1" />
|
||||||
|
<sequence name="hold" start="4" length="1" />
|
||||||
|
</unit>
|
||||||
</sequences>
|
</sequences>
|
||||||
Reference in New Issue
Block a user