Cleanup
This commit is contained in:
@@ -343,34 +343,32 @@
|
|||||||
{
|
{
|
||||||
var hotkey = KeyService.GetHotkey();
|
var hotkey = KeyService.GetHotkey();
|
||||||
|
|
||||||
if (hotkey == "")
|
if(hotkey is "`")
|
||||||
{
|
HandleCancelEntity();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hotkey == "`")
|
if (EntityFromKey(hotkey, out var entity))
|
||||||
{
|
return;
|
||||||
BuildOrderService.RemoveLast();
|
|
||||||
|
if (BuildOrderService.Add(entity!, EconomyService))
|
||||||
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
private void HandleCancelEntity()
|
||||||
|
{
|
||||||
|
BuildOrderService.RemoveLast();
|
||||||
|
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EntityFromKey(string? hotkey, out EntityModel? entity)
|
||||||
|
{
|
||||||
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
||||||
var isHoldSpace = KeyService.IsHoldingSpace();
|
var isHoldSpace = KeyService.IsHoldingSpace();
|
||||||
var faction = FilterService.GetFaction();
|
var faction = FilterService.GetFaction();
|
||||||
var immortal = FilterService.GetImmortal();
|
var immortal = FilterService.GetImmortal();
|
||||||
|
|
||||||
var entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
entity = EntityModel.GetFrom(hotkey!, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||||
|
|
||||||
if (entity == null)
|
return entity == null;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BuildOrderService.Add(entity, EconomyService))
|
|
||||||
{
|
|
||||||
EconomyService.Calculate(BuildOrderService, TimingService, BuildOrderService.GetLastRequestInterval());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonClicked(MouseEventArgs mouseEventArgs, HotkeyModel hotkey)
|
private void ButtonClicked(MouseEventArgs mouseEventArgs, HotkeyModel hotkey)
|
||||||
|
|||||||
Reference in New Issue
Block a user