38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
namespace NeonSprawl.Server.Game.Items;
|
|
|
|
/// <summary>Maps <c>GET /game/world/item-definitions</c> (NEO-53).</summary>
|
|
public static class ItemDefinitionsWorldApi
|
|
{
|
|
public static WebApplication MapItemDefinitionsWorldApi(this WebApplication app)
|
|
{
|
|
app.MapGet(
|
|
"/game/world/item-definitions",
|
|
(IItemDefinitionRegistry registry) =>
|
|
{
|
|
var defs = registry.GetDefinitionsInIdOrder();
|
|
var items = new List<ItemDefinitionJson>(defs.Count);
|
|
foreach (var d in defs)
|
|
{
|
|
items.Add(
|
|
new ItemDefinitionJson
|
|
{
|
|
Id = d.Id,
|
|
DisplayName = d.DisplayName,
|
|
PrototypeRole = d.PrototypeRole,
|
|
StackMax = d.StackMax,
|
|
InventorySlotKind = d.InventorySlotKind,
|
|
});
|
|
}
|
|
|
|
return Results.Json(
|
|
new ItemDefinitionsListResponse
|
|
{
|
|
SchemaVersion = ItemDefinitionsListResponse.CurrentSchemaVersion,
|
|
Items = items,
|
|
});
|
|
});
|
|
|
|
return app;
|
|
}
|
|
}
|