Initial commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
@implements IDisposable
|
||||
|
||||
<FormLayoutComponent>
|
||||
<FormDisplayComponent Label="Army ready at">
|
||||
<Display>@LastInterval | T @Interval.ToTime(LastInterval)</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Army units built">
|
||||
<Display>
|
||||
<div style="display: flex; width: 100%; gap: 12px; flex-wrap: wrap;">
|
||||
@foreach (var unit in armyCount) {
|
||||
<div style="width:90px; height: 60px; border: 1px solid gray; padding: 8px;">
|
||||
<div>@unit.Value.ToString()x</div>
|
||||
<div>@unit.Key</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</Display>
|
||||
</FormDisplayComponent>
|
||||
|
||||
</FormLayoutComponent>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
public IBuildOrderService BuildOrder { get; set; }
|
||||
|
||||
int LastInterval;
|
||||
|
||||
readonly Dictionary<string, int> armyCount = new();
|
||||
|
||||
List<EntityModel> army = new();
|
||||
|
||||
protected override void OnInitialized() {
|
||||
BuildOrder.Subscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
BuildOrder.Unsubscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
void OnBuildOrderChanged() {
|
||||
armyCount.Clear();
|
||||
|
||||
LastInterval = 0;
|
||||
|
||||
var entitiesOverTime = BuildOrder.GetOrders();
|
||||
|
||||
foreach (var entitiesAtTime in entitiesOverTime) {
|
||||
foreach (var entity in entitiesAtTime.Value) {
|
||||
if (entity.EntityType == EntityType.Army) {
|
||||
if (!armyCount.TryAdd(entity.Info().Name, 1)) {
|
||||
armyCount[entity.Info().Name]++;
|
||||
}
|
||||
|
||||
if (entity.Production() != null && entity.Production().BuildTime + entitiesAtTime.Key > LastInterval) {
|
||||
LastInterval = entity.Production().BuildTime + entitiesAtTime.Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
@implements IDisposable
|
||||
|
||||
<FormLayoutComponent>
|
||||
<FormDisplayComponent Label="Time">
|
||||
<Display>@BuildOrderService.GetLastRequestInterval() | T @Interval.ToTime(BuildOrderService.GetLastRequestInterval())</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Alloy">
|
||||
<Display>@economy.Alloy</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Ether">
|
||||
<Display>@economy.Ether</Display>
|
||||
</FormDisplayComponent>
|
||||
<DevOnlyComponent>
|
||||
<FormDisplayComponent Label="Pyre">
|
||||
<Display>@economy.Pyre</Display>
|
||||
</FormDisplayComponent>
|
||||
</DevOnlyComponent>
|
||||
<FormDisplayComponent Label="Supply">
|
||||
<Display>@supplyTaken / @supplyGranted (@(supplyGranted / 16)@(extraBuildings > 0 ? "+" + extraBuildings : ""))</Display>
|
||||
</FormDisplayComponent>
|
||||
</FormLayoutComponent>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IEconomyService EconomyService { get; set; }
|
||||
|
||||
EconomyModel economy = new();
|
||||
int supplyGranted;
|
||||
int supplyTaken;
|
||||
int extraBuildings;
|
||||
|
||||
protected override void OnInitialized() {
|
||||
BuildOrderService.Subscribe(OnBuildOrderChanged);
|
||||
EconomyService.Subscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
BuildOrderService.Unsubscribe(OnBuildOrderChanged);
|
||||
EconomyService.Subscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
void OnBuildOrderChanged() {
|
||||
economy = EconomyService.GetEconomy(BuildOrderService.GetLastRequestInterval());
|
||||
|
||||
var ordersOverTime = BuildOrderService.GetOrders();
|
||||
|
||||
supplyTaken = (from ordersAtInterval in ordersOverTime
|
||||
from order in ordersAtInterval.Value
|
||||
where order.Supply() != null
|
||||
where order.Supply().Takes > 0
|
||||
select order.Supply().Takes).Sum();
|
||||
|
||||
supplyGranted = (from ordersAtInterval in ordersOverTime
|
||||
from order in ordersAtInterval.Value
|
||||
where order.Supply() != null
|
||||
where order.Supply().Grants > 0
|
||||
select order.Supply().Grants).Sum();
|
||||
|
||||
extraBuildings = 0;
|
||||
if (supplyGranted > 160) {
|
||||
extraBuildings = (supplyGranted - 160) / 16;
|
||||
supplyGranted = 160;
|
||||
}
|
||||
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
@implements IDisposable
|
||||
|
||||
<FormLayoutComponent>
|
||||
<FormTextAreaComponent Label="JSON Data"
|
||||
Rows="14"
|
||||
Value="@BuildOrderService.AsJson()">
|
||||
</FormTextAreaComponent>
|
||||
</FormLayoutComponent>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
protected override void OnInitialized() {
|
||||
BuildOrderService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
BuildOrderService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
@implements IDisposable
|
||||
|
||||
<div class="chartsContainer">
|
||||
@foreach (var chart in charts) {
|
||||
<div style="width: @chart.IntervalDisplayMax.ToString()px; height: @chart.ValueDisplayMax.ToString()px">
|
||||
<div style="position: relative; border: 2px solid gray; border-radius:2px; width: @chart.IntervalDisplayMax.ToString()px; height: @chart.ValueDisplayMax.ToString()px">
|
||||
@foreach (var point in chart.Points) {
|
||||
<div style="position: absolute;
|
||||
bottom:@point.GetValue(chart.HighestValuePoint, chart.ValueDisplayMax)px;
|
||||
left:@point.GetInterval(chart.HighestIntervalPoint, chart.IntervalDisplayMax)px;
|
||||
width: 0px;
|
||||
height: 0px;">
|
||||
<div style="width:1px; height: 1px; border-top-right-radius:10px; border-top-left-radius:10px; border: 2px solid @chart.ChartColor; background-color:@chart.ChartColor">
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.chartsContainer {
|
||||
position: relative;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<FormLayoutComponent>
|
||||
<FormDisplayComponent Label="Highest Alloy">
|
||||
<Display>@highestAlloyPoint</Display>
|
||||
</FormDisplayComponent>
|
||||
<FormDisplayComponent Label="Highest Ether">
|
||||
<Display>@highestEtherPoint</Display>
|
||||
</FormDisplayComponent>
|
||||
<DevOnlyComponent>
|
||||
<FormDisplayComponent Label="Highest Pyre">
|
||||
<Display>@highestEtherPoint</Display>
|
||||
</FormDisplayComponent>
|
||||
</DevOnlyComponent>
|
||||
<FormDisplayComponent Label="Highest Army">
|
||||
<Display>@highestArmyPoint</Display>
|
||||
</FormDisplayComponent>
|
||||
</FormLayoutComponent>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
IEconomyService EconomyService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
|
||||
int height = 100;
|
||||
readonly int width = 250;
|
||||
|
||||
List<int> valueList = new();
|
||||
|
||||
readonly List<ChartModel> charts = new();
|
||||
|
||||
|
||||
float highestAlloyPoint;
|
||||
float highestEtherPoint;
|
||||
float highestPyrePoint;
|
||||
float highestArmyPoint;
|
||||
|
||||
protected override void OnInitialized() {
|
||||
EconomyService.Subscribe(GenerateChart);
|
||||
BuildOrderService.Subscribe(GenerateChart);
|
||||
|
||||
GenerateChart();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
EconomyService.Unsubscribe(GenerateChart);
|
||||
BuildOrderService.Unsubscribe(GenerateChart);
|
||||
}
|
||||
|
||||
void GenerateChart() {
|
||||
var economyOverTime = EconomyService.GetOverTime();
|
||||
|
||||
charts.Clear();
|
||||
|
||||
var alloyChart = new ChartModel {
|
||||
IntervalDisplayMax = width,
|
||||
ValueDisplayMax = 100,
|
||||
ChartColor = "Cyan"
|
||||
};
|
||||
var etherChart = new ChartModel {
|
||||
Offset = width,
|
||||
IntervalDisplayMax = width,
|
||||
ValueDisplayMax = 100,
|
||||
ChartColor = "LightGreen"
|
||||
};
|
||||
|
||||
var pyreChart = new ChartModel {
|
||||
Offset = width * 2,
|
||||
IntervalDisplayMax = width,
|
||||
ValueDisplayMax = 100,
|
||||
ChartColor = "Red"
|
||||
};
|
||||
|
||||
var armyChart = new ChartModel {
|
||||
Offset = width * 3,
|
||||
IntervalDisplayMax = width,
|
||||
ValueDisplayMax = 100,
|
||||
ChartColor = "White"
|
||||
};
|
||||
|
||||
highestAlloyPoint = 0;
|
||||
highestEtherPoint = 0;
|
||||
highestPyrePoint = 0;
|
||||
highestArmyPoint = 0;
|
||||
|
||||
for (var interval = 0; interval < economyOverTime.Count(); interval++) {
|
||||
var army = from unit in BuildOrderService.GetCompletedBefore(interval)
|
||||
where unit.EntityType == EntityType.Army
|
||||
select unit;
|
||||
|
||||
var armyValue = 0;
|
||||
foreach (var unit in army) {
|
||||
armyValue += unit.Production().Alloy + unit.Production().Ether;
|
||||
}
|
||||
|
||||
|
||||
highestArmyPoint = Math.Max(highestArmyPoint, armyValue);
|
||||
|
||||
armyChart.Points.Add(new PointModel { Interval = interval, Value = armyValue });
|
||||
}
|
||||
|
||||
|
||||
for (var interval = 0; interval < economyOverTime.Count(); interval++) {
|
||||
var alloyPoint = new PointModel { Interval = interval };
|
||||
var etherPoint = new PointModel { Interval = interval };
|
||||
var pyrePoint = new PointModel { Interval = interval };
|
||||
|
||||
var economyAtSecond = economyOverTime[interval];
|
||||
|
||||
var alloyWorkerHarvesters = from harvester in economyAtSecond.Harvesters
|
||||
where harvester.Harvest() != null
|
||||
where harvester.Harvest().RequiresWorker
|
||||
where harvester.Harvest().Resource == ResourceType.Alloy
|
||||
select harvester;
|
||||
|
||||
var alloyAutomaticHarvesters = from harvester in economyAtSecond.Harvesters
|
||||
where harvester.Harvest() != null
|
||||
where harvester.Harvest().RequiresWorker == false
|
||||
where harvester.Harvest().Resource == ResourceType.Alloy
|
||||
select harvester;
|
||||
|
||||
var etherAutomaticHarvesters = from harvester in economyAtSecond.Harvesters
|
||||
where harvester.Harvest() != null
|
||||
where harvester.Harvest().RequiresWorker == false
|
||||
where harvester.Harvest().Resource == ResourceType.Ether
|
||||
select harvester;
|
||||
|
||||
float autoAlloy = 0;
|
||||
float workerSlots = 0;
|
||||
float workerAlloy = 0;
|
||||
float autoEther = 0;
|
||||
|
||||
float economySpending = 0;
|
||||
|
||||
foreach (var alloyAutoHarvester in alloyAutomaticHarvesters) {
|
||||
autoAlloy += alloyAutoHarvester.Harvest().Slots * alloyAutoHarvester.Harvest().HarvestedPerInterval;
|
||||
var production = alloyAutoHarvester.Production();
|
||||
if (production != null) {
|
||||
economySpending += production.Alloy;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var alloyWorkerHarvester in alloyWorkerHarvesters) {
|
||||
workerSlots += alloyWorkerHarvester.Harvest().Slots;
|
||||
var production = alloyWorkerHarvester.Production();
|
||||
if (production != null) {
|
||||
economySpending += production.Alloy;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var etherWorkerHarvester in etherAutomaticHarvesters) {
|
||||
autoEther += etherWorkerHarvester.Harvest().Slots * etherWorkerHarvester.Harvest().HarvestedPerInterval;
|
||||
var production = etherWorkerHarvester.Production();
|
||||
if (production != null) {
|
||||
economySpending += production.Alloy;
|
||||
}
|
||||
}
|
||||
|
||||
economySpending += (economyAtSecond.WorkerCount - 6) * 50;
|
||||
|
||||
workerAlloy = Math.Min(economyAtSecond.WorkerCount - economyAtSecond.BusyWorkerCount, workerSlots);
|
||||
|
||||
|
||||
alloyPoint.TempValue = workerAlloy + autoAlloy;
|
||||
etherPoint.Value = autoEther;
|
||||
|
||||
|
||||
if (interval > 0) {
|
||||
alloyPoint.TempValue += alloyChart.Points.Last().TempValue;
|
||||
etherPoint.Value += etherChart.Points.Last().Value;
|
||||
pyrePoint.Value = pyreChart.Points.Last().Value + 1;
|
||||
}
|
||||
|
||||
alloyPoint.Value = alloyPoint.TempValue - economySpending;
|
||||
|
||||
highestAlloyPoint = Math.Max(highestAlloyPoint, alloyPoint.Value);
|
||||
highestEtherPoint = Math.Max(highestEtherPoint, etherPoint.Value);
|
||||
|
||||
alloyChart.Points.Add(alloyPoint);
|
||||
etherChart.Points.Add(etherPoint);
|
||||
pyreChart.Points.Add(pyrePoint);
|
||||
}
|
||||
|
||||
alloyChart.HighestValuePoint = (int)Math.Max(highestAlloyPoint, 5000.0f);
|
||||
etherChart.HighestValuePoint = (int)Math.Max(highestEtherPoint, 2000.0f);
|
||||
pyreChart.HighestValuePoint = (int)Math.Max(highestPyrePoint, 2000.0f);
|
||||
|
||||
alloyChart.HighestIntervalPoint = economyOverTime.Count();
|
||||
etherChart.HighestIntervalPoint = economyOverTime.Count();
|
||||
pyreChart.HighestIntervalPoint = economyOverTime.Count();
|
||||
|
||||
armyChart.HighestValuePoint = (int)Math.Max(highestArmyPoint, 2000.0f);
|
||||
armyChart.HighestIntervalPoint = economyOverTime.Count();
|
||||
|
||||
|
||||
charts.Add(alloyChart);
|
||||
charts.Add(etherChart);
|
||||
|
||||
|
||||
//TODO WIP
|
||||
//charts.Add(pyreChart);
|
||||
|
||||
charts.Add(armyChart);
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
@implements IDisposable
|
||||
|
||||
<div style="overflow-y: scroll; width: 100%; overflow-x: hidden; height: 550px;">
|
||||
@if (Entity != null) {
|
||||
<EntityViewComponent Entity=Entity></EntityViewComponent>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
EntityModel Entity;
|
||||
|
||||
[Inject]
|
||||
IKeyService KeyService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IImmortalSelectionService FilterService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
protected override void OnInitialized() {
|
||||
KeyService.Subscribe(HandleClick);
|
||||
BuildOrderService.Subscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
KeyService.Unsubscribe(HandleClick);
|
||||
BuildOrderService.Unsubscribe(OnBuildOrderChanged);
|
||||
}
|
||||
|
||||
|
||||
protected void HandleClick() {
|
||||
var hotkey = KeyService.GetHotkey();
|
||||
var hotkeyGroup = KeyService.GetHotkeyGroup();
|
||||
var isHoldSpace = KeyService.IsHoldingSpace();
|
||||
var faction = FilterService.GetFactionType();
|
||||
var immortal = FilterService.GetImmortalType();
|
||||
|
||||
var foundEntity = EntityModel.GetFrom(hotkey, hotkeyGroup, isHoldSpace, faction, immortal);
|
||||
|
||||
if (foundEntity != null) {
|
||||
Entity = foundEntity;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void OnBuildOrderChanged() {
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<FormLayoutComponent>
|
||||
<FormSelectComponent OnChange="@OnFactionChanged">
|
||||
<FormLabelComponent>Faction</FormLabelComponent>
|
||||
<ChildContent>
|
||||
<option value="@FactionType.Aru">Aru</option>
|
||||
<option value="@FactionType.QRath" selected>Q'Rath</option>
|
||||
</ChildContent>
|
||||
</FormSelectComponent>
|
||||
|
||||
<FormSelectComponent OnChange="@OnImmortalChanged">
|
||||
<FormLabelComponent>Immortal</FormLabelComponent>
|
||||
<ChildContent>
|
||||
@if (FilterService.GetFactionType() == FactionType.QRath) {
|
||||
<option value="@ImmortalType.Orzum" selected>Orzum</option>
|
||||
<option value="@ImmortalType.Ajari">Ajari</option>
|
||||
}
|
||||
@if (FilterService.GetFactionType() == FactionType.Aru) {
|
||||
<option value="@ImmortalType.Mala" selected>Mala</option>
|
||||
<option value="@ImmortalType.Xol">Xol</option>
|
||||
}
|
||||
</ChildContent>
|
||||
</FormSelectComponent>
|
||||
</FormLayoutComponent>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
public IImmortalSelectionService FilterService { get; set; }
|
||||
|
||||
void OnFactionChanged(ChangeEventArgs e) {
|
||||
FilterService.SelectFactionType(e.Value.ToString());
|
||||
}
|
||||
|
||||
void OnImmortalChanged(ChangeEventArgs e) {
|
||||
FilterService.SelectImmortalType(e.Value.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
@implements IDisposable
|
||||
|
||||
<div class="highlightsContainer">
|
||||
<div>
|
||||
<div>Requested</div>
|
||||
|
||||
@for (var i = TimingService.GetTiming() - 1; i >= 0; i--) {
|
||||
@foreach (var order in BuildOrderService.GetOrdersAt(i)) {
|
||||
if (order.EntityType == EntityType.Worker) {
|
||||
continue;
|
||||
}
|
||||
<div>
|
||||
@i | T @Interval.ToTime(i)
|
||||
</div>
|
||||
<div>
|
||||
@order.Info().Name
|
||||
</div>
|
||||
<br/>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
<div>Finished</div>
|
||||
|
||||
@for (var i = TimingService.GetTiming() - 1; i >= 0; i--) {
|
||||
@foreach (var order in BuildOrderService.GetCompletedAt(i)) {
|
||||
if (order.EntityType == EntityType.Worker) {
|
||||
continue;
|
||||
}
|
||||
<div>
|
||||
@i | T @Interval.ToTime(i)
|
||||
</div>
|
||||
<div>
|
||||
@order.Info().Name
|
||||
</div>
|
||||
<br/>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.highlightsContainer {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
height: 400px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
IEconomyService EconomyService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
[Inject]
|
||||
ITimingService TimingService { get; set; }
|
||||
|
||||
protected override void OnInitialized() {
|
||||
EconomyService.Subscribe(StateHasChanged);
|
||||
BuildOrderService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
EconomyService.Unsubscribe(StateHasChanged);
|
||||
BuildOrderService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
@implements IDisposable
|
||||
|
||||
<InputPanelComponent>
|
||||
<div class="keyContainer">
|
||||
@foreach (var hotkey in hotkeys) {
|
||||
if (hotkey.IsHidden) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var color = hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace() || KeyService.GetAllPressedKeys().Contains(hotkey.KeyText)
|
||||
? "#0a0f12" : hotkey.GetColor();
|
||||
|
||||
var x = hotkey.PositionX * Size;
|
||||
var y = hotkey.PositionY * Size;
|
||||
|
||||
var border = "1px solid black";
|
||||
if (hotkey.KeyText.Equals(_key)) {
|
||||
border = "5px solid black";
|
||||
}
|
||||
if (hotkey.KeyText.Equals(_controlGroup)) {
|
||||
border = "5px solid green";
|
||||
}
|
||||
|
||||
if (hotkey.KeyText.Equals("SPACE") && KeyService.IsHoldingSpace()) {
|
||||
border = "5px solid green";
|
||||
}
|
||||
|
||||
<div style="position:relative;
|
||||
cursor:pointer;
|
||||
top:@y.ToString()px;
|
||||
left:@x.ToString()px;
|
||||
width: 0px;
|
||||
height: 0px;">
|
||||
|
||||
<div @onclick="x => { if (hotkey.KeyText.Equals(HotKeyType.SPACE.ToString())) { if (KeyService.IsHoldingSpace()) { KeyService.RemovePressedKey(hotkey.KeyText); } else { KeyService.AddPressedKey(hotkey.KeyText); } } else { KeyService.AddPressedKey(hotkey.KeyText); KeyService.RemovePressedKey(hotkey.KeyText); }}" style="background-color:@color;
|
||||
border: @border;
|
||||
width: @Size.ToString()px;
|
||||
height: @Size.ToString()px;
|
||||
overflow: hidden;
|
||||
padding: 4px;">
|
||||
@hotkey.KeyText
|
||||
@foreach (var entity in data.Values) {
|
||||
if (!BuildOrderService.MeetsRequirements(entity, 9000)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (InvalidKey(entity, hotkey) || InvalidKeyGroup(entity, hotkey) || InvalidHoldSpace(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (InvalidFaction(entity) || InvalidVanguard(entity) || InvalidNonVanguard(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var isVanguard = entity.Vanguard() != null;
|
||||
var style = isVanguard ? "font-weight: bold;" : "";
|
||||
|
||||
<div style="@style">@entity.Info()?.Name</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</InputPanelComponent>
|
||||
|
||||
<style>
|
||||
.keyContainer {
|
||||
width: 400px;
|
||||
max-width: 95vw;
|
||||
height: 400px;
|
||||
outline: 3px solid black;
|
||||
border-radius: 8px;
|
||||
background-color: #282A30;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
@@media only screen and (max-width: 1025px) {
|
||||
.keyContainer {
|
||||
transform: scale(0.85) translateX(-20px);
|
||||
background-color: none;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public int Size { get; set; } = 100;
|
||||
|
||||
[Inject]
|
||||
public IKeyService KeyService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IImmortalSelectionService FilterService { get; set; }
|
||||
|
||||
readonly Dictionary<string, EntityModel> data = EntityModel.GetDictionary();
|
||||
readonly List<HotkeyModel> hotkeys = HotkeyModel.GetAll();
|
||||
|
||||
public string _controlGroup = "C";
|
||||
public string _key = "";
|
||||
|
||||
protected override void OnInitialized() {
|
||||
base.OnInitialized();
|
||||
|
||||
KeyService.Subscribe(OnKeyPressed);
|
||||
FilterService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
KeyService.Unsubscribe(OnKeyPressed);
|
||||
FilterService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidFaction(EntityModel entity) {
|
||||
if (entity.Faction() != null && entity.Faction()?.Faction != FilterService.GetFactionType() && FilterService.GetFactionType() != FactionType.Any) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidVanguard(EntityModel entity) {
|
||||
if (entity.Vanguard() != null && entity.Vanguard()?.Immortal != FilterService.GetImmortalType() && FilterService.GetImmortalType() != ImmortalType.Any) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Move to Filter Service
|
||||
bool InvalidNonVanguard(EntityModel entity) {
|
||||
if (entity.Replaceds().Count > 0) {
|
||||
var isReplaced = false;
|
||||
foreach (var replaced in entity.Replaceds()) {
|
||||
if (FilterService.GetImmortalType() == replaced.Immortal) {
|
||||
isReplaced = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isReplaced) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InvalidRequirements(EntityModel entity) {
|
||||
return !BuildOrderService.MeetsRequirements(entity, 9000);
|
||||
}
|
||||
|
||||
bool InvalidKey(EntityModel entity, HotkeyModel key) {
|
||||
if (entity.Hotkey()?.Hotkey == key.KeyText) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKeyGroup(EntityModel entity, HotkeyModel key) {
|
||||
if (entity.Hotkey()?.HotkeyGroup == _controlGroup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKey(EntityModel entity) {
|
||||
if (entity.Hotkey()?.Hotkey == _key) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidKeyGroup(EntityModel entity) {
|
||||
if (entity.Hotkey()?.HotkeyGroup == _controlGroup) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InvalidHoldSpace(EntityModel entity) {
|
||||
if (entity.Hotkey()?.HoldSpace == KeyService.IsHoldingSpace()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnKeyPressed() {
|
||||
if (KeyService.GetAllPressedKeys().Contains("Z")) {
|
||||
_controlGroup = "Z";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("TAB")) {
|
||||
_controlGroup = "TAB";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("C")) {
|
||||
_controlGroup = "C";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("D")) {
|
||||
_controlGroup = "D";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("1")) {
|
||||
_controlGroup = "1";
|
||||
}
|
||||
//TODO This could be better. Duplicated code
|
||||
if (KeyService.GetAllPressedKeys().Contains("2")) {
|
||||
_controlGroup = "2";
|
||||
}
|
||||
if (KeyService.GetAllPressedKeys().Contains("SHIFT")) {
|
||||
_controlGroup = "SHIFT";
|
||||
}
|
||||
|
||||
if (KeyService.GetAllPressedKeys().Contains("CONTROL")) {
|
||||
_controlGroup = "CONTROL";
|
||||
}
|
||||
|
||||
if (KeyService.GetAllPressedKeys().Count > 0) {
|
||||
_key = KeyService.GetAllPressedKeys().First();
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<div tabindex="0"
|
||||
style="margin: auto;"
|
||||
@onkeydown="HandleKeyDown"
|
||||
@onkeyup="HandleKeyUp"
|
||||
@onkeydown:preventDefault="true"
|
||||
colorwn:stopPropagation="true">
|
||||
@ChildContent
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IKeyService KeyService { get; set; }
|
||||
|
||||
private void HandleKeyDown(KeyboardEventArgs e) {
|
||||
KeyService.AddPressedKey(e.Key);
|
||||
}
|
||||
|
||||
private void HandleKeyUp(KeyboardEventArgs e) {
|
||||
KeyService.RemovePressedKey(e.Key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
@implements IDisposable
|
||||
|
||||
<Virtualize Items="@EconomyService.GetOverTime()" Context="economyAtSecond" ItemSize="400" OverscanCount="4">
|
||||
<div style="display: grid; gap: 8px; grid-template-columns: 1fr 1fr;">
|
||||
<div>
|
||||
<div>
|
||||
@economyAtSecond.Interval
|
||||
</div>
|
||||
<div>
|
||||
T @Interval.ToTime(economyAtSecond.Interval) | A @economyAtSecond.Alloy | E @economyAtSecond.Ether
|
||||
</div>
|
||||
<div>
|
||||
Worker Count: @(economyAtSecond.WorkerCount)
|
||||
</div>
|
||||
<div>
|
||||
Free Worker Count: @(economyAtSecond.WorkerCount - economyAtSecond.BusyWorkerCount)
|
||||
</div>
|
||||
<div>
|
||||
Busy Worker Count: @economyAtSecond.BusyWorkerCount
|
||||
</div>
|
||||
<div>
|
||||
Creating Worker Count: @economyAtSecond.CreatingWorkerCount
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
<div>
|
||||
@foreach (var order in BuildOrderService.GetOrdersAt(economyAtSecond.Interval)) {
|
||||
<div>
|
||||
Requested: @order.Info().Name
|
||||
</div>
|
||||
}
|
||||
@foreach (var order in BuildOrderService.GetCompletedAt(economyAtSecond.Interval)) {
|
||||
<div>
|
||||
New: @order.Info().Name
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</Virtualize>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
IEconomyService EconomyService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
protected override void OnInitialized() {
|
||||
EconomyService.Subscribe(StateHasChanged);
|
||||
BuildOrderService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
EconomyService.Unsubscribe(StateHasChanged);
|
||||
BuildOrderService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<FormLayoutComponent>
|
||||
<FormNumberComponent ReadOnly="true"
|
||||
Max="600"
|
||||
Min="0"
|
||||
Value="@TimingService.GetTiming()"
|
||||
OnChange="@OnTimingChanged">
|
||||
<FormLabelComponent>Timing interval</FormLabelComponent>
|
||||
<FormInfoComponent>Altering the time interval is currently disabled.</FormInfoComponent>
|
||||
</FormNumberComponent>
|
||||
|
||||
<FormTextComponent Label="Name" Placeholder="Fast Thrones..." Value="@BuildOrderService.GetName()" OnChange="OnNameChanged"/>
|
||||
|
||||
<FormTextAreaComponent Label="Notes"
|
||||
Value="@BuildOrderService.GetNotes()"
|
||||
OnChange="@OnNotesChanged">
|
||||
</FormTextAreaComponent>
|
||||
<FormTextComponent Label="Color" Placeholder="red..." Value="@BuildOrderService.GetColor()" OnChange="OnColorChanged"/>
|
||||
</FormLayoutComponent>
|
||||
|
||||
@code {
|
||||
|
||||
[Inject]
|
||||
public ITimingService TimingService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IBuildOrderService BuildOrderService { get; set; }
|
||||
|
||||
|
||||
void OnTimingChanged(ChangeEventArgs changeEventArgs) {
|
||||
TimingService.SetTiming(int.Parse(changeEventArgs.Value.ToString()));
|
||||
}
|
||||
|
||||
void OnTimingChanged(int value) {
|
||||
TimingService.SetTiming(value);
|
||||
}
|
||||
|
||||
void OnNameChanged(ChangeEventArgs changeEventArgs) {
|
||||
BuildOrderService.SetName(changeEventArgs.Value.ToString());
|
||||
}
|
||||
|
||||
void OnColorChanged(ChangeEventArgs changeEventArgs) {
|
||||
BuildOrderService.SetColor(changeEventArgs.Value.ToString());
|
||||
}
|
||||
|
||||
|
||||
void OnNotesChanged(ChangeEventArgs changeEventArgs) {
|
||||
BuildOrderService.SetNotes(changeEventArgs.Value.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user