载入中...
搜索中...
未找到
Warship.cpp
浏览该文件的文档.
1#include "warship/Warship.h"
2
3#include "common/Diagnostic.h"
4#include "common/ECS.h"
6#include "common/Value.h"
9
10#include <squirrel.h>
11#include <simplesquirrel/simplesquirrel.hpp>
12
13#include <cmath>
14#include <cstdint>
15#include <utility>
16
17namespace eve::warship {
18namespace {
19
20template <typename T>
21void registerCppEntityClassForScript(const ssq::Class& cls) {
22 eve::registerCppEntityView(cls, [](ssq::Array& out) {
23 HSQUIRRELVM vm = out.getHandle();
24 sq_pushobject(vm, out.getRaw());
25 ecs::Table* table = ecs::current();
26 if (table == nullptr) {
27 sq_pop(vm, 1);
28 return;
29 }
30 ecs::IComponentManager& cm = table->getOrCreateManager<T>();
31 auto* reg = cm.getOrCreateRegistryComponentBuffer<T>();
32 std::vector<ecs::IComponentBuffer*> stack;
33 stack.push_back(reg);
34 while (!stack.empty()) {
35 ecs::IComponentBuffer* buf = stack.back();
36 stack.pop_back();
37 auto* r = dynamic_cast<ecs::IRegistryComponentBuffer*>(buf);
38 if (r != nullptr) {
39 for (uint32_t i = 0; i < r->entity_count(); ++i) {
40 ecs::Entity* ent = r->entity_at(i);
41 if (ent != nullptr && ecs::is_entity_visible(ent)) {
42 ssq::detail::pushByPtr<T>(vm, static_cast<T*>(ent));
43 sq_arrayappend(vm, -2);
44 }
45 }
46 }
47 if (buf->children != nullptr) stack.push_back(buf->children);
48 if (buf->next != nullptr) stack.push_back(buf->next);
49 }
50 sq_pop(vm, 1);
51 });
52}
53
54Result<void> requireShip(WarshipEntity* ship, const char* op) {
55 if (!ship) {
56 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "warship entity is null", op));
57 }
58 return Result<void>::success();
59}
60
61} // namespace
62
64
66
70
72
74
75bool Warship::hasHullDefinition(const std::string& id) const { return WarshipRegistry::hasHull(id); }
76
77bool Warship::hasFunctionDefinition(const std::string& id) const { return WarshipRegistry::hasFunction(id); }
78
80
82
83std::string Warship::getHullDefinitionCategory(const std::string& id) const {
85 return def ? def->category : std::string{};
86}
87
88std::string Warship::getHullDefinitionMobility(const std::string& id) const {
90 return def ? def->mobility : std::string{};
91}
92
94
96
97Result<WarshipEntity*> Warship::newWarship(const std::string& defId, float x, float y, float heading,
98 const std::string& faction) {
100 if (!def) {
102 Diagnostic::error(DiagnosticCode::InvalidArgument, "unknown hull definition", "warship.new"));
103 }
104 if (!std::isfinite(x) || !std::isfinite(y) || !std::isfinite(heading)) {
106 Diagnostic::error(DiagnosticCode::InvalidArgument, "spawn transform must be finite", "warship.new"));
107 }
108
110 ship->identity()->id = defId + "#" + std::to_string(reinterpret_cast<std::uintptr_t>(ship));
111 ship->identity()->defId = defId;
112 ship->identity()->faction = faction;
113 ship->identity()->category = def->category;
114 ship->definition()->def = def;
115 ship->motion()->x = x;
116 ship->motion()->y = y;
117 ship->motion()->heading = heading;
118 ship->health()->hp = def->maxHealth;
119 ship->health()->maxHp = def->maxHealth;
120 ship->hull()->length = def->length;
121 ship->hull()->beam = def->beam;
122 ship->hull()->decks = def->grid.decks;
123 ship->layout()->grid = def->grid;
124 ship->layout()->cells.assign(static_cast<std::size_t>(def->grid.cellCount()), CompartmentCell{});
125
126 for (const LayoutSeed& seed : def->defaultLayout) {
127 const int index = ship->layout()->grid.indexOf(seed.deck, seed.row, seed.col);
128 if (index < 0) continue;
129 if (!WarshipRegistry::hasFunction(seed.functionId)) continue;
130 ship->layout()->cells[static_cast<std::size_t>(index)].functionId = seed.functionId;
131 }
134}
135
136Result<void> Warship::placeCompartment(WarshipEntity* ship, int deck, int row, int col, const std::string& functionId) {
137 if (auto ok = requireShip(ship, "warship.place"); !ok) return ok;
138 return WarshipSystem::placeCompartment(*ship, deck, row, col, functionId);
139}
140
141Result<void> Warship::clearCompartment(WarshipEntity* ship, int deck, int row, int col) {
142 if (auto ok = requireShip(ship, "warship.clear"); !ok) return ok;
143 return WarshipSystem::clearCompartment(*ship, deck, row, col);
144}
145
146Result<void> Warship::swapCompartments(WarshipEntity* ship, int deckA, int rowA, int colA, int deckB, int rowB,
147 int colB) {
148 if (auto ok = requireShip(ship, "warship.swap"); !ok) return ok;
149 return WarshipSystem::swapCompartments(*ship, deckA, rowA, colA, deckB, rowB, colB);
150}
151
153 if (auto ok = requireShip(ship, "warship.rearrange"); !ok) return ok;
154 return WarshipSystem::rearrangeFromJson(*ship, json);
155}
156
158 return ship == nullptr ? 0 : static_cast<int>(ship->layout()->cells.size());
159}
160
161int Warship::getGridCols(WarshipEntity* ship) const { return ship == nullptr ? 0 : ship->layout()->grid.cols; }
162
163int Warship::getGridRows(WarshipEntity* ship) const { return ship == nullptr ? 0 : ship->layout()->grid.rows; }
164
165int Warship::getGridDecks(WarshipEntity* ship) const { return ship == nullptr ? 0 : ship->layout()->grid.decks; }
166
167std::string Warship::getCompartmentFunction(WarshipEntity* ship, int deck, int row, int col) const {
168 if (ship == nullptr) return {};
169 const int index = ship->layout()->grid.indexOf(deck, row, col);
170 if (index < 0 || index >= static_cast<int>(ship->layout()->cells.size())) return {};
171 return ship->layout()->cells[static_cast<std::size_t>(index)].functionId;
172}
173
175 return ship == nullptr ? 0.f : ship->capabilities()->values.powerNet;
176}
177
179 return ship == nullptr ? 1.f : ship->capabilities()->values.thrustMul;
180}
181
183 return ship == nullptr ? 0 : ship->capabilities()->values.hangarCapacity;
184}
185
187 return ship == nullptr ? 0 : ship->capabilities()->values.weaponBayCount;
188}
189
191 return ship == nullptr ? 0 : ship->capabilities()->values.crewCapacity;
192}
193
195 return ship == nullptr ? 0.f : ship->capabilities()->values.sailPower;
196}
197
199 return ship == nullptr ? false : ship->capabilities()->values.underpowered;
200}
201
202void Warship::moveTo(WarshipEntity* ship, float x, float y) {
203 if (ship == nullptr) return;
204 WarshipSystem::moveTo(*ship, x, y);
205}
206
208 if (ship == nullptr) return;
209 WarshipSystem::stop(*ship);
210}
211
212void Warship::setInput(WarshipEntity* ship, float throttle, float steer) {
213 if (ship == nullptr) return;
214 ship->input()->throttle = throttle;
215 ship->input()->steer = steer;
216 ship->motion()->hasMove = false;
217}
218
220
221float Warship::getX(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->motion()->x; }
222
223float Warship::getY(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->motion()->y; }
224
225float Warship::getHeading(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->motion()->heading; }
226
227float Warship::getSpeed(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->motion()->speed; }
228
229float Warship::getLength(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->hull()->length; }
230
231float Warship::getBeam(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->hull()->beam; }
232
233std::string Warship::getId(WarshipEntity* ship) const { return ship == nullptr ? std::string{} : ship->identity()->id; }
234
235std::string Warship::getDefId(WarshipEntity* ship) const {
236 return ship == nullptr ? std::string{} : ship->identity()->defId;
237}
238
239std::string Warship::getCategory(WarshipEntity* ship) const {
240 return ship == nullptr ? std::string{} : ship->identity()->category;
241}
242
243std::string Warship::getFaction(WarshipEntity* ship) const {
244 return ship == nullptr ? std::string{} : ship->identity()->faction;
245}
246
247float Warship::getHealth(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->health()->hp; }
248
249float Warship::getMaxHealth(WarshipEntity* ship) const { return ship == nullptr ? 0.f : ship->health()->maxHp; }
250
251bool Warship::isArrived(WarshipEntity* ship) const { return ship != nullptr && ship->motion()->arrived; }
252
253bool Warship::isDestroyed(WarshipEntity* ship) const { return ship != nullptr && ship->stateFlags()->destroyed; }
254
255void Warship::applyDamage(WarshipEntity* ship, float amount) {
256 if (!ship) return;
257 WarshipSystem::applyDamage(*ship, amount);
258}
259
261
263
264std::string Warship::getEventType(int index) const {
266 return event ? warshipEventTypeName(event->type) : std::string{};
267}
268
269std::string Warship::getEventWarshipId(int index) const {
271 return event ? event->warshipId : std::string{};
272}
273
274std::string Warship::getEventDefId(int index) const {
276 return event ? event->defId : std::string{};
277}
278
279std::string Warship::getEventDetail(int index) const {
281 return event ? event->detail : std::string{};
282}
283
284void Warship::expose(ssq::Table& table) {
285 auto cls = table.addClass(name, Warship::create, false);
286 expose(cls);
287
288 auto shipCls = table.addClass<WarshipEntity>(
289 "WarshipEntity", std::function<WarshipEntity*()>([]() -> WarshipEntity* { return nullptr; }), false);
290 registerCppEntityClassForScript<WarshipEntity>(shipCls);
291}
292
293void Warship::expose(ssq::Class& cls) {
294 auto intProjector = [](int count) { return eve::Value(static_cast<std::int64_t>(count)); };
295
296 cls.addFunc("registerHullsFromJson", [vm = cls.getHandle(), intProjector](Warship* self, const std::string& json) {
297 if (!self) {
298 return eve::script::projectResult(
299 vm,
300 Result<int>::failure(
301 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")),
302 intProjector);
303 }
304 return eve::script::projectResult(vm, self->registerHullsFromJson(json), intProjector);
305 });
306 cls.addFunc(
307 "registerFunctionsFromJson", [vm = cls.getHandle(), intProjector](Warship* self, const std::string& json) {
308 if (!self) {
310 vm,
312 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")),
313 intProjector);
314 }
315 return eve::script::projectResult(vm, self->registerFunctionsFromJson(json), intProjector);
316 });
317 cls.addFunc("clearHullDefinitions", &Warship::clearHullDefinitions);
318 cls.addFunc("clearFunctionDefinitions", &Warship::clearFunctionDefinitions);
319 cls.addFunc("hasHullDefinition", &Warship::hasHullDefinition);
320 cls.addFunc("hasFunctionDefinition", &Warship::hasFunctionDefinition);
321 cls.addFunc("getHullDefinitionCount", &Warship::getHullDefinitionCount);
322 cls.addFunc("getFunctionDefinitionCount", &Warship::getFunctionDefinitionCount);
323 cls.addFunc("getHullDefinitionCategory", &Warship::getHullDefinitionCategory);
324 cls.addFunc("getHullDefinitionMobility", &Warship::getHullDefinitionMobility);
325 cls.addFunc("getMobilityCount", &Warship::getMobilityCount);
326
327 cls.addFunc("newWarship",
328 [](Warship* self, const std::string& defId, float x, float y, float heading,
329 const std::string& faction) -> WarshipEntity* {
330 if (!self) return nullptr;
331 auto created = self->newWarship(defId, x, y, heading, faction);
332 return created ? created.value() : nullptr;
333 });
334
335 cls.addFunc("placeCompartment", [vm = cls.getHandle()](Warship* self, WarshipEntity* ship, int deck, int row,
336 int col, const std::string& functionId) {
337 if (!self) {
340 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")));
341 }
342 return eve::script::projectResult(vm, self->placeCompartment(ship, deck, row, col, functionId));
343 });
344 cls.addFunc(
345 "clearCompartment", [vm = cls.getHandle()](Warship* self, WarshipEntity* ship, int deck, int row, int col) {
346 if (!self) {
349 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")));
350 }
351 return eve::script::projectResult(vm, self->clearCompartment(ship, deck, row, col));
352 });
353 cls.addFunc("swapCompartments", [vm = cls.getHandle()](Warship* self, WarshipEntity* ship, int deckA, int rowA,
354 int colA, int deckB, int rowB, int colB) {
355 if (!self) {
358 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")));
359 }
360 return eve::script::projectResult(vm, self->swapCompartments(ship, deckA, rowA, colA, deckB, rowB, colB));
361 });
362 cls.addFunc(
363 "rearrangeFromJson", [vm = cls.getHandle()](Warship* self, WarshipEntity* ship, const std::string& json) {
364 if (!self) {
367 Diagnostic::error(DiagnosticCode::InvalidArgument, "warship module is null", "warship")));
368 }
369 return eve::script::projectResult(vm, self->rearrangeFromJson(ship, json));
370 });
371
372 cls.addFunc("getCompartmentCount", &Warship::getCompartmentCount);
373 cls.addFunc("getGridCols", &Warship::getGridCols);
374 cls.addFunc("getGridRows", &Warship::getGridRows);
375 cls.addFunc("getGridDecks", &Warship::getGridDecks);
376 cls.addFunc("getCompartmentFunction", &Warship::getCompartmentFunction);
377 cls.addFunc("getPowerNet", &Warship::getPowerNet);
378 cls.addFunc("getThrustMul", &Warship::getThrustMul);
379 cls.addFunc("getHangarCapacity", &Warship::getHangarCapacity);
380 cls.addFunc("getWeaponBayCount", &Warship::getWeaponBayCount);
381 cls.addFunc("getCrewCapacity", &Warship::getCrewCapacity);
382 cls.addFunc("getSailPower", &Warship::getSailPower);
383 cls.addFunc("isUnderpowered", &Warship::isUnderpowered);
384
385 cls.addFunc("moveTo", &Warship::moveTo);
386 cls.addFunc("stop", &Warship::stop);
387 cls.addFunc("setInput", &Warship::setInput);
388 cls.addFunc("update", &Warship::update);
389
390 cls.addFunc("getX", &Warship::getX);
391 cls.addFunc("getY", &Warship::getY);
392 cls.addFunc("getHeading", &Warship::getHeading);
393 cls.addFunc("getSpeed", &Warship::getSpeed);
394 cls.addFunc("getLength", &Warship::getLength);
395 cls.addFunc("getBeam", &Warship::getBeam);
396 cls.addFunc("getId", &Warship::getId);
397 cls.addFunc("getDefId", &Warship::getDefId);
398 cls.addFunc("getCategory", &Warship::getCategory);
399 cls.addFunc("getFaction", &Warship::getFaction);
400 cls.addFunc("getHealth", &Warship::getHealth);
401 cls.addFunc("getMaxHealth", &Warship::getMaxHealth);
402 cls.addFunc("isArrived", &Warship::isArrived);
403 cls.addFunc("isDestroyed", &Warship::isDestroyed);
404 cls.addFunc("applyDamage", &Warship::applyDamage);
405
406 cls.addFunc("clearEvents", &Warship::clearEvents);
407 cls.addFunc("getEventCount", &Warship::getEventCount);
408 cls.addFunc("getEventType", &Warship::getEventType);
409 cls.addFunc("getEventWarshipId", &Warship::getEventWarshipId);
410 cls.addFunc("getEventDefId", &Warship::getEventDefId);
411 cls.addFunc("getEventDetail", &Warship::getEventDetail);
412}
413
414} // namespace eve::warship
double y
double x
struct SQVM * HSQUIRRELVM
Stable, structured diagnostics shared by engine modules.
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
std::string name
Definition ECS.cpp:154
double r
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
double dt
int created
ScriptStructure out
int count
The single Squirrel projection for common Result, Status and Value.
uint32_t seed
Definition TreeMesh.cpp:276
V3 heading
Definition TreeMesh.cpp:429
uint32_t index
Owning, renderer-independent dynamic values.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Pluggable hull mobility (surface / sail / carrier / space / custom).
Warship short-root entity: huge hull + rearrangeable compartments.
static WarshipEntity * createWarship()
Allocate a WarshipEntity with every component installed. @ownership ECS table owns the entity; caller...
static Result< int > loadHullsFromJson(std::string_view json)
static bool hasHull(const std::string &id)
static bool hasFunction(const std::string &id)
static const WarshipDefinition * findHull(const std::string &id)
Lookup a hull template. @ownership Borrowed; valid until the next clear / replace of that id....
static Result< int > loadFunctionsFromJson(std::string_view json)
static int mobilityCount()
Number of registered mobility implementations (includes builtins).
static void stop(WarshipEntity &ship)
Cancel move order and zero helm input.
static Result< void > clearCompartment(WarshipEntity &ship, int deck, int row, int col)
Vacate one cell.
static void applyDamage(WarshipEntity &ship, float amount, const std::string &sourceId={})
Apply damage; may mark destroyed and push events.
static Result< void > swapCompartments(WarshipEntity &ship, int deckA, int rowA, int colA, int deckB, int rowB, int colB)
Swap two cells atomically.
static void recomputeCapabilities(WarshipEntity &ship)
Recompute Capabilities from Layout + function catalogue. @cost Linear in cell count; amortize across ...
static Result< void > rearrangeFromJson(WarshipEntity &ship, const std::string &json)
Replace the entire layout from a JSON array of {deck,row,col,function}.
static void update(float dt)
Advance all warships one step.
static void moveTo(WarshipEntity &ship, float x, float y, float arriveRadius=24.f)
Issue a move order toward (x, y).
static void registerMobility(IWarshipMobility *mobility)
Register a mobility plugin (same name replaces). Takes ownership.
static const WarshipEvent * eventAt(int index)
Borrow one buffered event by index.
static Result< void > placeCompartment(WarshipEntity &ship, int deck, int row, int col, const std::string &functionId)
Place or replace a function in one cell. @cost One cell write + full capability recompute.
Warship module (eve.Warship).
Definition Warship.h:20
float getHeading(WarshipEntity *ship) const
Definition Warship.cpp:225
bool isArrived(WarshipEntity *ship) const
Definition Warship.cpp:251
static int getMobilityCount()
Definition Warship.cpp:95
std::string getCompartmentFunction(WarshipEntity *ship, int deck, int row, int col) const
Definition Warship.cpp:167
int getCompartmentCount(WarshipEntity *ship) const
Definition Warship.cpp:157
bool isDestroyed(WarshipEntity *ship) const
Definition Warship.cpp:253
void clearFunctionDefinitions()
Definition Warship.cpp:73
void setInput(WarshipEntity *ship, float throttle, float steer)
Definition Warship.cpp:212
float getMaxHealth(WarshipEntity *ship) const
Definition Warship.cpp:249
bool hasHullDefinition(const std::string &id) const
Definition Warship.cpp:75
int getGridRows(WarshipEntity *ship) const
Definition Warship.cpp:163
void clearHullDefinitions()
Definition Warship.cpp:71
float getY(WarshipEntity *ship) const
Definition Warship.cpp:223
void update(float dt)
Definition Warship.cpp:219
std::string getDefId(WarshipEntity *ship) const
Definition Warship.cpp:235
std::string getEventType(int index) const
Definition Warship.cpp:264
Result< void > placeCompartment(WarshipEntity *ship, int deck, int row, int col, const std::string &functionId)
Definition Warship.cpp:136
Result< int > registerFunctionsFromJson(const std::string &json)
Register compartment function catalogue entries from JSON.
Definition Warship.cpp:67
std::string getCategory(WarshipEntity *ship) const
Definition Warship.cpp:239
void stop(WarshipEntity *ship)
Definition Warship.cpp:207
float getPowerNet(WarshipEntity *ship) const
Definition Warship.cpp:174
int getFunctionDefinitionCount() const
Definition Warship.cpp:81
std::string getId(WarshipEntity *ship) const
Definition Warship.cpp:233
float getX(WarshipEntity *ship) const
Definition Warship.cpp:221
float getBeam(WarshipEntity *ship) const
Definition Warship.cpp:231
float getSailPower(WarshipEntity *ship) const
Definition Warship.cpp:194
float getSpeed(WarshipEntity *ship) const
Definition Warship.cpp:227
int getEventCount() const
Definition Warship.cpp:262
float getHealth(WarshipEntity *ship) const
Definition Warship.cpp:247
std::string getHullDefinitionMobility(const std::string &id) const
Definition Warship.cpp:88
float getLength(WarshipEntity *ship) const
Definition Warship.cpp:229
std::string getEventWarshipId(int index) const
Definition Warship.cpp:269
int getCrewCapacity(WarshipEntity *ship) const
Definition Warship.cpp:190
Result< WarshipEntity * > newWarship(const std::string &defId, float x, float y, float heading=0.f, const std::string &faction="")
Spawn a hull from a registered definition. @ownership ECS owns the entity; callers must not delete it...
Definition Warship.cpp:97
static void registerMobility(IWarshipMobility *mobility)
Register a custom mobility plugin (ownership transferred).
Definition Warship.cpp:93
std::string getEventDetail(int index) const
Definition Warship.cpp:279
int getHangarCapacity(WarshipEntity *ship) const
Definition Warship.cpp:182
int getGridCols(WarshipEntity *ship) const
Definition Warship.cpp:161
int getGridDecks(WarshipEntity *ship) const
Definition Warship.cpp:165
void moveTo(WarshipEntity *ship, float x, float y)
Definition Warship.cpp:202
float getThrustMul(WarshipEntity *ship) const
Definition Warship.cpp:178
std::string getHullDefinitionCategory(const std::string &id) const
Definition Warship.cpp:83
bool isUnderpowered(WarshipEntity *ship) const
Definition Warship.cpp:198
Result< int > registerHullsFromJson(const std::string &json)
Register hull templates from a JSON object or array.
Definition Warship.cpp:65
std::string getEventDefId(int index) const
Definition Warship.cpp:274
void applyDamage(WarshipEntity *ship, float amount)
Definition Warship.cpp:255
Result< void > clearCompartment(WarshipEntity *ship, int deck, int row, int col)
Definition Warship.cpp:141
int getHullDefinitionCount() const
Definition Warship.cpp:79
int getWeaponBayCount(WarshipEntity *ship) const
Definition Warship.cpp:186
Result< void > rearrangeFromJson(WarshipEntity *ship, const std::string &json)
Definition Warship.cpp:152
std::string getFaction(WarshipEntity *ship) const
Definition Warship.cpp:243
Result< void > swapCompartments(WarshipEntity *ship, int deckA, int rowA, int colA, int deckB, int rowB, int colB)
Definition Warship.cpp:146
bool hasFunctionDefinition(const std::string &id) const
Definition Warship.cpp:77
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
Warship module entry (eve.Warship): hull/function catalogues, spawn, compartment remodel,...
Definition Warship.cpp:17
const char * warshipEventTypeName(WarshipEventType type)
Stable event type protocol name.
void registerCppEntityView(const ssq::Class &cls, CppEntityViewFn fn)
Registers cpp entity view.
Definition ECS.cpp:1642
One cell of a hull's compartment grid.
int cellCount() const noexcept
Total cell count (cols * rows * decks).
One default layout entry applied when a hull is spawned.
Hull template registered through Warship::registerHullsFromJson.
std::string category
Convention: warship / sailship / carrier / starship / custom.
float length
Hull length in world units (large relative to typical vehicles).
std::string mobility
IWarshipMobility registry name; default surface.
std::vector< LayoutSeed > defaultLayout
float beam
Hull beam (width) in world units.
One warship event (frame cache).