Skip to content

Commit ca14218

Browse files
author
Ivan Kravarščan
committed
Fixed fuel usage change when sending a fleet
1 parent 2f91950 commit ca14218

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

source/Stareater.Core/Controllers/PlayerController.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,9 @@ public IEnumerable<FleetInfo> FleetsMine
175175
get
176176
{
177177
var game = this.gameInstance;
178-
var orders = game.Orders[this.PlayerInstance(game)].ShipOrders;
179-
var player = this.PlayerInstance(game);
180178

181-
return game.States.Fleets.
182-
OwnedBy[player].
183-
Where(x => !orders.ContainsKey(x.Position)).
184-
Concat(orders.SelectMany(x => x.Value)).
179+
return game.Derivates[this.PlayerInstance(game)].
180+
MyFleets(game).
185181
Select(
186182
x => new FleetInfo(x, game.Derivates[x.Owner], game.Statics)
187183
);

source/Stareater.Core/GameLogic/PlayerProcessor.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,19 @@ public void CalculateStareater(MainGame game)
270270
}
271271
}
272272

273-
public double TotalFuelUsage(MainGame game)
273+
public IEnumerable<Fleet> MyFleets(MainGame game)
274274
{
275-
//TODO(v0.8) duplicate from PlayerController.FleetsMine
275+
var orders = game.Orders[this.Player].ShipOrders;
276+
276277
return game.States.Fleets.
277-
OwnedBy[this.Player].
278-
Concat(game.Orders[this.Player].ShipOrders.SelectMany(x => x.Value)).
279-
Sum(fleet => this.FuelUsage(fleet, game));
278+
OwnedBy [this.Player].
279+
Where(x => !orders.ContainsKey(x.Position)).
280+
Concat(orders.SelectMany(x => x.Value));
281+
}
282+
283+
public double TotalFuelUsage(MainGame game)
284+
{
285+
return this.MyFleets(game).Sum(fleet => this.FuelUsage(fleet, game));
280286
}
281287

282288
public double FuelUsage(Fleet fleet, MainGame game)

source/Stareater.UI.WinForms/GameScenes/GalaxyScene.cs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ private void setupFleetMovement()
338338
).ToList()
339339
);
340340
}
341-
341+
342342
//TODO(v0.8) bundle with movement simulation
343343
private void setupMovementEta()
344344
{
@@ -352,28 +352,25 @@ private void setupMovementEta()
352352

353353
var waypoints = this.SelectedFleet.SimulationWaypoints();
354354

355-
if (waypoints.Count > 0 && this.SelectedFleet.SimulationEta > 0)
356-
{
357-
var destination = waypoints[waypoints.Count - 1];
358-
var numVars = new Var("eta", Math.Ceiling(this.SelectedFleet.SimulationEta)).Get;
359-
var textVars = new TextVar("eta", new DecimalsFormatter(0, 1).Format(this.SelectedFleet.SimulationEta, RoundingMethod.Ceil, 0)).
360-
And("fuel", new ThousandsFormatter().Format(this.SelectedFleet.SimulationFuel)).Get;
355+
var destination = waypoints[waypoints.Count - 1];
356+
var numVars = new Var("eta", Math.Ceiling(this.SelectedFleet.SimulationEta)).Get;
357+
var textVars = new TextVar("eta", new DecimalsFormatter(0, 1).Format(this.SelectedFleet.SimulationEta, RoundingMethod.Ceil, 0)).
358+
And("fuel", new ThousandsFormatter().Format(this.SelectedFleet.SimulationFuel)).Get;
361359

362-
this.UpdateScene(
363-
ref this.movementEtaText,
364-
new SceneObjectBuilder().
365-
StartSprite(EtaZ, TextRenderUtil.Get.TextureId, Color.White).
366-
Scale(EtaTextScale / (float)Math.Pow(ZoomBase, zoomLevel)).
367-
Translate(destination.X, destination.Y + 0.5).
368-
AddVertices(
369-
TextRenderUtil.Get.BufferText(
370-
LocalizationManifest.Get.CurrentLanguage["FormMain"]["FleetEta"].Text(numVars, textVars),
371-
-0.5f,
372-
Matrix4.Identity
373-
)).
374-
Build()
375-
);
376-
}
360+
this.UpdateScene(
361+
ref this.movementEtaText,
362+
new SceneObjectBuilder().
363+
StartSprite(EtaZ, TextRenderUtil.Get.TextureId, Color.White).
364+
Scale(EtaTextScale / (float)Math.Pow(ZoomBase, zoomLevel)).
365+
Translate(destination.X, destination.Y + 0.5).
366+
AddVertices(
367+
TextRenderUtil.Get.BufferText(
368+
LocalizationManifest.Get.CurrentLanguage["FormMain"]["FleetEta"].Text(numVars, textVars),
369+
-0.5f,
370+
Matrix4.Identity
371+
)).
372+
Build()
373+
);
377374
}
378375

379376
private void setupMovementSimulation()

0 commit comments

Comments
 (0)