refactor: replace SpaceLayerKinds with strongly-typed SpaceLayerKind enum
Replaces string-based `SpaceLayerKinds` constants with a strongly-typed `SpaceLayerKind` enum. Updates backend services, runtime models, and projection logic to use the new enum. Adds `ToContractValue` method for compatibility with existing contracts.
This commit is contained in:
@@ -1646,7 +1646,7 @@ internal sealed class ShipAiService
|
||||
bool completeOnArrival)
|
||||
{
|
||||
var distance = ship.Position.DistanceTo(targetPosition);
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKinds.LocalSpace;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKind.LocalSpace;
|
||||
ship.SpatialState.MovementRegime = MovementRegimeKinds.LocalFlight;
|
||||
ship.SpatialState.Transit = null;
|
||||
ship.SpatialState.DestinationNodeId = targetCelestial?.Id;
|
||||
@@ -1691,7 +1691,7 @@ internal sealed class ShipAiService
|
||||
subTask.ElapsedSeconds = 0f;
|
||||
}
|
||||
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKinds.SystemSpace;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKind.SystemSpace;
|
||||
ship.SpatialState.MovementRegime = MovementRegimeKinds.Warp;
|
||||
ship.SpatialState.CurrentCelestialId = null;
|
||||
ship.SpatialState.DestinationNodeId = targetCelestial.Id;
|
||||
@@ -1748,7 +1748,7 @@ internal sealed class ShipAiService
|
||||
subTask.ElapsedSeconds = 0f;
|
||||
}
|
||||
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKinds.GalaxySpace;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKind.GalaxySpace;
|
||||
ship.SpatialState.MovementRegime = MovementRegimeKinds.FtlTransit;
|
||||
ship.SpatialState.CurrentCelestialId = null;
|
||||
ship.SpatialState.DestinationNodeId = destinationNodeId;
|
||||
@@ -1779,7 +1779,7 @@ internal sealed class ShipAiService
|
||||
ship.SystemId = targetSystemId;
|
||||
ship.SpatialState.CurrentSystemId = targetSystemId;
|
||||
ship.SpatialState.Transit = null;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKinds.LocalSpace;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKind.LocalSpace;
|
||||
ship.SpatialState.MovementRegime = MovementRegimeKinds.LocalFlight;
|
||||
ship.SpatialState.CurrentCelestialId = targetCelestial?.Id;
|
||||
ship.SpatialState.DestinationNodeId = targetCelestial?.Id;
|
||||
@@ -1794,7 +1794,7 @@ internal sealed class ShipAiService
|
||||
ship.SystemId = targetSystemId;
|
||||
ship.SpatialState.CurrentSystemId = targetSystemId;
|
||||
ship.SpatialState.Transit = null;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKinds.LocalSpace;
|
||||
ship.SpatialState.SpaceLayer = SpaceLayerKind.LocalSpace;
|
||||
ship.SpatialState.MovementRegime = MovementRegimeKinds.LocalFlight;
|
||||
ship.SpatialState.CurrentCelestialId = targetCelestial?.Id;
|
||||
ship.SpatialState.DestinationNodeId = targetCelestial?.Id;
|
||||
@@ -2095,27 +2095,27 @@ internal sealed class ShipAiService
|
||||
var source = stationsById.Values
|
||||
.Where(station =>
|
||||
{
|
||||
if (station.Id == destination.Id || GetInventoryAmount(station.Inventory, order.ItemId) <= GetStationReserveFloor(world, station, order.ItemId) + 1f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (station.Id == destination.Id || GetInventoryAmount(station.Inventory, order.ItemId) <= GetStationReserveFloor(world, station, order.ItemId) + 1f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryCheckSystemAllowed(world, policy, ship.FactionId, station.SystemId, "trade", out var sourceDeniedReason))
|
||||
{
|
||||
deniedReason ??= sourceDeniedReason;
|
||||
return false;
|
||||
}
|
||||
if (!TryCheckSystemAllowed(world, policy, ship.FactionId, station.SystemId, "trade", out var sourceDeniedReason))
|
||||
{
|
||||
deniedReason ??= sourceDeniedReason;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsWithinSystemRange(world, originSystemId, station.SystemId, rangeBudget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!IsWithinSystemRange(world, originSystemId, station.SystemId, rangeBudget))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !requireKnownStations
|
||||
|| ship.KnownStationIds.Count == 0
|
||||
|| ship.KnownStationIds.Contains(station.Id)
|
||||
|| (homeStation is not null && string.Equals(station.Id, homeStation.Id, StringComparison.Ordinal));
|
||||
})
|
||||
return !requireKnownStations
|
||||
|| ship.KnownStationIds.Count == 0
|
||||
|| ship.KnownStationIds.Contains(station.Id)
|
||||
|| (homeStation is not null && string.Equals(station.Id, homeStation.Id, StringComparison.Ordinal));
|
||||
})
|
||||
.OrderByDescending(station => GetInventoryAmount(station.Inventory, order.ItemId) - GetStationReserveFloor(world, station, order.ItemId))
|
||||
.ThenByDescending(station => homeStation is not null && station.Id == homeStation.Id ? 1 : 0)
|
||||
.ThenBy(station => station.Id, StringComparer.Ordinal)
|
||||
|
||||
Reference in New Issue
Block a user