aboutsummaryrefslogtreecommitdiffstats
path: root/src/game/data.hpp
diff options
context:
space:
mode:
authorEmil A. Overbeck <emil.a.overbeck@gmail.com>2026-07-19 04:19:48 +0200
committerEmil A. Overbeck <emil.a.overbeck@gmail.com>2026-07-19 04:19:48 +0200
commit521b5da83485a956811fc510cba9f139acad8b26 (patch)
tree29b210263300479e9a565af568812c5e707d23f7 /src/game/data.hpp
parentff85499d5567c36ce63e2d7903d5f872fd9aef1d (diff)
downloadforts_clone-main.tar.gz
forts_clone-main.zip
New maps and map selectormain
Diffstat (limited to 'src/game/data.hpp')
-rw-r--r--src/game/data.hpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/game/data.hpp b/src/game/data.hpp
index 9b9aec1..3207ba0 100644
--- a/src/game/data.hpp
+++ b/src/game/data.hpp
@@ -43,11 +43,9 @@ std::vector<MaterialDef> load_materials(ScriptEngine& script,
std::vector<WeaponDef> load_weapons(ScriptEngine& script,
const std::string& data_dir);
-// Loads prebuilt structures from <data_dir>/structures.lua (+ mods) and builds
-// them into `graph`. Each structure is a list of beams {x1,y1,x2,y2,material}.
-// Used for scenario forts (e.g. the enemy target). Requires graph.materials set.
-void load_structures(ScriptEngine& script, const std::string& data_dir,
- BuildGraph& graph);
+// A prebuilt strut of a scenario fort, kept in map data so a map can be rebuilt
+// on demand (the dev UI switches maps at runtime).
+struct MapBeam { float x1, y1, x2, y2; std::string material; };
// A device type (reactor / mine / turbine / battery / ...), from data/devices.lua.
struct DeviceDef {
@@ -66,13 +64,32 @@ struct DeviceDef {
float r, g, b; // fallback colour when no texture
};
-// Scenario map: metal deposits + pre-placed devices (player reactor, enemy
-// reactor, starter generators), from data/map.lua (+ mods).
struct PlacedDevice { std::string type; float x, y; int team; };
-struct MapData {
+struct PlacedWeapon { std::string type; float x, y; };
+
+// One selectable scenario from data/maps.lua (+ mod layers): the ground height,
+// metal deposits, pre-placed devices (reactors, generators), the player's
+// starting weapons, and every prebuilt strut. Self-contained on purpose, so the
+// dev UI can tear the world down and rebuild it from another map at runtime.
+//
+// NOTE: terrain is still a flat half-plane, so `ground_level` moves the ground
+// up and down but cannot change its SHAPE. Real terrain is M6.
+struct MapDef {
+ std::string name;
+ std::string description;
+ float ground_level = 1.0f;
std::vector<std::pair<float,float>> deposits;
- std::vector<PlacedDevice> devices;
+ std::vector<PlacedDevice> devices;
+ std::vector<PlacedWeapon> weapons;
+ std::vector<MapBeam> beams;
};
std::vector<DeviceDef> load_devices(ScriptEngine& script, const std::string& data_dir);
-MapData load_map(ScriptEngine& script, const std::string& data_dir);
+
+// Loads every map from <data_dir>/maps.lua (+ mods), same layering as the rest.
+std::vector<MapDef> load_maps(ScriptEngine& script, const std::string& data_dir);
+
+// Clears `graph` and rebuilds it from `m`: sets ground_level, then welds every
+// prebuilt beam (creating/merging endpoint nodes, ground-level ones becoming
+// foundations). Requires graph.materials to be loaded.
+void build_map(const MapDef& m, BuildGraph& graph);