Show building rotation, recipes and other surfaces on the web map

The mod now sends each building's direction and recipe (furnaces: the last
recipe, since they only have one while working).
- Rotated buildings are drawn at their real footprint.
- Crafting machines show their recipe icon, like Factorio's alt mode, and
  the hover tooltip includes the recipe.

The web map has a surface drop-down (e.g. Space Exploration planets and
orbits), backed by a new surfaces endpoint. Every layer, the resource labels
and the player markers follow the chosen surface.

Resource labels use the in-game names (e.g. "Iridite" instead of
"Se iridium ore"). export_building_icons.py also exports recipe icons, plus
recipe and resource names.

The three in-memory views in events-server-web now share one helper for
following a Kafka topic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lazzexus 2026-10-21 10:14:39 +02:00
parent 7ef4918a5c
commit b9adb9ea83
20 changed files with 482 additions and 139 deletions

View file

@ -306,6 +306,8 @@ export interface FactorioEntityUpdateElementStandard {
isActive?: boolean;
isRotatable?: boolean;
lastUser?: UInt | null;
direction?: UByte | null;
recipe?: string | null;
}
export type MinedProduct =

View file

@ -11,6 +11,7 @@ import EventDataCache from "../../emitting/EventDataCache";
import {
BoundingBox,
LuaEntity,
LuaRecipePrototype,
LuaSurface,
MapPosition,
OldTileAndPosition,
@ -137,6 +138,8 @@ export class EntityUpdatesHandler {
isRotatable: entity.rotatable,
lastUser: entity.last_user?.index,
status: Converters.entityStatus(entity.status),
direction: entity.supports_direction ? entity.direction : undefined,
recipe: EntityUpdatesHandler.recipeName(entity),
}
EventDataCache.throttle<KafkatorioPacketData.MapChunkEntityUpdate>(
@ -156,6 +159,22 @@ export class EntityUpdatesHandler {
}
/** The recipe of a crafting machine. Furnaces only have a recipe while working, so use the last one. */
private static recipeName(entity: LuaEntity): string | undefined {
if (entity.type == "assembling-machine" || entity.type == "rocket-silo") {
const [recipe] = entity.get_recipe()
return recipe?.name
} else if (entity.type == "furnace") {
const [recipe] = entity.get_recipe()
if (recipe != undefined) return recipe.name
// documented as a prototype, but be lenient in case it's a name
const previous = entity.previous_recipe?.name as LuaRecipePrototype | string | undefined
return typeof previous == "string" ? previous : previous?.name
}
return undefined
}
private static throttleResourcesUpdate(
eventName: EventName,
eventTick: Tick,