D2k Starport

- OG fly path and Frigate behaviour
- BulkProductionQueue
- ProductionStarport trait
- OG palette widget behavior for Bulk queue
- Purchase button for each BulkProduction
- Delivery timer for each BulkProduction
This commit is contained in:
N.N
2024-05-02 13:07:34 +02:00
committed by Gustas Kažukauskas
parent fcae6a26d1
commit 18870cbb03
17 changed files with 825 additions and 54 deletions

View File

@@ -50,6 +50,8 @@ namespace OpenRA.Mods.Common.Widgets
public readonly int2 IconSpriteOffset = int2.Zero;
public readonly float2 QueuedOffset = new(4, 2);
public readonly float2 BulkOffset = new(4, 2);
public readonly TextAlign QueuedTextAlign = TextAlign.Left;
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
@@ -363,6 +365,24 @@ namespace OpenRA.Mods.Common.Widgets
bool HandleRightClick(ProductionItem item, ProductionIcon icon, int handleCount)
{
if (CurrentQueue is BulkProductionQueue bulkProductionQueue && !bulkProductionQueue.HasDeliveryStarted())
{
var readyActors = bulkProductionQueue.GetActorsReadyForDelivery();
if (readyActors.Any(a => a.Actor.Name == icon.Name))
{
World.IssueOrder(
new Order("ReturnOrder", CurrentQueue.Actor, false)
{
ExtraData = (uint)handleCount,
TargetString = icon.Name
});
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
return true;
}
else
return false;
}
if (item == null)
return false;
@@ -390,17 +410,18 @@ namespace OpenRA.Mods.Common.Widgets
bool HandleMiddleClick(ProductionItem item, ProductionIcon icon, int handleCount)
{
if (item == null)
return false;
if (item != null)
{
// Directly cancel, skipping "on-hold"
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
TextNotificationsManager.AddTransientLine(World.LocalPlayer, CurrentQueue.Info.CancelledTextNotification);
// Directly cancel, skipping "on-hold"
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
TextNotificationsManager.AddTransientLine(World.LocalPlayer, CurrentQueue.Info.CancelledTextNotification);
World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));
return true;
}
World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));
return true;
return false;
}
bool HandleEvent(ProductionIcon icon, MouseButton btn, Modifiers modifiers)
@@ -568,10 +589,13 @@ namespace OpenRA.Mods.Common.Widgets
var waiting = !CurrentQueue.IsProducing(first) && !first.Done;
if (first.Done)
{
if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber * worldRenderer.World.Timestep / 360 % 2 == 0)
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, TextColor, Color.Black, 1);
else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
if (CurrentQueue is not BulkProductionQueue)
{
if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber * worldRenderer.World.Timestep / 360 % 2 == 0)
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, TextColor, Color.Black, 1);
else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
}
}
else if (first.Paused)
overlayFont.DrawTextWithContrast(HoldText,
@@ -603,6 +627,14 @@ namespace OpenRA.Mods.Common.Widgets
TextColor, Color.Black, 1);
}
}
if (CurrentQueue is BulkProductionQueue bulkProductionQueue)
{
var readyActors = bulkProductionQueue.GetActorsReadyForDelivery().
Count(a => a.Actor.Name == icon.Name);
overlayFont.DrawTextWithContrast(readyActors.ToString(NumberFormatInfo.CurrentInfo),
icon.Pos + BulkOffset, TextColor, Color.Black, 1);
}
}
}