Эта версия компилится
This commit is contained in:
@@ -24,12 +24,16 @@ struct DefPortal_Mod { };
|
||||
struct DefEntity_Mod { };
|
||||
struct DefItem_Mod { };
|
||||
|
||||
struct DefVoxel { };
|
||||
struct DefNode { };
|
||||
struct DefWorld { };
|
||||
struct DefPortal { };
|
||||
struct DefEntity { };
|
||||
struct DefItem { };
|
||||
struct ResourceBase {
|
||||
std::string Domain, Key;
|
||||
};
|
||||
|
||||
struct DefVoxel : public ResourceBase { };
|
||||
struct DefNode : public ResourceBase { };
|
||||
struct DefWorld : public ResourceBase { };
|
||||
struct DefPortal : public ResourceBase { };
|
||||
struct DefEntity : public ResourceBase { };
|
||||
struct DefItem : public ResourceBase { };
|
||||
|
||||
class ContentManager {
|
||||
template<typename T>
|
||||
@@ -89,10 +93,41 @@ class ContentManager {
|
||||
|
||||
ResourceId resId = NextId[(int) type]++;
|
||||
ContentKeyToId[(int) type][domain][key] = resId;
|
||||
|
||||
switch(type) {
|
||||
case EnumDefContent::Voxel:
|
||||
if(resId >= Profiles_Voxel.size()*TableEntry<DefVoxel>::ChunkSize)
|
||||
Profiles_Voxel.push_back(std::make_unique<TableEntry<DefVoxel>>());
|
||||
break;
|
||||
case EnumDefContent::Node:
|
||||
if(resId >= Profiles_Node.size()*TableEntry<DefNode>::ChunkSize)
|
||||
Profiles_Node.push_back(std::make_unique<TableEntry<DefNode>>());
|
||||
break;
|
||||
case EnumDefContent::World:
|
||||
if(resId >= Profiles_World.size()*TableEntry<DefWorld>::ChunkSize)
|
||||
Profiles_World.push_back(std::make_unique<TableEntry<DefWorld>>());
|
||||
break;
|
||||
case EnumDefContent::Portal:
|
||||
if(resId >= Profiles_Portal.size()*TableEntry<DefPortal>::ChunkSize)
|
||||
Profiles_Portal.push_back(std::make_unique<TableEntry<DefPortal>>());
|
||||
break;
|
||||
case EnumDefContent::Entity:
|
||||
if(resId >= Profiles_Entity.size()*TableEntry<DefEntity>::ChunkSize)
|
||||
Profiles_Entity.push_back(std::make_unique<TableEntry<DefEntity>>());
|
||||
break;
|
||||
case EnumDefContent::Item:
|
||||
if(resId >= Profiles_Item.size()*TableEntry<DefItem>::ChunkSize)
|
||||
Profiles_Item.push_back(std::make_unique<TableEntry<DefItem>>());
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
return resId;
|
||||
}
|
||||
|
||||
void registerBase_Node(ResourceId id, const sol::table& profile);
|
||||
void registerBase_World(ResourceId id, const sol::table& profile);
|
||||
|
||||
public:
|
||||
ContentManager(asio::io_context& ioc);
|
||||
@@ -110,6 +145,60 @@ public:
|
||||
};
|
||||
|
||||
Out_buildEndProfiles buildEndProfiles();
|
||||
|
||||
std::optional<DefVoxel*> getProfile_Voxel(ResourceId id) {
|
||||
assert(id < Profiles_Voxel.size()*TableEntry<DefVoxel>::ChunkSize);
|
||||
auto& value = Profiles_Voxel[id / TableEntry<DefVoxel>::ChunkSize]->Entries[id % TableEntry<DefVoxel>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<DefNode*> getProfile_Node(ResourceId id) {
|
||||
assert(id < Profiles_Node.size()*TableEntry<DefNode>::ChunkSize);
|
||||
auto& value = Profiles_Node[id / TableEntry<DefNode>::ChunkSize]->Entries[id % TableEntry<DefNode>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<DefWorld*> getProfile_World(ResourceId id) {
|
||||
assert(id < Profiles_World.size()*TableEntry<DefWorld>::ChunkSize);
|
||||
auto& value = Profiles_World[id / TableEntry<DefWorld>::ChunkSize]->Entries[id % TableEntry<DefWorld>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<DefPortal*> getProfile_Portal(ResourceId id) {
|
||||
assert(id < Profiles_Portal.size()*TableEntry<DefPortal>::ChunkSize);
|
||||
auto& value = Profiles_Portal[id / TableEntry<DefPortal>::ChunkSize]->Entries[id % TableEntry<DefPortal>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<DefEntity*> getProfile_Entity(ResourceId id) {
|
||||
assert(id < Profiles_Entity.size()*TableEntry<DefEntity>::ChunkSize);
|
||||
auto& value = Profiles_Entity[id / TableEntry<DefEntity>::ChunkSize]->Entries[id % TableEntry<DefEntity>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<DefItem*> getProfile_Item(ResourceId id) {
|
||||
assert(id < Profiles_Item.size()*TableEntry<DefItem>::ChunkSize);
|
||||
auto& value = Profiles_Item[id / TableEntry<DefItem>::ChunkSize]->Entries[id % TableEntry<DefItem>::ChunkSize];
|
||||
if(value)
|
||||
return {&*value};
|
||||
else
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user