Map Reader

System Map Reader allows to read environmental properties based on RGBA pixel color that is stored on a alpha texture. Pre rendered PNG maps are loaded as bitmaps into the memory and each query is a set of in game coordinates projected on the pixel map accordingly based on the world size. This approach was chosen to avoid complex spatial queries and heavy logic on the game server side or a game client.

All calculations are done multi-threaded and the service can query thousands of players in parallel with minimal CPU and memory footprint.

Main goal

Our goal was to have a lightweight and modular system that would allows us to have multiple dangerous zones with environmental threats. This gave me an idea to extend this system for even more functionality like network zones, pvp zones, safe zones, literally 0-255 types of various effects. Of course with more alpha maps, the memory footprint increases, but still remains very low. The system works well even with a smaller compressed maps if you don't aim for a pixel perfect precision.

Technical details

I used .NET 8 web console application template and setup a simple minimal API interface. This can be also containerized into docker for easy deployment and scaling. Communication is done via HTTP REST calls with JSON payloads.

/getPixelColor(double x, double y)

The API accepts world coordinates (x, y) as input parameters and returns the pixel color values (RGBA) at that specific coordinate from multiple pre-rendered PNG maps (e.g., radiation, current network, current loot zone).

Use Case

Imagine a player walking cross the map. We sync the player position on a specific tick, that can be every 1 second or even longer, based on the precision and responsiveness that we want, so the period is not frequent but the general call is not heavy on performance. We then send the player coordinates to the MapReader service, which reads the pixel color values from multiple pre-rendered PNG maps (e.g., radiation, current network, current loot zone) at that specific coordinate. The frontend (client or game server) then interprets these values accordingly, which we can specify in a scripted way.

Loot Zones are incorporated with other system Krabice and PDA system and Network System

Radiation Layer

Radiation Layer

Network Zones Layer

Network Zones Layer

Loot Zones Layer

Loot Zones Layer

Combat Military Zone Layer

Military Zone Layer