|
|
@@ -14,39 +14,22 @@ class UnitCompiler
|
|
|
{
|
|
|
typedef Buffer (*CompileFunction)(const char* json, CompileOptions& opts);
|
|
|
|
|
|
-public:
|
|
|
-
|
|
|
- UnitCompiler(CompileOptions& opts);
|
|
|
-
|
|
|
- void compile_unit(const char* path);
|
|
|
- void compile_unit_from_json(const char* json);
|
|
|
- void compile_multiple_units(const char* json);
|
|
|
-
|
|
|
- Buffer get();
|
|
|
-
|
|
|
-private:
|
|
|
+ struct ComponentTypeData
|
|
|
+ {
|
|
|
+ ALLOCATOR_AWARE;
|
|
|
|
|
|
- void register_component_compiler(const char* type, CompileFunction fn, f32 spawn_order);
|
|
|
- Buffer compile_component(StringId32 type, const char* json);
|
|
|
- void add_component_data(StringId32 type, const Buffer& data, u32 unit_index);
|
|
|
+ CompileFunction _compiler;
|
|
|
|
|
|
-private:
|
|
|
+ u32 _num;
|
|
|
+ Array<u32> _unit_index;
|
|
|
+ Buffer _data;
|
|
|
|
|
|
- struct ComponentTypeData
|
|
|
- {
|
|
|
ComponentTypeData(Allocator& a)
|
|
|
- : _data(a)
|
|
|
+ : _num(0)
|
|
|
, _unit_index(a)
|
|
|
- , _num(0)
|
|
|
+ , _data(a)
|
|
|
{
|
|
|
}
|
|
|
-
|
|
|
- Buffer _data;
|
|
|
- Array<u32> _unit_index;
|
|
|
- CompileFunction _compiler;
|
|
|
- u32 _num;
|
|
|
-
|
|
|
- ALLOCATOR_AWARE;
|
|
|
};
|
|
|
|
|
|
typedef SortMap<StringId32, ComponentTypeData> ComponentTypeMap;
|
|
|
@@ -54,6 +37,20 @@ private:
|
|
|
CompileOptions& _opts;
|
|
|
u32 _num_units;
|
|
|
ComponentTypeMap _component_data;
|
|
|
+
|
|
|
+ void register_component_compiler(const char* type, CompileFunction fn, f32 spawn_order);
|
|
|
+ Buffer compile_component(StringId32 type, const char* json);
|
|
|
+ void add_component_data(StringId32 type, const Buffer& data, u32 unit_index);
|
|
|
+
|
|
|
+public:
|
|
|
+
|
|
|
+ UnitCompiler(CompileOptions& opts);
|
|
|
+
|
|
|
+ void compile_unit(const char* path);
|
|
|
+ void compile_unit_from_json(const char* json);
|
|
|
+ void compile_multiple_units(const char* json);
|
|
|
+
|
|
|
+ Buffer blob();
|
|
|
};
|
|
|
|
|
|
} // namespace crown
|