refactor(backend): simplify cargo kind loading
This commit is contained in:
@@ -46,7 +46,7 @@ internal static class SimulationRuntimeSupport
|
||||
}
|
||||
|
||||
var remaining = station.Inventory
|
||||
.Where(entry => world.ItemDefinitions.TryGetValue(entry.Key, out var definition) && definition.CargoStorageKind == storageKind)
|
||||
.Where(entry => world.ItemDefinitions.TryGetValue(entry.Key, out var definition) && definition.CargoKind == storageKind)
|
||||
.Sum(entry => entry.Value);
|
||||
|
||||
foreach (var (module, definition) in storageModules)
|
||||
@@ -114,8 +114,8 @@ internal static class SimulationRuntimeSupport
|
||||
internal static bool CanExtractNode(ShipRuntime ship, ResourceNodeRuntime node, SimulationWorld world) =>
|
||||
HasShipCapabilities(ship.Definition, "mining")
|
||||
&& world.ItemDefinitions.TryGetValue(node.ItemId, out var item)
|
||||
&& item.CargoStorageKind is not null
|
||||
&& item.CargoStorageKind == ship.Definition.CargoStorageKind;
|
||||
&& item.CargoKind is not null
|
||||
&& item.CargoKind == ship.Definition.CargoKind;
|
||||
|
||||
internal static bool CanBuildClaimBeacon(ShipRuntime ship) =>
|
||||
string.Equals(ship.Definition.Kind, "military", StringComparison.Ordinal);
|
||||
@@ -176,7 +176,7 @@ internal static class SimulationRuntimeSupport
|
||||
return 0f;
|
||||
}
|
||||
|
||||
var storageKind = itemDefinition.CargoStorageKind;
|
||||
var storageKind = itemDefinition.CargoKind;
|
||||
if (storageKind is null)
|
||||
{
|
||||
return 0f;
|
||||
@@ -194,7 +194,7 @@ internal static class SimulationRuntimeSupport
|
||||
}
|
||||
|
||||
var used = station.Inventory
|
||||
.Where(entry => world.ItemDefinitions.TryGetValue(entry.Key, out var definition) && definition.CargoStorageKind == storageKind)
|
||||
.Where(entry => world.ItemDefinitions.TryGetValue(entry.Key, out var definition) && definition.CargoKind == storageKind)
|
||||
.Sum(entry => entry.Value);
|
||||
var accepted = MathF.Min(amount, MathF.Max(0f, capacity - used));
|
||||
if (accepted <= 0.01f)
|
||||
|
||||
Reference in New Issue
Block a user