Add resource patch labels to the web map

Group nearby resource tiles of the same type into patches, and label
them on the map, e.g. "Iron ore / 2.4M", or "Crude oil / 12 wells".

- events-library: ResourcePatch model, shared by the server and map.
- events-server-web: ResourcePatchService reads the map-chunk-resource
  topic from the beginning (read_committed) into memory, and on request
  groups tiles into connected patches (join distance 2 tiles for ore,
  12 for infinite resources, whose wells are spread out). Results are
  cached until new data arrives.
  New endpoint: GET .../servers/{id}/map/resources/s{surface}/patches
- web-map: toggleable "Resource patches" overlay with labels at each
  patch centre and a hover tooltip, refreshed every minute. Patches
  under 10 tiles are hidden. (Surface 1 only, like the rest of the map.)
- events-mod: mark resources infinite based on the prototype's
  infinite_resource. Entity initial_amount is nil for e.g. crude oil, so
  oil fields were treated as hundreds of tiny ore patches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lazzexus 2026-10-13 07:07:23 +02:00
parent e183ccd1fc
commit f1ddf9d69b
10 changed files with 388 additions and 5 deletions

View file

@ -0,0 +1,28 @@
package dev.adamko.kafkatorio.schema.common
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* A group of nearby resource tiles of the same type (an ore field, or an oil field), as shown on
* the in-game map.
*/
@Serializable
@SerialName("kafkatorio.resource.ResourcePatch")
data class ResourcePatch(
val protoId: PrototypeId,
val surfaceIndex: SurfaceIndex,
/**
* The total remaining amount. For infinite resources (e.g. crude oil) this is the sum of the
* current yields, so it's only meaningful relative to [tileCount].
*/
val totalAmount: Long,
/** The number of resource entities (ore tiles, or oil wells) in the patch. */
val tileCount: Int,
/** Infinite resources (e.g. crude oil) never deplete, and are counted by wells, not amount. */
val isInfinite: Boolean,
val centre: MapEntityPosition,
val leftTop: MapEntityPosition,
val rightBottom: MapEntityPosition,
)