fixed unit production bug; unit is not emitted until space is clear.
This commit is contained in:
@@ -20,12 +20,14 @@ namespace OpenRa.Game
|
||||
readonly Sprite moneyBinSprite;
|
||||
readonly SpriteRenderer buildPaletteRenderer;
|
||||
readonly Animation cantBuild;
|
||||
readonly Animation ready;
|
||||
|
||||
readonly List<Pair<Rectangle, Action<bool>>> buildItems = new List<Pair<Rectangle, Action<bool>>>();
|
||||
readonly Cache<string, Animation> clockAnimations;
|
||||
readonly List<Sprite> digitSprites;
|
||||
readonly Dictionary<string, Sprite[]> tabSprites;
|
||||
readonly Sprite[] shimSprites;
|
||||
readonly Sprite blank;
|
||||
|
||||
public Chrome(Renderer r)
|
||||
{
|
||||
@@ -37,6 +39,8 @@ namespace OpenRa.Game
|
||||
specialBinSprite = new Sprite(specialBin, new Rectangle(0, 0, 32, 192), TextureChannel.Alpha);
|
||||
moneyBinSprite = new Sprite(specialBin, new Rectangle(512-320, 0, 320, 64), TextureChannel.Alpha);
|
||||
|
||||
blank = SheetBuilder.Add(new Size(64,48), 16);
|
||||
|
||||
sprites = groups
|
||||
.SelectMany(g => Rules.Categories[g])
|
||||
.Where(u => Rules.UnitInfo[u].TechLevel != -1)
|
||||
@@ -71,6 +75,9 @@ namespace OpenRa.Game
|
||||
new Sprite( specialBin, new Rectangle( 0, 202, 192 +9, 10 ), TextureChannel.Alpha ),
|
||||
new Sprite( specialBin, new Rectangle( 0, 216, 9, 48 ), TextureChannel.Alpha ),
|
||||
};
|
||||
|
||||
ready = new Animation("pips");
|
||||
ready.PlayRepeating("ready");
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
@@ -107,7 +114,8 @@ namespace OpenRa.Game
|
||||
{
|
||||
var groupName = q.Key;
|
||||
if (!Rules.TechTree.BuildableItems(Game.LocalPlayer, q.Key).Any()) continue;
|
||||
var index = q.Key == currentTab ? 2 : 0;
|
||||
var producing = Game.LocalPlayer.Producing(groupName);
|
||||
var index = q.Key == currentTab ? 2 : (producing != null && producing.Done) ? 1 : 0;
|
||||
chromeRenderer.DrawSprite(q.Value[index], new float2(x, y), 0);
|
||||
|
||||
buildItems.Add(Pair.New(new Rectangle(x, y, 27, 40), (Action<bool>)(isLmb => currentTab = groupName)));
|
||||
@@ -163,6 +171,14 @@ namespace OpenRa.Game
|
||||
clockAnimations[queueName].Tick();
|
||||
buildPaletteRenderer.DrawSprite(clockAnimations[queueName].Image,
|
||||
Game.viewport.Location + new float2(rect.Location), 0);
|
||||
|
||||
if (currentItem.Done)
|
||||
{
|
||||
ready.Play("ready");
|
||||
buildPaletteRenderer.DrawSprite(ready.Image, Game.viewport.Location
|
||||
+ new float2(rect.Location)
|
||||
+ new float2((64 - ready.Image.size.X) / 2, 2), 0);
|
||||
}
|
||||
}
|
||||
|
||||
var closureItem = item;
|
||||
@@ -171,12 +187,21 @@ namespace OpenRa.Game
|
||||
if (++x == 3) { x = 0; y++; }
|
||||
}
|
||||
|
||||
while( x != 0)
|
||||
{
|
||||
var rect = new Rectangle(Game.viewport.Width - (3 - x) * 64, 40 + 48 * y, 64, 48);
|
||||
buildPaletteRenderer.DrawSprite(blank, Game.viewport.Location + new float2(rect.Location), 0);
|
||||
buildItems.Add(Pair.New(rect,
|
||||
(Action<bool>)(_ => { })));
|
||||
if (++x == 3) { x = 0; y++; }
|
||||
}
|
||||
|
||||
buildPaletteRenderer.Flush();
|
||||
|
||||
for (var j = 0; j <= y; j++)
|
||||
for (var j = 0; j < y; j++)
|
||||
chromeRenderer.DrawSprite(shimSprites[2], new float2(Game.viewport.Width - 192 - 9, 40 + 48 * j), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[0], new float2(Game.viewport.Width - 192 - 9, 40 - 9), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[1], new float2(Game.viewport.Width - 192 - 9, 40 - 1 + 48 + 48 * y), 0);
|
||||
chromeRenderer.DrawSprite(shimSprites[1], new float2(Game.viewport.Width - 192 - 9, 40 - 1 + 48 * y), 0);
|
||||
chromeRenderer.Flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -337,6 +337,10 @@ namespace OpenRa.Game
|
||||
}
|
||||
else
|
||||
{
|
||||
var productionPoint = (1 / 24f * producer.CenterLocation).ToInt2();
|
||||
if (UnitInfluence.GetUnitAt(productionPoint) != null)
|
||||
return;
|
||||
|
||||
unit = new Actor(name, (1 / 24f * producer.CenterLocation).ToInt2(), player);
|
||||
var mobile = unit.traits.Get<Mobile>();
|
||||
mobile.facing = 128;
|
||||
|
||||
@@ -120,7 +120,13 @@ namespace OpenRa.Game
|
||||
|
||||
public void Tick( Player player )
|
||||
{
|
||||
if( Paused || Done ) return;
|
||||
if (Done)
|
||||
{
|
||||
if (OnComplete != null) OnComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
if( Paused ) return;
|
||||
|
||||
var costThisFrame = RemainingCost / RemainingTime;
|
||||
if( costThisFrame != 0 && !player.TakeCash( costThisFrame ) ) return;
|
||||
@@ -129,10 +135,7 @@ namespace OpenRa.Game
|
||||
RemainingTime -= 1;
|
||||
if( RemainingTime > 0 ) return;
|
||||
|
||||
// item finished; do whatever needs done.
|
||||
Done = true;
|
||||
if (OnComplete != null)
|
||||
OnComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace OpenRa.Game
|
||||
if (order.Player == Game.LocalPlayer)
|
||||
Game.PlaySound(group == "Building"
|
||||
? "conscmp1.aud" : "unitrdy1.aud", false);
|
||||
if (group != "Building")
|
||||
if (group != "Building" && group != "Defense")
|
||||
Game.BuildUnit(order.Player, order.TargetString);
|
||||
})));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user