aboutsummaryrefslogtreecommitdiffstats
path: root/src/game/build_graph.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/build_graph.hpp')
-rw-r--r--src/game/build_graph.hpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game/build_graph.hpp b/src/game/build_graph.hpp
index 4452139..cd8dc3d 100644
--- a/src/game/build_graph.hpp
+++ b/src/game/build_graph.hpp
@@ -67,6 +67,17 @@ struct BuildEdge {
struct BuildFace { int node_a, node_b, node_c; };
+// A device mounted on the strut graph via two mount nodes. It is destroyed when
+// (a) both mount nodes are removed (fall below ground, snap, break), or
+// (b) its HP reaches zero from splash/beam/fire damage.
+struct MountedDevice {
+ int node_a, node_b; // mount-point node indices (-1 if destroyed)
+ int type; // index into DeviceDefs (from data.hpp)
+ int team = 0; // team index (0 = player, 1 = enemy)
+ float hp, max_hp;
+ bool alive = true;
+};
+
class BuildGraph {
public:
// Material table, loaded from Lua at startup (build modes index into it).
@@ -133,6 +144,24 @@ public:
// e.g. restoring a scenario snapshot).
void rebuild() { rebuild_topology(); }
+ // --- devices mounted on the strut graph ------------------------------
+ // Attach a device to two mount nodes (any type from DeviceDefs).
+ // Returns the device index in the graph's devices vector.
+ int mount_device(int na, int nb, int device_type, int team, float hp);
+
+ // Remove a device (e.g. when a weapon shot destroys it outright).
+ // Does NOT shift indices — marks it dead and skips it in queries.
+ void unmount_device(int device_id);
+
+ bool is_device_alive(int device_id) const;
+ float get_device_hp(int device_id) const;
+ const std::vector<MountedDevice>& get_devices() const { return devices; }
+ int nearest_device(float x, float y, float radius) const;
+
+ // Deal damage to a device (splash/beam/fire). Returns true if the device
+ // was alive before and is dead after (for downstream win-condition checks).
+ bool damage_device(int device_id, float amount);
+
// --- destruction primitives -------------------------------------------
void break_edge(int edge_id);
void break_node(int node_id);
@@ -147,6 +176,7 @@ public:
std::vector<BuildNode> nodes;
std::vector<BuildEdge> edges;
std::vector<BuildFace> faces;
+ std::vector<MountedDevice> devices;
struct Destroyed { float x, y; };
std::vector<Destroyed> destroyed_events; // drained by the app for FX