Kaynağa Gözat

improve TypeRegistry

Kolja Strohm 1 ay önce
ebeveyn
işleme
87464f7f24
82 değiştirilmiş dosya ile 2213 ekleme ve 2054 silme
  1. 185 0
      ConfigEditor/ConfigEditor.vcxproj
  2. 22 0
      ConfigEditor/ConfigEditor.vcxproj.filters
  3. BIN
      ConfigEditor/data/schriften/ksgs.ltds
  4. BIN
      ConfigEditor/error_core_memory_dump.dmp
  5. 106 0
      ConfigEditor/main.cpp
  6. 18 2
      FactoryCraft.sln
  7. 14 17
      FactoryCraft/Animal.cpp
  8. 4 6
      FactoryCraft/Animal.h
  9. 60 47
      FactoryCraft/BasicBlocks.cpp
  10. 13 17
      FactoryCraft/BasicBlocks.h
  11. 24 20
      FactoryCraft/BasicItems.cpp
  12. 4 5
      FactoryCraft/BasicItems.h
  13. 238 236
      FactoryCraft/BasicTool.cpp
  14. 25 32
      FactoryCraft/BasicTool.h
  15. 18 20
      FactoryCraft/BiomGenerator.cpp
  16. 4 7
      FactoryCraft/BiomGenerator.h
  17. 25 22
      FactoryCraft/Block.cpp
  18. 4 4
      FactoryCraft/Block.h
  19. 80 96
      FactoryCraft/BlockFilter.cpp
  20. 32 51
      FactoryCraft/BlockFilter.h
  21. 11 10
      FactoryCraft/BlockInstanceGeneratorRule.cpp
  22. 4 4
      FactoryCraft/BlockInstanceGeneratorRule.h
  23. 20 15
      FactoryCraft/BlockType.h
  24. 12 9
      FactoryCraft/BlockTypeGeneratorRule.cpp
  25. 4 4
      FactoryCraft/BlockTypeGeneratorRule.h
  26. 16 12
      FactoryCraft/Chest.cpp
  27. 7 9
      FactoryCraft/Chest.h
  28. 27 27
      FactoryCraft/DimensionGenerator.cpp
  29. 22 17
      FactoryCraft/DimensionGenerator.h
  30. 16 19
      FactoryCraft/EntityGenerator.cpp
  31. 4 6
      FactoryCraft/EntityGenerator.h
  32. 1 1
      FactoryCraft/FactoryCraft.vcxproj
  33. 22 19
      FactoryCraft/FluidBlock.cpp
  34. 4 5
      FactoryCraft/FluidBlock.h
  35. 66 65
      FactoryCraft/FluidContainer.cpp
  36. 12 14
      FactoryCraft/FluidContainer.h
  37. 7 7
      FactoryCraft/Game.cpp
  38. 13 6
      FactoryCraft/GeneratorRule.h
  39. 12 5
      FactoryCraft/GeneratorTemplate.h
  40. 15 10
      FactoryCraft/Grass.cpp
  41. 7 10
      FactoryCraft/Grass.h
  42. 30 27
      FactoryCraft/GrowingPlant.cpp
  43. 4 4
      FactoryCraft/GrowingPlant.h
  44. 10 15
      FactoryCraft/Item.cpp
  45. 3 6
      FactoryCraft/Item.h
  46. 39 48
      FactoryCraft/ItemFilter.cpp
  47. 16 26
      FactoryCraft/ItemFilter.h
  48. 34 42
      FactoryCraft/ItemModifier.cpp
  49. 16 24
      FactoryCraft/ItemModifier.h
  50. 14 8
      FactoryCraft/ItemSkill.h
  51. 2 2
      FactoryCraft/ItemType.cpp
  52. 12 6
      FactoryCraft/ItemType.h
  53. 77 86
      FactoryCraft/JNoise.cpp
  54. 3 3
      FactoryCraft/JNoise.h
  55. 122 149
      FactoryCraft/JsonExpression.cpp
  56. 36 54
      FactoryCraft/JsonExpression.h
  57. 28 28
      FactoryCraft/LightSources.cpp
  58. 4 4
      FactoryCraft/LightSources.h
  59. 16 19
      FactoryCraft/ModelInfo.cpp
  60. 4 6
      FactoryCraft/ModelInfo.h
  61. 43 53
      FactoryCraft/PlaceableProof.cpp
  62. 16 24
      FactoryCraft/PlaceableProof.h
  63. 87 100
      FactoryCraft/Quest.cpp
  64. 20 32
      FactoryCraft/Quest.h
  65. 12 9
      FactoryCraft/QuestRequirement.cpp
  66. 16 9
      FactoryCraft/QuestRequirement.h
  67. 23 22
      FactoryCraft/QuestReward.cpp
  68. 22 17
      FactoryCraft/QuestReward.h
  69. 60 61
      FactoryCraft/Recipie.cpp
  70. 29 29
      FactoryCraft/Recipie.h
  71. 5 5
      FactoryCraft/RecipieLoader.cpp
  72. 1 1
      FactoryCraft/RecipieLoader.h
  73. 24 26
      FactoryCraft/StructureCollection.cpp
  74. 4 6
      FactoryCraft/StructureCollection.h
  75. 17 17
      FactoryCraft/TreeSeblingBlock.cpp
  76. 4 4
      FactoryCraft/TreeSeblingBlock.h
  77. 19 15
      FactoryCraft/TreeTemplate.cpp
  78. 4 5
      FactoryCraft/TreeTemplate.h
  79. 1 1
      FactoryCraft/TypeRegistry.cpp
  80. 152 200
      FactoryCraft/TypeRegistry.h
  81. 5 5
      FactoryCraft/WorldGenerator.cpp
  82. 1 0
      Windows Version/Windows Version.vcxproj

+ 185 - 0
ConfigEditor/ConfigEditor.vcxproj

@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="main.cpp" />
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{1ef64c4f-fdb8-4c8e-9d85-b71937ddcadd}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>ConfigEditor</RootNamespace>
+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v143</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v143</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>..\..\..\..\..\Allgemein\Framework;..\FactoryCraft;..\..\..\..\..\Allgemein\Network\Network;..\..\..\..\..\Allgemein\Network;$(IncludePath)</IncludePath>
+    <LibraryPath>..\..\..\..\..\Allgemein\Framework\x64\debug;..\..\..\..\..\Allgemein\Network\x64\debug;$(LibraryPath)</LibraryPath>
+    <SourcePath>..\FactoryCraft;$(SourcePath)</SourcePath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>..\..\Framework;$(IncludePath)</IncludePath>
+    <LibraryPath>..\..\Framework\Release;$(LibraryPath)</LibraryPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+    <IncludePath>..\..\..\..\..\Allgemein\Framework;..\FactoryCraft;..\..\..\..\..\Allgemein\Network\Network;..\..\..\..\..\Allgemein\Network;$(IncludePath)</IncludePath>
+    <LibraryPath>..\..\..\..\..\Allgemein\Framework\x64\release;..\..\..\..\..\Allgemein\Network\x64\release;$(LibraryPath)</LibraryPath>
+    <SourcePath>..\FactoryCraft;$(SourcePath)</SourcePath>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>Framework.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <LanguageStandard>stdcpp20</LanguageStandard>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>Framework.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+    <CustomBuildStep>
+      <Command>copy ..\..\..\..\..\Allgemein\Network\x64\debug\Network.dll Network.dll
+copy ..\..\..\..\..\Allgemein\Framework\x64\debug\Framework.dll Framework.dll</Command>
+    </CustomBuildStep>
+    <CustomBuildStep>
+      <Outputs>kopieren...;%(Outputs)</Outputs>
+    </CustomBuildStep>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>Framework.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+    <CustomBuildStep>
+    </CustomBuildStep>
+    <CustomBuildStep>
+      <Outputs>kopieren...;%(Outputs)</Outputs>
+    </CustomBuildStep>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <LanguageStandard>stdcpp20</LanguageStandard>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>Framework.lib;Network.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+    <CustomBuildStep>
+    </CustomBuildStep>
+    <CustomBuildStep>
+      <Outputs>kopieren...;%(Outputs)</Outputs>
+      <Command>copy ..\..\..\..\..\Allgemein\Network\x64\release\Network.dll Network.dll
+copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll</Command>
+    </CustomBuildStep>
+  </ItemDefinitionGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 22 - 0
ConfigEditor/ConfigEditor.vcxproj.filters

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Quelldateien">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Headerdateien">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Ressourcendateien">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="main.cpp">
+      <Filter>Headerdateien</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

BIN
ConfigEditor/data/schriften/ksgs.ltds


BIN
ConfigEditor/error_core_memory_dump.dmp


+ 106 - 0
ConfigEditor/main.cpp

@@ -0,0 +1,106 @@
+#include <Datei.h>
+#include <DateiSystem.h>
+#include <Fenster.h>
+#include <GraphicsApi.h>
+#include <JsonEditor.h>
+#include <Logging.h>
+#include <main.h>
+#include <MausEreignis.h>
+#include <RenderThread.h>
+#include <Schrift.h>
+#include <TastaturEreignis.h>
+#include <UIInitialization.h>
+#include <XML.h>
+
+using namespace Framework;
+
+int KSGStart Framework::Start(Startparam p)
+{
+    Logging::LoggingChannel* logger
+        = new Logging::OutputDebugStringLoggingChannel();
+    logger->setFormat(Logging::LoggingFormatBuilder()
+                          .datetime("h:i:s")
+                          .level(false)
+                          .text(": ")
+                          .build());
+    Logging::zLoggingHandler()->addChannel(logger);
+
+    WFenster fenster;
+    WNDCLASS wc = Framework::F_Normal(p.hinst);
+    wc.lpszClassName = "Config Editor";
+    fenster.erstellen(WS_OVERLAPPEDWINDOW, wc);
+    fenster.setBounds(Punkt(100, 100), Punkt(1100, 1100));
+
+    fenster.setAnzeigeModus(SW_SHOWNORMAL);
+    fenster.setVSchließAktion([&fenster](void* p, void* f) {
+        StopNachrichtenSchleife(fenster.getFensterHandle());
+    });
+    fenster.setMausAktion(_ret1ME);
+    fenster.setTastaturAktion(_ret1TE);
+    Bildschirm3D screen(
+        dynamic_cast<WFenster*>(fenster.getThis()), new DirectX11());
+    screen.setHandleUserInputsOnTick(1);
+    fenster.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+    screen.setFillFarbe(0);
+    screen.setTestRend(1);
+
+    LTDSDatei dat;
+    dat.setPfad(new Text("data/schriften/ksgs.ltds"));
+    dat.leseDaten();
+    Schrift* schrift = dat.ladeSchrift();
+
+    JSON::JsonEditor* editor
+        = new JSON::JsonEditor(Framework::defaultUI(schrift, &screen));
+    editor->setPosition(0, 0);
+    editor->setSize(1080, 1050);
+    editor->setStyle(ZeichnungHintergrund::Style::Hintergrund
+                     | ZeichnungHintergrund::Style::Sichtbar
+                     | ZeichnungHintergrund::Style::Erlaubt);
+    editor->setHintergrundFarbe(0xFF000000);
+    editor->setFont(dynamic_cast<Schrift*>(schrift->getThis()));
+    editor->setMausEreignis(_ret1ME);
+    editor->setTastaturEreignis(_ret1TE);
+
+    Datei v("../Windows Version/data/syntax/class DimensionGenerator.xml");
+    v.open(Datei::Style::lesen);
+    int size = (int)v.getSize();
+    char* buffer = new char[size + 1];
+    v.lese(buffer, size);
+    buffer[size] = 0;
+    v.close();
+    XML::Element* xml = new XML::Element(buffer);
+    delete[] buffer;
+    JSON::Validator::JSONValidator* validator
+        = JSON::Validator::JSONValidator::buildForArray()
+              ->addAcceptedTypeInArray(
+                  new Framework::JSON::Validator::JSONValidator(xml))
+              ->finishArray();
+    editor->setValidator(validator);
+
+    Datei d("../Windows Version/data/generator/overworld.json");
+    // Datei d("C:/Users/kolja/Downloads/train_0/train_0.iml");
+    //  Datei d("C:/Users/kolja/Downloads/train_0/neu 36.txt");
+    d.open(Datei::Style::lesen);
+    size = (int)d.getSize();
+    buffer = new char[size + 1];
+    d.lese(buffer, size);
+    buffer[size] = 0;
+    d.close();
+
+    editor->setContent(buffer);
+    // editor->setContent("{\"price_usd\": \"üöä\",\"test\":{},\"\":[]}");
+    delete[] buffer;
+    screen.addMember(editor);
+
+    RenderTh rTh;
+    rTh.setMaxFps(60);
+    rTh.setQuiet(1);
+    rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
+
+    rTh.beginn();
+    StartNachrichtenSchleife();
+    rTh.beenden();
+    schrift->release();
+
+    return 0;
+}

+ 18 - 2
FactoryCraft.sln

@@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Windows Version", "Windows
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest\NoiseTest.vcxproj", "{096A454C-3835-4A4E-89FE-34EDCCD80467}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConfigEditor", "ConfigEditor\ConfigEditor.vcxproj", "{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|ARM = Debug|ARM
@@ -28,8 +30,6 @@ Global
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|ARM64.Build.0 = Debug|ARM64
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|ARM64.Deploy.0 = Debug|ARM64
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x64.ActiveCfg = Debug|x64
-		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x64.Build.0 = Debug|x64
-		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x64.Deploy.0 = Debug|x64
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x86.ActiveCfg = Debug|x86
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x86.Build.0 = Debug|x86
 		{A1B59831-7E37-4F83-A545-0E27609E8295}.Debug|x86.Deploy.0 = Debug|x86
@@ -77,6 +77,22 @@ Global
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x64.Build.0 = Release|x64
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x86.ActiveCfg = Release|Win32
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x86.Build.0 = Release|Win32
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM.ActiveCfg = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM.Build.0 = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM64.ActiveCfg = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM64.Build.0 = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x64.ActiveCfg = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x64.Build.0 = Debug|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x86.ActiveCfg = Debug|Win32
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x86.Build.0 = Debug|Win32
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM.ActiveCfg = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM.Build.0 = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM64.ActiveCfg = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM64.Build.0 = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x64.ActiveCfg = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x64.Build.0 = Release|x64
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x86.ActiveCfg = Release|Win32
+		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 14 - 17
FactoryCraft/Animal.cpp

@@ -119,25 +119,19 @@ AnimalEntityTypeFactory::AnimalEntityTypeFactory()
     : SubTypeFactory()
 {}
 
-AnimalEntityType* AnimalEntityTypeFactory::createValue(
+AnimalEntityType* AnimalEntityTypeFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
     Framework::Text name = zJson->zValue("typeName")->asString()->getString();
     AnimalEntityType* result = new AnimalEntityType(name,
         Game::INSTANCE->zTypeRegistry()->fromJson<ModelInfo>(
             zJson->zValue("model")));
-    return result;
-}
-
-void AnimalEntityTypeFactory::fromJson(
-    AnimalEntityType* zResult, Framework::JSON::JSONObject* zJson) const
-{
     Framework::JSON::JSONArray* spawnsJson = zJson->zValue("spawns")->asArray();
     for (int i = 0; i < spawnsJson->getLength(); i++)
     {
         Framework::JSON::JSONObject* spawnJson
             = spawnsJson->zValue(i)->asObject();
-        zResult->spawns.add(SpawnConfig{
+        result->spawns.add(SpawnConfig{
             (int)spawnJson->zValue("min")->asNumber()->getNumber(),
             (int)spawnJson->zValue("max")->asNumber()->getNumber(),
             (float)spawnJson->zValue("chance")->asNumber()->getNumber(),
@@ -145,12 +139,14 @@ void AnimalEntityTypeFactory::fromJson(
             0,
         });
     }
-    zResult->ai = zJson->getValue("ai")->asObject();
+    result->ai = zJson->getValue("ai")->asObject();
+    return result;
 }
 
-void AnimalEntityTypeFactory::toJson(
-    AnimalEntityType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* AnimalEntityTypeFactory::toJsonObject(
+    AnimalEntityType* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* spawnsJson = new Framework::JSON::JSONArray();
     for (int i = 0; i < zObject->spawns.getEintragAnzahl(); i++)
     {
@@ -165,15 +161,16 @@ void AnimalEntityTypeFactory::toJson(
             "itemType", new Framework::JSON::JSONString(spawn.itemTypeName));
         spawnsJson->addValue(spawnJson);
     }
-    zResult->addValue("spawns", spawnsJson);
-    zResult->addValue(
+    result->addValue("spawns", spawnsJson);
+    result->addValue(
         "typeName", new Framework::JSON::JSONString(zObject->getName()));
-    zResult->addValue(
+    result->addValue(
         "model", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zModel()));
-    zResult->addValue("ai", zObject->ai->clone());
+    result->addValue("ai", zObject->ai->clone());
+    return result;
 }
 
-Framework::Text AnimalEntityTypeFactory::getTypeToken() const
+const char* AnimalEntityTypeFactory::getTypeToken() const
 {
     return "animal";
 }
@@ -183,7 +180,7 @@ JSONObjectValidationBuilder* AnimalEntityTypeFactory::addToValidator(
 {
     return builder
         ->withRequiredAttribute("spawns",
-            Framework::JSON::Validator::JSONValidator::buildForArray()
+            Framework::Validator::DataValidator::buildForArray()
                 ->addAcceptedObjectInArray()
                 ->withRequiredString("itemType")
                 ->finishString()

+ 4 - 6
FactoryCraft/Animal.h

@@ -57,13 +57,11 @@ class AnimalEntityTypeFactory
 {
 public:
     AnimalEntityTypeFactory();
-    AnimalEntityType* createValue(
+    AnimalEntityType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(AnimalEntityType* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(AnimalEntityType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
-    Framework::Text getTypeToken() const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        AnimalEntityType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
+    const char* getTypeToken() const override;
 };

+ 60 - 47
FactoryCraft/BasicBlocks.cpp

@@ -150,34 +150,36 @@ BasicBlockType* BasicBlockTypeFactory::createValue(
     return new BasicBlockType();
 }
 
-void BasicBlockTypeFactory::fromJson(
-    BasicBlockType* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setItemTypeName(
-        zJson->zValue("itemType")->asString()->getString());
-    zResult->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
-    zResult->setPassable(zJson->zValue("passable")->asBool()->getBool());
-    zResult->setSpeedModifier(
+BasicBlockType* BasicBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
+{
+    BasicBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
+    result->setItemTypeName(zJson->zValue("itemType")->asString()->getString());
+    result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
+    result->setPassable(zJson->zValue("passable")->asBool()->getBool());
+    result->setSpeedModifier(
         (float)zJson->zValue("speedModifier")->asNumber()->getNumber());
-    zResult->setInteractable(
+    result->setInteractable(
         (float)zJson->zValue("interactable")->asBool()->getBool());
-    BlockTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void BasicBlockTypeFactory::toJson(
-    BasicBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BasicBlockTypeFactory::toJsonObject(
+    BasicBlockType* zObject) const
 {
-    zResult->addValue("itemType",
+    Framework::JSON::JSONObject* result
+        = BlockTypeFactoryBase::toJsonObject(zObject);
+    result->addValue("itemType",
         new Framework::JSON::JSONString(zObject->getItemTypeName()));
-    zResult->addValue(
+    result->addValue(
         "transparent", new Framework::JSON::JSONBool(zObject->isTransparent()));
-    zResult->addValue(
+    result->addValue(
         "passable", new Framework::JSON::JSONBool(zObject->isPassable()));
-    zResult->addValue("speedModifier",
+    result->addValue("speedModifier",
         new Framework::JSON::JSONNumber(zObject->getSpeedModifier()));
-    zResult->addValue("interactable",
+    result->addValue("interactable",
         new Framework::JSON::JSONBool(zObject->isInteractable()));
-    BlockTypeFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* BasicBlockTypeFactory::addToValidator(
@@ -201,7 +203,7 @@ JSONObjectValidationBuilder* BasicBlockTypeFactory::addToValidator(
             ->finishBool());
 }
 
-Framework::Text BasicBlockTypeFactory::getTypeToken() const
+const char* BasicBlockTypeFactory::getTypeToken() const
 {
     return "basicBlock";
 }
@@ -302,26 +304,27 @@ AdditionalItemSpawningBlockType::getSpawns() const
 }
 
 AdditionalItemSpawningBlockTypeFactory::AdditionalItemSpawningBlockTypeFactory()
-    : BlockTypeFactoryBase()
+    : BasicBlockTypeFactory()
 {}
 
-AdditionalItemSpawningBlockType*
-AdditionalItemSpawningBlockTypeFactory::createValue(
+BasicBlockType* AdditionalItemSpawningBlockTypeFactory::createValue(
     Framework::JSON::JSONObject* zJson) const
 {
     return new AdditionalItemSpawningBlockType();
 }
 
-void AdditionalItemSpawningBlockTypeFactory::fromJson(
-    AdditionalItemSpawningBlockType* zResult,
+BasicBlockType* AdditionalItemSpawningBlockTypeFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
+    AdditionalItemSpawningBlockType* result
+        = dynamic_cast<AdditionalItemSpawningBlockType*>(
+            BasicBlockTypeFactory::fromJson(zJson));
     Framework::JSON::JSONArray* spawnsJson = zJson->zValue("spawns")->asArray();
     for (int i = 0; i < spawnsJson->getLength(); i++)
     {
         Framework::JSON::JSONObject* spawnJson
             = spawnsJson->zValue(i)->asObject();
-        zResult->addSpawn(SpawnConfig{
+        result->addSpawn(SpawnConfig{
             (int)spawnJson->zValue("min")->asNumber()->getNumber(),
             (int)spawnJson->zValue("max")->asNumber()->getNumber(),
             (float)spawnJson->zValue("chance")->asNumber()->getNumber(),
@@ -329,15 +332,19 @@ void AdditionalItemSpawningBlockTypeFactory::fromJson(
             0,
         });
     }
-    super.fromJson(zResult, zJson);
+    return result;
 }
 
-void AdditionalItemSpawningBlockTypeFactory::toJson(
-    AdditionalItemSpawningBlockType* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject*
+AdditionalItemSpawningBlockTypeFactory::toJsonObject(
+    BasicBlockType* zObject) const
 {
+    AdditionalItemSpawningBlockType* zType
+        = dynamic_cast<AdditionalItemSpawningBlockType*>(zObject);
+    Framework::JSON::JSONObject* result
+        = BasicBlockTypeFactory::toJsonObject(zObject);
     Framework::JSON::JSONArray* spawns = new Framework::JSON::JSONArray();
-    for (const SpawnConfig& config : zObject->getSpawns())
+    for (const SpawnConfig& config : zType->getSpawns())
     {
         Framework::JSON::JSONObject* spawn = new Framework::JSON::JSONObject();
         spawn->addValue(
@@ -348,30 +355,36 @@ void AdditionalItemSpawningBlockTypeFactory::toJson(
         spawn->addValue("max", new Framework::JSON::JSONNumber(config.max));
         spawns->addValue(spawn);
     }
-    zResult->addValue("spawns", spawns);
-    return super.toJson(zObject, zResult);
+    result->addValue("spawns", spawns);
+    return result;
 }
 
 JSONObjectValidationBuilder*
 AdditionalItemSpawningBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    return super.addToValidator(builder->withRequiredAttribute("spawns",
-        Framework::JSON::Validator::JSONValidator::buildForArray()
-            ->addAcceptedObjectInArray()
-            ->withRequiredString("itemType")
-            ->finishString()
-            ->withRequiredNumber("chance")
-            ->finishNumber()
-            ->withRequiredNumber("min")
-            ->finishNumber()
-            ->withRequiredNumber("max")
-            ->finishNumber()
-            ->finishObject()
-            ->finishArray()));
+    return BasicBlockTypeFactory::addToValidator(
+        builder->withRequiredAttribute("spawns",
+            Framework::Validator::DataValidator::buildForArray()
+                ->addAcceptedObjectInArray()
+                ->withRequiredString("itemType")
+                ->finishString()
+                ->withRequiredNumber("chance")
+                ->finishNumber()
+                ->withRequiredNumber("min")
+                ->finishNumber()
+                ->withRequiredNumber("max")
+                ->finishNumber()
+                ->finishObject()
+                ->finishArray()));
 }
 
-Framework::Text AdditionalItemSpawningBlockTypeFactory::getTypeToken() const
+const char* AdditionalItemSpawningBlockTypeFactory::getTypeToken() const
 {
     return "additionalItemsBlockType";
-}
+}
+
+const char* AdditionalItemSpawningBlockTypeFactory::getTypeName() const
+{
+    return typeid(AdditionalItemSpawningBlockType).name();
+}

+ 13 - 17
FactoryCraft/BasicBlocks.h

@@ -70,15 +70,15 @@ class BasicBlockTypeFactory : public BlockTypeFactoryBase<BasicBlockType>
 {
 public:
     BasicBlockTypeFactory();
-    BasicBlockType* createValue(
+    virtual BasicBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BasicBlockType* zResult,
+    virtual BasicBlockType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BasicBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
-    JSONObjectValidationBuilder* addToValidator(
+    virtual Framework::JSON::JSONObject* toJsonObject(
+        BasicBlockType* zObject) const override;
+    virtual JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    virtual const char* getTypeToken() const override;
 };
 
 class AdditionalItemSpawningBlock : public BasicBlock
@@ -112,21 +112,17 @@ public:
     const Framework::Array<SpawnConfig>& getSpawns() const;
 };
 
-class AdditionalItemSpawningBlockTypeFactory
-    : public BlockTypeFactoryBase<AdditionalItemSpawningBlockType>
+class AdditionalItemSpawningBlockTypeFactory : public BasicBlockTypeFactory
 {
-private:
-    BasicBlockTypeFactory super;
-
 public:
     AdditionalItemSpawningBlockTypeFactory();
-    AdditionalItemSpawningBlockType* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(AdditionalItemSpawningBlockType* zResult,
+    BasicBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(AdditionalItemSpawningBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BasicBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
+    const char* getTypeName() const override;
 };

+ 24 - 20
FactoryCraft/BasicItems.cpp

@@ -1,9 +1,9 @@
 #include "BasicItems.h"
 
+#include "Entity.h"
 #include "Game.h"
-#include "ModelInfo.h"
 #include "Item.h"
-#include "Entity.h"
+#include "ModelInfo.h"
 
 BasicItemType::BasicItemType()
     : ItemType(),
@@ -139,36 +139,40 @@ BasicItemType* BasicItemTypeFactory::createValue(
     return new BasicItemType();
 }
 
-void BasicItemTypeFactory::fromJson(
-    BasicItemType* zResult, Framework::JSON::JSONObject* zJson) const
+BasicItemType* BasicItemTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setItemName(
+    BasicItemType* result = ItemTypeFactoryBase::fromJson(zJson);
+    result->setItemName(
         Framework::Text(zJson->zValue("itemName")->asString()->getString()));
-    zResult->setHp((float)zJson->zValue("hp")->asNumber()->getNumber());
-    zResult->setDurability(
+    result->setHp((float)zJson->zValue("hp")->asNumber()->getNumber());
+    result->setDurability(
         (float)zJson->zValue("durability")->asNumber()->getNumber());
-    zResult->setSolid(zJson->zValue("solid")->asBool()->getBool());
-    zResult->setHungerRecoveryPerHp(
+    result->setSolid(zJson->zValue("solid")->asBool()->getBool());
+    result->setHungerRecoveryPerHp(
         (float)zJson->zValue("hungerRecoveryPerHp")->asNumber()->getNumber());
-    zResult->setThirstRecoveryPerHp(
+    result->setThirstRecoveryPerHp(
         (float)zJson->zValue("thirstRecoveryPerHp")->asNumber()->getNumber());
-    ItemTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void BasicItemTypeFactory::toJson(
-    BasicItemType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BasicItemTypeFactory::toJsonObject(
+    BasicItemType* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result
+        = ItemTypeFactoryBase::toJsonObject(zObject);
+    result->addValue(
         "itemName", new Framework::JSON::JSONString(zObject->getItemName()));
-    zResult->addValue("hp", new Framework::JSON::JSONNumber(zObject->getHp()));
-    zResult->addValue("durability",
+    result->addValue("hp", new Framework::JSON::JSONNumber(zObject->getHp()));
+    result->addValue("durability",
         new Framework::JSON::JSONNumber(zObject->getDurability()));
-    zResult->addValue(
+    result->addValue(
         "solid", new Framework::JSON::JSONBool(zObject->isSolid()));
-    zResult->addValue("hungerRecoveryPerHp",
+    result->addValue("hungerRecoveryPerHp",
         new Framework::JSON::JSONNumber(zObject->getHungerRecoveryPerHp()));
-    zResult->addValue("thirstRecoveryPerHp",
+    result->addValue("thirstRecoveryPerHp",
         new Framework::JSON::JSONNumber(zObject->getThirstRecoveryPerHp()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BasicItemTypeFactory::addToValidator(
@@ -198,7 +202,7 @@ JSONObjectValidationBuilder* BasicItemTypeFactory::addToValidator(
             ->finishNumber());
 }
 
-Framework::Text BasicItemTypeFactory::getTypeToken() const
+const char* BasicItemTypeFactory::getTypeToken() const
 {
     return "basic";
 }

+ 4 - 5
FactoryCraft/BasicItems.h

@@ -35,11 +35,10 @@ public:
     BasicItemTypeFactory();
     BasicItemType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BasicItemType* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BasicItemType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BasicItemType* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicItemType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 238 - 236
FactoryCraft/BasicTool.cpp

@@ -83,43 +83,41 @@ XPBasedLevelUpRuleFactory::XPBasedLevelUpRuleFactory()
     : SubTypeFactory()
 {}
 
-XPBasedLevelUpRule* XPBasedLevelUpRuleFactory::createValue(
+XPBasedLevelUpRule* XPBasedLevelUpRuleFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new XPBasedLevelUpRule();
-}
-
-void XPBasedLevelUpRuleFactory::fromJson(
-    XPBasedLevelUpRule* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    XPBasedLevelUpRule* result = new XPBasedLevelUpRule();
     if (zJson->hasValue("maxLevel"))
     {
-        zResult->setMaxLevel(
+        result->setMaxLevel(
             (float)zJson->zValue("maxLevel")->asNumber()->getNumber());
     }
-    zResult->setXpIncrease(
+    result->setXpIncrease(
         (float)zJson->zValue("xpIncrease")->asNumber()->getNumber());
-    zResult->setXpMultiplier(
+    result->setXpMultiplier(
         (float)zJson->zValue("xpMultiplier")->asNumber()->getNumber());
-    zResult->setLevelIncrease(
+    result->setLevelIncrease(
         (float)zJson->zValue("levelIncrease")->asNumber()->getNumber());
-    zResult->setLevelMultiplier(
+    result->setLevelMultiplier(
         (float)zJson->zValue("levelMultiplier")->asNumber()->getNumber());
+    return result;
 }
 
-void XPBasedLevelUpRuleFactory::toJson(
-    XPBasedLevelUpRule* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* XPBasedLevelUpRuleFactory::toJsonObject(
+    XPBasedLevelUpRule* zObject) const
 {
-    zResult->addValue("xpIncrease",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("xpIncrease",
         new Framework::JSON::JSONNumber(zObject->getXpIncrease()));
-    zResult->addValue("xpMultiplier",
+    result->addValue("xpMultiplier",
         new Framework::JSON::JSONNumber(zObject->getXpMultiplier()));
-    zResult->addValue("levelIncrease",
+    result->addValue("levelIncrease",
         new Framework::JSON::JSONNumber(zObject->getLevelIncrease()));
-    zResult->addValue("levelMultiplier",
+    result->addValue("levelMultiplier",
         new Framework::JSON::JSONNumber(zObject->getLevelMultiplier()));
-    zResult->addValue(
+    result->addValue(
         "maxLevel", new Framework::JSON::JSONNumber(zObject->getMaxLevel()));
+    return result;
 }
 
 JSONObjectValidationBuilder* XPBasedLevelUpRuleFactory::addToValidator(
@@ -146,7 +144,7 @@ JSONObjectValidationBuilder* XPBasedLevelUpRuleFactory::addToValidator(
         ->finishNumber();
 }
 
-Framework::Text XPBasedLevelUpRuleFactory::getTypeToken() const
+const char* XPBasedLevelUpRuleFactory::getTypeToken() const
 {
     return "xpBased";
 }
@@ -290,17 +288,17 @@ void BasicToolItemType::setItemAttribute(
 {
     BasicToolItem* item = dynamic_cast<BasicToolItem*>(zItem);
     if (name.istGleich("headMaterialHardness")
-        && zValue->getType() == Framework::JSON::JSONType::NUMBER)
+        && zValue->getType() == Framework::AbstractType::NUMBER)
     {
         item->setHeadMaterialHardness((float)zValue->asNumber()->getNumber());
     }
     else if (name.istGleich("rodMaterialHardness")
-             && zValue->getType() == Framework::JSON::JSONType::NUMBER)
+             && zValue->getType() == Framework::AbstractType::NUMBER)
     {
         item->setRodMaterialHardness((float)zValue->asNumber()->getNumber());
     }
     else if (name.istGleich("handleMaterialHardness")
-             && zValue->getType() == Framework::JSON::JSONType::NUMBER)
+             && zValue->getType() == Framework::AbstractType::NUMBER)
     {
         item->setHandleMaterialHardness((float)zValue->asNumber()->getNumber());
     }
@@ -494,90 +492,93 @@ BasicToolItemType* BasicToolItemTypeFactory::createValue(
     return new BasicToolItemType();
 }
 
-void BasicToolItemTypeFactory::fromJson(
-    BasicToolItemType* zResult, Framework::JSON::JSONObject* zJson) const
+BasicToolItemType* BasicToolItemTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setHandleMaterialHardness(
+    BasicToolItemType* result = ItemTypeFactoryBase::fromJson(zJson);
+    result->setHandleMaterialHardness(
         (float)zJson->zValue("headMaterialHardness")->asNumber()->getNumber());
-    zResult->setRodMaterialHardness(
+    result->setRodMaterialHardness(
         (float)zJson->zValue("rodMaterialHardness")->asNumber()->getNumber());
-    zResult->setHandleMaterialHardness(
+    result->setHandleMaterialHardness(
         (float)zJson->zValue("handleMaterialHardness")
             ->asNumber()
             ->getNumber());
-    zResult->setBaseDurability(
+    result->setBaseDurability(
         (float)zJson->zValue("baseDurability")->asNumber()->getNumber());
-    zResult->setBaseDurabilityMultiplier(
+    result->setBaseDurabilityMultiplier(
         (float)zJson->zValue("baseDurabilityMultiplier")
             ->asNumber()
             ->getNumber());
-    zResult->setHeadMaterialDurability(
+    result->setHeadMaterialDurability(
         (float)zJson->zValue("headMaterialDurability")
             ->asNumber()
             ->getNumber());
-    zResult->setHeadMaterialDurabilityMultiplier(
+    result->setHeadMaterialDurabilityMultiplier(
         (float)zJson->zValue("headMaterialDurabilityMultiplier")
             ->asNumber()
             ->getNumber());
-    zResult->setRodMaterialDurability(
+    result->setRodMaterialDurability(
         (float)zJson->zValue("rodMaterialDurability")->asNumber()->getNumber());
-    zResult->setRodMaterialDurabilityMultiplier(
+    result->setRodMaterialDurabilityMultiplier(
         (float)zJson->zValue("rodMaterialDurabilityMultiplier")
             ->asNumber()
             ->getNumber());
-    zResult->setHandleMaterialDurability(
+    result->setHandleMaterialDurability(
         (float)zJson->zValue("handleMaterialDurability")
             ->asNumber()
             ->getNumber());
-    zResult->setHandleMaterialDurabilityMultiplier(
+    result->setHandleMaterialDurabilityMultiplier(
         (float)zJson->zValue("handleMaterialDurabilityMultiplier")
             ->asNumber()
             ->getNumber());
-    zResult->setLevelUpRule(
+    result->setLevelUpRule(
         Game::INSTANCE->zTypeRegistry()->fromJson<ItemSkillLevelUpRule>(
             zJson->zValue("levelUpRule")));
-    zResult->setBrokenItemTypeName(
+    result->setBrokenItemTypeName(
         zJson->zValue("brokenItemTypeName")->asString()->getString());
-    zResult->setItemSkillConfigJson(zJson->getValue("itemSkill")->asObject());
-    ItemTypeFactoryBase::fromJson(zResult, zJson);
+    result->setItemSkillConfigJson(zJson->getValue("itemSkill")->asObject());
+    return result;
 }
 
-void BasicToolItemTypeFactory::toJson(
-    BasicToolItemType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BasicToolItemTypeFactory::toJsonObject(
+    BasicToolItemType* zObject) const
 {
-    zResult->addValue("headMaterialHardness",
+    Framework::JSON::JSONObject* result
+        = ItemTypeFactoryBase::toJsonObject(zObject);
+    result->addValue("headMaterialHardness",
         new Framework::JSON::JSONNumber(zObject->getHeadMaterialHardness()));
-    zResult->addValue("rodMaterialHardness",
+    result->addValue("rodMaterialHardness",
         new Framework::JSON::JSONNumber(zObject->getRodMaterialHardness()));
-    zResult->addValue("handleMaterialHardness",
+    result->addValue("handleMaterialHardness",
         new Framework::JSON::JSONNumber(zObject->getHandleMaterialHardness()));
-    zResult->addValue("baseDurability",
+    result->addValue("baseDurability",
         new Framework::JSON::JSONNumber(zObject->getBaseDurablility()));
-    zResult->addValue("baseDurabilityMultiplier",
+    result->addValue("baseDurabilityMultiplier",
         new Framework::JSON::JSONNumber(
             zObject->getBaseDurabilityMultiplier()));
-    zResult->addValue("headMaterialDurability",
+    result->addValue("headMaterialDurability",
         new Framework::JSON::JSONNumber(zObject->getHeadMaterialDurability()));
-    zResult->addValue("headMaterialDurabilityMultiplier",
+    result->addValue("headMaterialDurabilityMultiplier",
         new Framework::JSON::JSONNumber(
             zObject->getHeadMaterialDurabilityMultiplier()));
-    zResult->addValue("rodMaterialDurability",
+    result->addValue("rodMaterialDurability",
         new Framework::JSON::JSONNumber(zObject->getRodMaterialDurability()));
-    zResult->addValue("rodMaterialDurabilityMultiplier",
+    result->addValue("rodMaterialDurabilityMultiplier",
         new Framework::JSON::JSONNumber(
             zObject->getRodMaterialDurabilityMultiplier()));
-    zResult->addValue("handleMaterialDurability",
+    result->addValue("handleMaterialDurability",
         new Framework::JSON::JSONNumber(
             zObject->getHandleMaterialDurability()));
-    zResult->addValue("handleMaterialDurabilityMultiplier",
+    result->addValue("handleMaterialDurabilityMultiplier",
         new Framework::JSON::JSONNumber(
             zObject->getHandleMaterialDurabilityMultiplier()));
-    zResult->addValue("levelUpRule",
+    result->addValue("levelUpRule",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zLevelUpRule()));
-    zResult->addValue("brokenItemTypeName",
+    result->addValue("brokenItemTypeName",
         new Framework::JSON::JSONString(zObject->zBrokenItemType()->getName()));
-    zResult->addValue("itemSkill", zObject->getItemSkillConfigJson());
-    ItemTypeFactoryBase::toJson(zObject, zResult);
+    result->addValue("itemSkill", zObject->getItemSkillConfigJson());
+    return result;
 }
 
 JSONObjectValidationBuilder* BasicToolItemTypeFactory::addToValidator(
@@ -637,7 +638,7 @@ JSONObjectValidationBuilder* BasicToolItemTypeFactory::addToValidator(
                 Game::INSTANCE->zTypeRegistry()->getValidator<ItemSkill>()));
 }
 
-Framework::Text BasicToolItemTypeFactory::getTypeToken() const
+const char* BasicToolItemTypeFactory::getTypeToken() const
 {
     return "tool";
 }
@@ -772,93 +773,89 @@ float BlockReplaceItemSkillConfig::getXpGain() const
 }
 
 BlockReplaceItemSkillConfigFactory::BlockReplaceItemSkillConfigFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-BlockReplaceItemSkillConfig* BlockReplaceItemSkillConfigFactory::createValue(
-    Framework::JSON::JSONObject* zJson) const
-{
-    return new BlockReplaceItemSkillConfig();
-}
-
-void BlockReplaceItemSkillConfigFactory::fromJson(
-    BlockReplaceItemSkillConfig* zResult,
+BlockReplaceItemSkillConfig* BlockReplaceItemSkillConfigFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setTargetBlockFilter(
+    BlockReplaceItemSkillConfig* result = new BlockReplaceItemSkillConfig();
+    result->setTargetBlockFilter(
         Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
             zJson->asObject()->zValue("targetFilter")));
-    zResult->setCooldownTicks((int)zJson->asObject()
-                                  ->zValue("cooldownTicks")
-                                  ->asNumber()
-                                  ->getNumber());
-    zResult->setReplacementBlockTypeId(
+    result->setCooldownTicks((int)zJson->asObject()
+                                 ->zValue("cooldownTicks")
+                                 ->asNumber()
+                                 ->getNumber());
+    result->setReplacementBlockTypeId(
         Game::INSTANCE->getBlockTypeId(zJson->asObject()
                                            ->zValue("replacementBlockType")
                                            ->asString()
                                            ->getString()));
-    zResult->setCooldownTicks((int)zJson->asObject()
-                                  ->zValue("cooldownTicks")
-                                  ->asNumber()
-                                  ->getNumber());
-    zResult->setStaminaCost((float)zJson->asObject()
-                                ->zValue("staminaCost")
-                                ->asNumber()
-                                ->getNumber());
-    zResult->setStaminaCostDevider((float)zJson->asObject()
-                                       ->zValue("staminaCostDevider")
-                                       ->asNumber()
-                                       ->getNumber());
-    zResult->setAdditionalStaminaCostDeviderPerLevel(
+    result->setCooldownTicks((int)zJson->asObject()
+                                 ->zValue("cooldownTicks")
+                                 ->asNumber()
+                                 ->getNumber());
+    result->setStaminaCost((float)zJson->asObject()
+                               ->zValue("staminaCost")
+                               ->asNumber()
+                               ->getNumber());
+    result->setStaminaCostDevider((float)zJson->asObject()
+                                      ->zValue("staminaCostDevider")
+                                      ->asNumber()
+                                      ->getNumber());
+    result->setAdditionalStaminaCostDeviderPerLevel(
         (float)zJson->asObject()
             ->zValue("additionalStaminaCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setDurabilityCost((float)zJson->asObject()
-                                   ->zValue("durabilityCost")
-                                   ->asNumber()
-                                   ->getNumber());
-    zResult->setDurabilityCostDevider((float)zJson->asObject()
-                                          ->zValue("durabilityCostDevider")
-                                          ->asNumber()
-                                          ->getNumber());
-    zResult->setAdditionalDurabilityCostDeviderPerLevel(
+    result->setDurabilityCost((float)zJson->asObject()
+                                  ->zValue("durabilityCost")
+                                  ->asNumber()
+                                  ->getNumber());
+    result->setDurabilityCostDevider((float)zJson->asObject()
+                                         ->zValue("durabilityCostDevider")
+                                         ->asNumber()
+                                         ->getNumber());
+    result->setAdditionalDurabilityCostDeviderPerLevel(
         (float)zJson->asObject()
             ->zValue("additionalDurabilityCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setXpGain(
+    result->setXpGain(
         (float)zJson->asObject()->zValue("xpGain")->asNumber()->getNumber());
+    return result;
 }
 
-void BlockReplaceItemSkillConfigFactory::toJson(
-    BlockReplaceItemSkillConfig* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockReplaceItemSkillConfigFactory::toJsonObject(
+    BlockReplaceItemSkillConfig* zObject) const
 {
-    zResult->addValue("targetFilter",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("targetFilter",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zTargetBlockFilter()));
-    zResult->addValue("replacementBlockType",
+    result->addValue("replacementBlockType",
         new Framework::JSON::JSONString(
             Game::INSTANCE->zBlockType(zObject->getReplacementBlockTypeId())
                 ->getName()));
-    zResult->addValue("cooldownTicks",
+    result->addValue("cooldownTicks",
         new Framework::JSON::JSONNumber(zObject->getCooldownTicks()));
-    zResult->addValue("staminaCost",
+    result->addValue("staminaCost",
         new Framework::JSON::JSONNumber(zObject->getStaminaCost()));
-    zResult->addValue("staminaCostDevider",
+    result->addValue("staminaCostDevider",
         new Framework::JSON::JSONNumber(zObject->getStaminaCostDevider()));
-    zResult->addValue("additionalStaminaCostDeviderPerLevel",
+    result->addValue("additionalStaminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getAdditionalStaminaCostDeviderPerLevel()));
-    zResult->addValue("durabilityCost",
+    result->addValue("durabilityCost",
         new Framework::JSON::JSONNumber(zObject->getDurabilityCost()));
-    zResult->addValue("durabilityCostDevider",
+    result->addValue("durabilityCostDevider",
         new Framework::JSON::JSONNumber(zObject->getDurabilityCostDevider()));
-    zResult->addValue("additionalDurabilityCostDeviderPerLevel",
+    result->addValue("additionalDurabilityCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getAdditionalDurabilityCostDeviderPerLevel()));
-    zResult->addValue(
+    result->addValue(
         "xpGain", new Framework::JSON::JSONNumber(zObject->getXpGain()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockReplaceItemSkillConfigFactory::addToValidator(
@@ -1034,9 +1031,10 @@ BlockReplaceItemSkill* BlockReplaceItemSkillFactory::createValue(
     return new BlockReplaceItemSkill();
 }
 
-void BlockReplaceItemSkillFactory::fromJson(
-    BlockReplaceItemSkill* zResult, Framework::JSON::JSONObject* zJson) const
+BlockReplaceItemSkill* BlockReplaceItemSkillFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    BlockReplaceItemSkill* result = ItemSkillFactoryBase::fromJson(zJson);
     BlockReplaceItemSkillConfig* invalidUseConfig
         = new BlockReplaceItemSkillConfig();
     invalidUseConfig->setStaminaCost(
@@ -1062,41 +1060,43 @@ void BlockReplaceItemSkillFactory::fromJson(
     invalidUseConfig->setCooldownTicks(
         (int)zJson->zValue("invalidCooldownTicks")->asNumber()->getNumber());
     invalidUseConfig->setXpGain(0.f);
-    zResult->setInvalidUseConfig(invalidUseConfig);
+    result->setInvalidUseConfig(invalidUseConfig);
     Framework::RCArray<BlockReplaceItemSkillConfig> configs;
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("configs")->asArray())
     {
-        zResult->addConfig(Game::INSTANCE->zTypeRegistry()
-                               ->fromJson<BlockReplaceItemSkillConfig>(value));
+        result->addConfig(Game::INSTANCE->zTypeRegistry()
+                              ->fromJson<BlockReplaceItemSkillConfig>(value));
     }
-    ItemSkillFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void BlockReplaceItemSkillFactory::toJson(
-    BlockReplaceItemSkill* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockReplaceItemSkillFactory::toJsonObject(
+    BlockReplaceItemSkill* zObject) const
 {
-    zResult->addValue("invalidStaminaCost",
+    Framework::JSON::JSONObject* result
+        = ItemSkillFactoryBase::toJsonObject(zObject);
+    result->addValue("invalidStaminaCost",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCost()));
-    zResult->addValue("invalidStaminaCostDevider",
+    result->addValue("invalidStaminaCostDevider",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostDevider()));
-    zResult->addValue("invalidAdditionalStaminaCostDeviderPerLevel",
+    result->addValue("invalidAdditionalStaminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()
                 ->getAdditionalStaminaCostDeviderPerLevel()));
-    zResult->addValue("invalidDurabilityCost",
+    result->addValue("invalidDurabilityCost",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getDurabilityCost()));
-    zResult->addValue("invalidDurabilityCostDevider",
+    result->addValue("invalidDurabilityCostDevider",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getDurabilityCostDevider()));
-    zResult->addValue("invalidAdditionalDurabilityCostDeviderPerLevel",
+    result->addValue("invalidAdditionalDurabilityCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()
                 ->getAdditionalDurabilityCostDeviderPerLevel()));
-    zResult->addValue("invalidCooldownTicks",
+    result->addValue("invalidCooldownTicks",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getCooldownTicks()));
     Framework::JSON::JSONArray* configs = new Framework::JSON::JSONArray();
@@ -1104,8 +1104,8 @@ void BlockReplaceItemSkillFactory::toJson(
     {
         configs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(config));
     }
-    zResult->addValue("configs", configs);
-    ItemSkillFactoryBase::toJson(zObject, zResult);
+    result->addValue("configs", configs);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockReplaceItemSkillFactory::addToValidator(
@@ -1147,7 +1147,7 @@ JSONObjectValidationBuilder* BlockReplaceItemSkillFactory::addToValidator(
             ->finishArray());
 }
 
-Framework::Text BlockReplaceItemSkillFactory::getTypeToken() const
+const char* BlockReplaceItemSkillFactory::getTypeToken() const
 {
     return "replaceBlock";
 }
@@ -1398,152 +1398,148 @@ float DamagingItemSkillConfig::getXpGainPerDamage() const
 }
 
 DamagingItemSkillConfigFactory::DamagingItemSkillConfigFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-DamagingItemSkillConfig* DamagingItemSkillConfigFactory::createValue(
+DamagingItemSkillConfig* DamagingItemSkillConfigFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new DamagingItemSkillConfig();
-}
-
-void DamagingItemSkillConfigFactory::fromJson(
-    DamagingItemSkillConfig* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setTargetBlockFilter(
+    DamagingItemSkillConfig* result = new DamagingItemSkillConfig();
+    result->setTargetBlockFilter(
         Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
             zJson->zValue("targetFilter")));
-    zResult->setDamage(
+    result->setDamage(
         (float)zJson->asObject()->zValue("damage")->asNumber()->getNumber());
-    zResult->setDamagePerHeadHardness((float)zJson->asObject()
-                                          ->zValue("damagePerHeadHardness")
-                                          ->asNumber()
-                                          ->getNumber());
-    zResult->setBaseDamageMultiplier((float)zJson->asObject()
-                                         ->zValue("baseDamageMultiplier")
+    result->setDamagePerHeadHardness((float)zJson->asObject()
+                                         ->zValue("damagePerHeadHardness")
                                          ->asNumber()
                                          ->getNumber());
-    zResult->setDamageMultiplierPerHeadHardness(
+    result->setBaseDamageMultiplier((float)zJson->asObject()
+                                        ->zValue("baseDamageMultiplier")
+                                        ->asNumber()
+                                        ->getNumber());
+    result->setDamageMultiplierPerHeadHardness(
         (float)zJson->asObject()
             ->zValue("damageMultiplierPerHeadHardness")
             ->asNumber()
             ->getNumber());
-    zResult->setDamagePerLevel((float)zJson->asObject()
-                                   ->zValue("damagePerLevel")
-                                   ->asNumber()
-                                   ->getNumber());
-    zResult->setDamageMultiplierPerLevel(
-        (float)zJson->asObject()
-            ->zValue("damageMultiplierPerLevel")
-            ->asNumber()
-            ->getNumber());
-    zResult->setDamageDevider((float)zJson->asObject()
-                                  ->zValue("damageDevider")
+    result->setDamagePerLevel((float)zJson->asObject()
+                                  ->zValue("damagePerLevel")
                                   ->asNumber()
                                   ->getNumber());
-    zResult->setDamageDeviderPerHardness(
+    result->setDamageMultiplierPerLevel((float)zJson->asObject()
+                                            ->zValue("damageMultiplierPerLevel")
+                                            ->asNumber()
+                                            ->getNumber());
+    result->setDamageDevider((float)zJson->asObject()
+                                 ->zValue("damageDevider")
+                                 ->asNumber()
+                                 ->getNumber());
+    result->setDamageDeviderPerHardness((float)zJson->asObject()
+                                            ->zValue("damageDeviderPerHardness")
+                                            ->asNumber()
+                                            ->getNumber());
+    result->setStaminaCost((float)zJson->asObject()
+                               ->zValue("staminaCost")
+                               ->asNumber()
+                               ->getNumber());
+    result->setStaminaCostPerDamage((float)zJson->asObject()
+                                        ->zValue("staminaCostPerDamage")
+                                        ->asNumber()
+                                        ->getNumber());
+    result->setStaminaCostPerHardness((float)zJson->asObject()
+                                          ->zValue("staminaCostPerHardness")
+                                          ->asNumber()
+                                          ->getNumber());
+    result->setStaminaCostDevider((float)zJson->asObject()
+                                      ->zValue("staminaCostDevider")
+                                      ->asNumber()
+                                      ->getNumber());
+    result->setStaminaCostDeviderPerLevel(
         (float)zJson->asObject()
-            ->zValue("damageDeviderPerHardness")
+            ->zValue("staminaCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setStaminaCost((float)zJson->asObject()
-                                ->zValue("staminaCost")
-                                ->asNumber()
-                                ->getNumber());
-    zResult->setStaminaCostPerDamage((float)zJson->asObject()
-                                         ->zValue("staminaCostPerDamage")
-                                         ->asNumber()
-                                         ->getNumber());
-    zResult->setStaminaCostPerHardness((float)zJson->asObject()
-                                           ->zValue("staminaCostPerHardness")
+    result->setDurabilityCost((float)zJson->asObject()
+                                  ->zValue("durabilityCost")
+                                  ->asNumber()
+                                  ->getNumber());
+    result->setDurabilityCostPerDamage((float)zJson->asObject()
+                                           ->zValue("durabilityCostPerDamage")
                                            ->asNumber()
                                            ->getNumber());
-    zResult->setStaminaCostDevider((float)zJson->asObject()
-                                       ->zValue("staminaCostDevider")
-                                       ->asNumber()
-                                       ->getNumber());
-    zResult->setStaminaCostDeviderPerLevel(
-        (float)zJson->asObject()
-            ->zValue("staminaCostDeviderPerLevel")
-            ->asNumber()
-            ->getNumber());
-    zResult->setDurabilityCost((float)zJson->asObject()
-                                   ->zValue("durabilityCost")
-                                   ->asNumber()
-                                   ->getNumber());
-    zResult->setDurabilityCostPerDamage((float)zJson->asObject()
-                                            ->zValue("durabilityCostPerDamage")
-                                            ->asNumber()
-                                            ->getNumber());
-    zResult->setDurabilityCostPerHardness(
+    result->setDurabilityCostPerHardness(
         (float)zJson->asObject()
             ->zValue("durabilityCostPerHardness")
             ->asNumber()
             ->getNumber());
-    zResult->setDurabilityCostDevider((float)zJson->asObject()
-                                          ->zValue("durabilityCostDevider")
-                                          ->asNumber()
-                                          ->getNumber());
-    zResult->setAdditionalDurabilityCostDeviderPerLevel(
+    result->setDurabilityCostDevider((float)zJson->asObject()
+                                         ->zValue("durabilityCostDevider")
+                                         ->asNumber()
+                                         ->getNumber());
+    result->setAdditionalDurabilityCostDeviderPerLevel(
         (float)zJson->asObject()
             ->zValue("additionalDurabilityCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setXpGainPerDamage((float)zJson->asObject()
-                                    ->zValue("xpGainPerDamage")
-                                    ->asNumber()
-                                    ->getNumber());
+    result->setXpGainPerDamage((float)zJson->asObject()
+                                   ->zValue("xpGainPerDamage")
+                                   ->asNumber()
+                                   ->getNumber());
+    return result;
 }
 
-void DamagingItemSkillConfigFactory::toJson(DamagingItemSkillConfig* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* DamagingItemSkillConfigFactory::toJsonObject(
+    DamagingItemSkillConfig* zObject) const
 {
-    zResult->addValue("targetFilter",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("targetFilter",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zTargetBlockFilter()));
-    zResult->addValue(
+    result->addValue(
         "damage", new Framework::JSON::JSONNumber(zObject->getDamage()));
-    zResult->addValue("damagePerHeadHardness",
+    result->addValue("damagePerHeadHardness",
         new Framework::JSON::JSONNumber(zObject->getDamagePerHeadHardness()));
-    zResult->addValue("baseDamageMultiplier",
+    result->addValue("baseDamageMultiplier",
         new Framework::JSON::JSONNumber(zObject->getBaseDamageMultiplier()));
-    zResult->addValue("damageMultiplierPerHeadHardness",
+    result->addValue("damageMultiplierPerHeadHardness",
         new Framework::JSON::JSONNumber(
             zObject->getDamageMultiplierPerHeadHardness()));
-    zResult->addValue("damagePerLevel",
+    result->addValue("damagePerLevel",
         new Framework::JSON::JSONNumber(zObject->getDamagePerLevel()));
-    zResult->addValue("damageMultiplierPerLevel",
+    result->addValue("damageMultiplierPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getDamageMultiplierPerLevel()));
-    zResult->addValue("damageDevider",
+    result->addValue("damageDevider",
         new Framework::JSON::JSONNumber(zObject->getDamageDevider()));
-    zResult->addValue("damageDeviderPerHardness",
+    result->addValue("damageDeviderPerHardness",
         new Framework::JSON::JSONNumber(
             zObject->getDamageDeviderPerHardness()));
-    zResult->addValue("staminaCost",
+    result->addValue("staminaCost",
         new Framework::JSON::JSONNumber(zObject->getStaminaCost()));
-    zResult->addValue("staminaCostPerDamage",
+    result->addValue("staminaCostPerDamage",
         new Framework::JSON::JSONNumber(zObject->getStaminaCostPerDamage()));
-    zResult->addValue("staminaCostPerHardness",
+    result->addValue("staminaCostPerHardness",
         new Framework::JSON::JSONNumber(zObject->getStaminaCostPerHardness()));
-    zResult->addValue("staminaCostDevider",
+    result->addValue("staminaCostDevider",
         new Framework::JSON::JSONNumber(zObject->getStaminaCostDevider()));
-    zResult->addValue("staminaCostDeviderPerLevel",
+    result->addValue("staminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getStaminaCostDeviderPerLevel()));
-    zResult->addValue("durabilityCost",
+    result->addValue("durabilityCost",
         new Framework::JSON::JSONNumber(zObject->getDurabilityCost()));
-    zResult->addValue("durabilityCostPerDamage",
+    result->addValue("durabilityCostPerDamage",
         new Framework::JSON::JSONNumber(zObject->getDurabilityCostPerDamage()));
-    zResult->addValue("durabilityCostPerHardness",
+    result->addValue("durabilityCostPerHardness",
         new Framework::JSON::JSONNumber(
             zObject->getDurabilityCostPerHardness()));
-    zResult->addValue("durabilityCostDevider",
+    result->addValue("durabilityCostDevider",
         new Framework::JSON::JSONNumber(zObject->getDurabilityCostDevider()));
-    zResult->addValue("additionalDurabilityCostDeviderPerLevel",
+    result->addValue("additionalDurabilityCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getAdditionalDurabilityCostDeviderPerLevel()));
-    zResult->addValue("xpGainPerDamage",
+    result->addValue("xpGainPerDamage",
         new Framework::JSON::JSONNumber(zObject->getXpGainPerDamage()));
+    return result;
 }
 
 JSONObjectValidationBuilder* DamagingItemSkillConfigFactory::addToValidator(
@@ -1704,7 +1700,10 @@ bool DamagingItemSkill::use(Entity* zActor, Item* zUsedItem, Block* zTarget)
     {
         durabilityCost /= durabilityDevider;
     }
-    zUsedItem->setDurability(zUsedItem->getDurability() - durabilityCost);
+    if (zUsedItem)
+    {
+        zUsedItem->setDurability(zUsedItem->getDurability() - durabilityCost);
+    }
     zActor->setStamina(zActor->getStamina() - staminaCost);
     setXp(getXp() + usedConfig->getXpGainPerDamage() * damage);
     zTarget->setHP(zTarget->getHP() - damage);
@@ -1748,13 +1747,14 @@ DamagingItemSkill* DamagingItemSkillFactory::createValue(
     return new DamagingItemSkill();
 }
 
-void DamagingItemSkillFactory::fromJson(
-    DamagingItemSkill* zResult, Framework::JSON::JSONObject* zJson) const
+DamagingItemSkill* DamagingItemSkillFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    DamagingItemSkill* result = ItemSkillFactoryBase::fromJson(zJson);
     for (Framework::JSON::JSONValue* configValue :
         *zJson->zValue("configs")->asArray())
     {
-        zResult->addConfig(
+        result->addConfig(
             Game::INSTANCE->zTypeRegistry()->fromJson<DamagingItemSkillConfig>(
                 configValue));
     }
@@ -1796,37 +1796,39 @@ void DamagingItemSkillFactory::fromJson(
         (float)zJson->zValue("invalidDurabilityCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setInvalidUseConfig(invalidUseConfig);
-    ItemSkillFactoryBase::fromJson(zResult, zJson);
+    result->setInvalidUseConfig(invalidUseConfig);
+    return result;
 }
 
-void DamagingItemSkillFactory::toJson(
-    DamagingItemSkill* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* DamagingItemSkillFactory::toJsonObject(
+    DamagingItemSkill* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result
+        = ItemSkillFactoryBase::toJsonObject(zObject);
+    result->addValue(
         "maxXp", new Framework::JSON::JSONNumber(zObject->getMaxXp()));
-    zResult->addValue("invalidStaminaCost",
+    result->addValue("invalidStaminaCost",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCost()));
-    zResult->addValue("invalidStaminaCostPerHardness",
+    result->addValue("invalidStaminaCostPerHardness",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostPerHardness()));
-    zResult->addValue("invalidStaminaCostDevider",
+    result->addValue("invalidStaminaCostDevider",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostDevider()));
-    zResult->addValue("invalidStaminaCostDeviderPerLevel",
+    result->addValue("invalidStaminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostDeviderPerLevel()));
-    zResult->addValue("invalidDurabilityCost",
+    result->addValue("invalidDurabilityCost",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getDurabilityCost()));
-    zResult->addValue("invalidDurabilityCostPerHardness",
+    result->addValue("invalidDurabilityCostPerHardness",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getDurabilityCostPerHardness()));
-    zResult->addValue("invalidDurabilityCostDevider",
+    result->addValue("invalidDurabilityCostDevider",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getDurabilityCostDevider()));
-    zResult->addValue("invalidDurabilityCostDeviderPerLevel",
+    result->addValue("invalidDurabilityCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()
                 ->getAdditionalDurabilityCostDeviderPerLevel()));
@@ -1835,8 +1837,8 @@ void DamagingItemSkillFactory::toJson(
     {
         configs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(config));
     }
-    zResult->addValue("configs", configs);
-    ItemSkillFactoryBase::toJson(zObject, zResult);
+    result->addValue("configs", configs);
+    return result;
 }
 
 JSONObjectValidationBuilder* DamagingItemSkillFactory::addToValidator(
@@ -1883,7 +1885,7 @@ JSONObjectValidationBuilder* DamagingItemSkillFactory::addToValidator(
             ->finishArray());
 }
 
-Framework::Text DamagingItemSkillFactory::getTypeToken() const
+const char* DamagingItemSkillFactory::getTypeToken() const
 {
     return "damaging";
 }

+ 25 - 32
FactoryCraft/BasicTool.h

@@ -36,15 +36,13 @@ class XPBasedLevelUpRuleFactory
 {
 public:
     XPBasedLevelUpRuleFactory();
-    XPBasedLevelUpRule* createValue(
+    XPBasedLevelUpRule* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(XPBasedLevelUpRule* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(XPBasedLevelUpRule* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        XPBasedLevelUpRule* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BasicToolItem : public Item
@@ -141,13 +139,13 @@ public:
     BasicToolItemTypeFactory();
     BasicToolItemType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BasicToolItemType* zResult,
+    BasicToolItemType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BasicToolItemType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicToolItemType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockReplaceItemSkillConfig : public Framework::ReferenceCounter
@@ -192,16 +190,14 @@ public:
 };
 
 class BlockReplaceItemSkillConfigFactory
-    : public TypeFactory<BlockReplaceItemSkillConfig>
+    : public ObjectTypeFactory<BlockReplaceItemSkillConfig>
 {
 public:
     BlockReplaceItemSkillConfigFactory();
-    BlockReplaceItemSkillConfig* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockReplaceItemSkillConfig* zResult,
+    BlockReplaceItemSkillConfig* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockReplaceItemSkillConfig* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockReplaceItemSkillConfig* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -235,13 +231,13 @@ public:
     BlockReplaceItemSkillFactory();
     BlockReplaceItemSkill* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockReplaceItemSkill* zResult,
+    BlockReplaceItemSkill* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockReplaceItemSkill* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockReplaceItemSkill* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class DamagingItemSkillConfig : public Framework::ReferenceCounter
@@ -316,16 +312,14 @@ public:
 };
 
 class DamagingItemSkillConfigFactory
-    : public TypeFactory<DamagingItemSkillConfig>
+    : public ObjectTypeFactory<DamagingItemSkillConfig>
 {
 public:
     DamagingItemSkillConfigFactory();
-    DamagingItemSkillConfig* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(DamagingItemSkillConfig* zResult,
+    DamagingItemSkillConfig* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(DamagingItemSkillConfig* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        DamagingItemSkillConfig* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -347,18 +341,17 @@ public:
     const Framework::RCArray<DamagingItemSkillConfig>& getConfigs() const;
 };
 
-class DamagingItemSkillFactory
-    : public ItemSkillFactoryBase<DamagingItemSkill>
+class DamagingItemSkillFactory : public ItemSkillFactoryBase<DamagingItemSkill>
 {
 public:
     DamagingItemSkillFactory();
     DamagingItemSkill* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(DamagingItemSkill* zResult,
+    DamagingItemSkill* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(DamagingItemSkill* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        DamagingItemSkill* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 18 - 20
FactoryCraft/BiomGenerator.cpp

@@ -195,20 +195,15 @@ BiomGenerator::getEntityGenerators() const
 }
 
 BiomGeneratorFactory::BiomGeneratorFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-BiomGenerator* BiomGeneratorFactory::createValue(
+BiomGenerator* BiomGeneratorFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BiomGenerator();
-}
-
-void BiomGeneratorFactory::fromJson(
-    BiomGenerator* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setName(zJson->zValue("name")->asString()->getString());
-    zResult->setCondition(
+    BiomGenerator* result = new BiomGenerator();
+    result->setName(zJson->zValue("name")->asString()->getString());
+    result->setCondition(
         Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(
             zJson->zValue("condition")));
     bool first = 1;
@@ -218,28 +213,30 @@ void BiomGeneratorFactory::fromJson(
         StructureTemplateCollection* collection
             = Game::INSTANCE->zTypeRegistry()
                   ->fromJson<StructureTemplateCollection>(value);
-        zResult->addTemplate(collection);
+        result->addTemplate(collection);
     }
     for (Framework::JSON::JSONValue* value :
         *zJson->asObject()->zValue("blocks")->asArray())
     {
-        zResult->addGeneratorRule(
+        result->addGeneratorRule(
             Game::INSTANCE->zTypeRegistry()->fromJson<GeneratorRule>(value));
     }
     for (Framework::JSON::JSONValue* value :
         *zJson->asObject()->zValue("entities")->asArray())
     {
-        zResult->addEntityGenerator(
+        result->addEntityGenerator(
             Game::INSTANCE->zTypeRegistry()->fromJson<EntityGenerator>(value));
     }
+    return result;
 }
 
-void BiomGeneratorFactory::toJson(
-    BiomGenerator* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BiomGeneratorFactory::toJsonObject(
+    BiomGenerator* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
-    zResult->addValue("condition",
+    result->addValue("condition",
         Game::INSTANCE->zTypeRegistry()->toJson<JBoolExpression>(
             zObject->getCondition()));
     Framework::JSON::JSONArray* collections = new Framework::JSON::JSONArray();
@@ -249,21 +246,22 @@ void BiomGeneratorFactory::toJson(
             Game::INSTANCE->zTypeRegistry()
                 ->toJson<StructureTemplateCollection>(collection));
     }
-    zResult->addValue("structurCollections", collections);
+    result->addValue("structurCollections", collections);
     Framework::JSON::JSONArray* rules = new Framework::JSON::JSONArray();
     for (GeneratorRule* rule : zObject->getGeneratorRules())
     {
         rules->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson<GeneratorRule>(rule));
     }
-    zResult->addValue("blocks", rules);
+    result->addValue("blocks", rules);
     Framework::JSON::JSONArray* entities = new Framework::JSON::JSONArray();
     for (EntityGenerator* entity : zObject->getEntityGenerators())
     {
         entities->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson<EntityGenerator>(entity));
     }
-    zResult->addValue("entities", entities);
+    result->addValue("entities", entities);
+    return result;
 }
 
 JSONObjectValidationBuilder* BiomGeneratorFactory::addToValidator(

+ 4 - 7
FactoryCraft/BiomGenerator.h

@@ -66,16 +66,13 @@ public:
     const Framework::RCArray<EntityGenerator>& getEntityGenerators() const;
 };
 
-class BiomGeneratorFactory : public TypeFactory<BiomGenerator>
+class BiomGeneratorFactory : public ObjectTypeFactory<BiomGenerator>
 {
 public:
     BiomGeneratorFactory();
-    BiomGenerator* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BiomGenerator* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BiomGenerator* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BiomGenerator* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BiomGenerator* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 25 - 22
FactoryCraft/Block.cpp

@@ -603,44 +603,47 @@ BasicBlockItemType* BasicBlockItemTypeFactory::createValue(
     return new BasicBlockItemType();
 }
 
-void BasicBlockItemTypeFactory::fromJson(
-    BasicBlockItemType* zResult, Framework::JSON::JSONObject* zJson) const
+BasicBlockItemType* BasicBlockItemTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
-    zResult->setPassable(zJson->zValue("passable")->asBool()->getBool());
-    zResult->setHardness(
+    BasicBlockItemType* result = ItemTypeFactoryBase::fromJson(zJson);
+    result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
+    result->setPassable(zJson->zValue("passable")->asBool()->getBool());
+    result->setHardness(
         (float)zJson->zValue("hardness")->asNumber()->getNumber());
-    zResult->setSpeedModifier(
+    result->setSpeedModifier(
         (float)zJson->zValue("speedModifier")->asNumber()->getNumber());
-    zResult->setBlockTypeName(
+    result->setBlockTypeName(
         zJson->zValue("blockType")->asString()->getString());
-    zResult->setPlaceableProof(
+    result->setPlaceableProof(
         zJson->zValue("placeableProof")->getType()
-                == Framework::JSON::JSONType::OBJECT
+                == Framework::AbstractType::OBJECT
             ? Game::INSTANCE->zTypeRegistry()->fromJson<PlaceableProof>(
-                zJson->zValue("placeableProof"))
+                  zJson->zValue("placeableProof"))
             : 0);
-    ItemTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void BasicBlockItemTypeFactory::toJson(
-    BasicBlockItemType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BasicBlockItemTypeFactory::toJsonObject(
+    BasicBlockItemType* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result
+        = ItemTypeFactoryBase::toJsonObject(zObject);
+    result->addValue(
         "transparent", new Framework::JSON::JSONBool(zObject->isTransparent()));
-    zResult->addValue(
+    result->addValue(
         "passable", new Framework::JSON::JSONBool(zObject->isPassable()));
-    zResult->addValue(
+    result->addValue(
         "hardness", new Framework::JSON::JSONNumber(zObject->getHardness()));
-    zResult->addValue("speedModifier",
+    result->addValue("speedModifier",
         new Framework::JSON::JSONNumber(zObject->getSpeedModifier()));
-    zResult->addValue("blockType",
+    result->addValue("blockType",
         new Framework::JSON::JSONString(zObject->getBlockTypeName()));
-    zResult->addValue("placeableProof",
+    result->addValue("placeableProof",
         zObject->zPlaceableProof() ? Game::INSTANCE->zTypeRegistry()->toJson(
-            zObject->zPlaceableProof())
+                                         zObject->zPlaceableProof())
                                    : new Framework::JSON::JSONValue());
-    ItemTypeFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* BasicBlockItemTypeFactory::addToValidator(
@@ -669,7 +672,7 @@ JSONObjectValidationBuilder* BasicBlockItemTypeFactory::addToValidator(
             ->finishObject());
 }
 
-Framework::Text BasicBlockItemTypeFactory::getTypeToken() const
+const char* BasicBlockItemTypeFactory::getTypeToken() const
 {
     return "placeable";
 }

+ 4 - 4
FactoryCraft/Block.h

@@ -198,11 +198,11 @@ public:
     BasicBlockItemTypeFactory();
     BasicBlockItemType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BasicBlockItemType* zResult,
+    BasicBlockItemType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BasicBlockItemType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicBlockItemType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 80 - 96
FactoryCraft/BlockFilter.cpp

@@ -38,32 +38,30 @@ BlockFilterAndFactory::BlockFilterAndFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterAnd* BlockFilterAndFactory::createValue(
+BlockFilterAnd* BlockFilterAndFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterAnd();
-}
-
-void BlockFilterAndFactory::fromJson(
-    BlockFilterAnd* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    BlockFilterAnd* result = new BlockFilterAnd();
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("filters")->asArray())
     {
-        zResult->addFilter(
+        result->addFilter(
             Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(value));
     }
+    return result;
 }
 
-void BlockFilterAndFactory::toJson(
-    BlockFilterAnd* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterAndFactory::toJsonObject(
+    BlockFilterAnd* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* filters = new Framework::JSON::JSONArray();
     for (BlockFilter* filter : zObject->getFilters())
     {
         filters->addValue(Game::INSTANCE->zTypeRegistry()->toJson(filter));
     }
-    zResult->addValue("filters", filters);
+    result->addValue("filters", filters);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterAndFactory::addToValidator(
@@ -75,7 +73,7 @@ JSONObjectValidationBuilder* BlockFilterAndFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text BlockFilterAndFactory::getTypeToken() const
+const char* BlockFilterAndFactory::getTypeToken() const
 {
     return "and";
 }
@@ -110,32 +108,30 @@ BlockFilterOrFactory::BlockFilterOrFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterOr* BlockFilterOrFactory::createValue(
+BlockFilterOr* BlockFilterOrFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterOr();
-}
-
-void BlockFilterOrFactory::fromJson(
-    BlockFilterOr* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    BlockFilterOr* result = new BlockFilterOr();
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("filters")->asArray())
     {
-        zResult->addFilter(
+        result->addFilter(
             Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(value));
     }
+    return result;
 }
 
-void BlockFilterOrFactory::toJson(
-    BlockFilterOr* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterOrFactory::toJsonObject(
+    BlockFilterOr* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* filters = new Framework::JSON::JSONArray();
     for (BlockFilter* filter : zObject->getFilters())
     {
         filters->addValue(Game::INSTANCE->zTypeRegistry()->toJson(filter));
     }
-    zResult->addValue("filters", filters);
+    result->addValue("filters", filters);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterOrFactory::addToValidator(
@@ -147,7 +143,7 @@ JSONObjectValidationBuilder* BlockFilterOrFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text BlockFilterOrFactory::getTypeToken() const
+const char* BlockFilterOrFactory::getTypeToken() const
 {
     return "or";
 }
@@ -182,24 +178,22 @@ BlockFilterNotFactory::BlockFilterNotFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterNot* BlockFilterNotFactory::createValue(
+BlockFilterNot* BlockFilterNotFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterNot();
-}
-
-void BlockFilterNotFactory::fromJson(
-    BlockFilterNot* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
+    BlockFilterNot* result = new BlockFilterNot();
+    result->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
         zJson->zValue("filter")));
+    return result;
 }
 
-void BlockFilterNotFactory::toJson(
-    BlockFilterNot* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterNotFactory::toJsonObject(
+    BlockFilterNot* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "filter", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zFilter()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterNotFactory::addToValidator(
@@ -209,7 +203,7 @@ JSONObjectValidationBuilder* BlockFilterNotFactory::addToValidator(
         "filter", Game::INSTANCE->zTypeRegistry()->getValidator<BlockFilter>());
 }
 
-Framework::Text BlockFilterNotFactory::getTypeToken() const
+const char* BlockFilterNotFactory::getTypeToken() const
 {
     return "not";
 }
@@ -244,33 +238,31 @@ BlockFilterBlockTypeFactory::BlockFilterBlockTypeFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterBlockType* BlockFilterBlockTypeFactory::createValue(
+BlockFilterBlockType* BlockFilterBlockTypeFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterBlockType();
-}
-
-void BlockFilterBlockTypeFactory::fromJson(
-    BlockFilterBlockType* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    BlockFilterBlockType* result = new BlockFilterBlockType();
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("typeNames")->asArray())
     {
-        zResult->addBlockTypeId(
+        result->addBlockTypeId(
             Game::INSTANCE->getBlockTypeId(value->asString()->getString()));
     }
+    return result;
 }
 
-void BlockFilterBlockTypeFactory::toJson(
-    BlockFilterBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterBlockTypeFactory::toJsonObject(
+    BlockFilterBlockType* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* typeNames = new Framework::JSON::JSONArray();
     for (int typeId : zObject->getBlockTypeIds())
     {
         typeNames->addValue(new Framework::JSON::JSONString(
             Game::INSTANCE->zBlockType(typeId)->getName()));
     }
-    zResult->addValue("typeNames", typeNames);
+    result->addValue("typeNames", typeNames);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterBlockTypeFactory::addToValidator(
@@ -282,7 +274,7 @@ JSONObjectValidationBuilder* BlockFilterBlockTypeFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text BlockFilterBlockTypeFactory::getTypeToken() const
+const char* BlockFilterBlockTypeFactory::getTypeToken() const
 {
     return "types";
 }
@@ -322,31 +314,29 @@ BlockFilterTypeGroupFactory::BlockFilterTypeGroupFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterTypeGroup* BlockFilterTypeGroupFactory::createValue(
+BlockFilterTypeGroup* BlockFilterTypeGroupFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterTypeGroup();
-}
-
-void BlockFilterTypeGroupFactory::fromJson(
-    BlockFilterTypeGroup* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    BlockFilterTypeGroup* result = new BlockFilterTypeGroup();
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("groupNames")->asArray())
     {
-        zResult->addGroupName(value->asString()->getString());
+        result->addGroupName(value->asString()->getString());
     }
+    return result;
 }
 
-void BlockFilterTypeGroupFactory::toJson(
-    BlockFilterTypeGroup* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterTypeGroupFactory::toJsonObject(
+    BlockFilterTypeGroup* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* groupNames = new Framework::JSON::JSONArray();
     for (Framework::Text* groupName : zObject->getGroupNames())
     {
         groupNames->addValue(new Framework::JSON::JSONString(*groupName));
     }
-    zResult->addValue("groupNames", groupNames);
+    result->addValue("groupNames", groupNames);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterTypeGroupFactory::addToValidator(
@@ -358,7 +348,7 @@ JSONObjectValidationBuilder* BlockFilterTypeGroupFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text BlockFilterTypeGroupFactory::getTypeToken() const
+const char* BlockFilterTypeGroupFactory::getTypeToken() const
 {
     return "groups";
 }
@@ -386,24 +376,22 @@ BlockFilterMaxHardnessFactory::BlockFilterMaxHardnessFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterMaxHardness* BlockFilterMaxHardnessFactory::createValue(
+BlockFilterMaxHardness* BlockFilterMaxHardnessFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterMaxHardness();
-}
-
-void BlockFilterMaxHardnessFactory::fromJson(
-    BlockFilterMaxHardness* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setMaxHardness(
+    BlockFilterMaxHardness* result = new BlockFilterMaxHardness();
+    result->setMaxHardness(
         (float)zJson->zValue("maxHardness")->asNumber()->getNumber());
+    return result;
 }
 
-void BlockFilterMaxHardnessFactory::toJson(
-    BlockFilterMaxHardness* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterMaxHardnessFactory::toJsonObject(
+    BlockFilterMaxHardness* zObject) const
 {
-    zResult->addValue("maxHardness",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("maxHardness",
         new Framework::JSON::JSONNumber(zObject->getMaxHardness()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterMaxHardnessFactory::addToValidator(
@@ -414,7 +402,7 @@ JSONObjectValidationBuilder* BlockFilterMaxHardnessFactory::addToValidator(
         ->finishNumber();
 }
 
-Framework::Text BlockFilterMaxHardnessFactory::getTypeToken() const
+const char* BlockFilterMaxHardnessFactory::getTypeToken() const
 {
     return "maxHardness";
 }
@@ -443,24 +431,22 @@ BlockFilterMinHardnessFactory::BlockFilterMinHardnessFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterMinHardness* BlockFilterMinHardnessFactory::createValue(
+BlockFilterMinHardness* BlockFilterMinHardnessFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterMinHardness();
-}
-
-void BlockFilterMinHardnessFactory::fromJson(
-    BlockFilterMinHardness* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setMinHardness(
+    BlockFilterMinHardness* result = new BlockFilterMinHardness();
+    result->setMinHardness(
         (float)zJson->zValue("minHardness")->asNumber()->getNumber());
+    return result;
 }
 
-void BlockFilterMinHardnessFactory::toJson(
-    BlockFilterMinHardness* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterMinHardnessFactory::toJsonObject(
+    BlockFilterMinHardness* zObject) const
 {
-    zResult->addValue("minHardness",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("minHardness",
         new Framework::JSON::JSONNumber(zObject->getMinHardness()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterMinHardnessFactory::addToValidator(
@@ -471,7 +457,7 @@ JSONObjectValidationBuilder* BlockFilterMinHardnessFactory::addToValidator(
         ->finishNumber();
 }
 
-Framework::Text BlockFilterMinHardnessFactory::getTypeToken() const
+const char* BlockFilterMinHardnessFactory::getTypeToken() const
 {
     return "minHardness";
 }
@@ -502,23 +488,21 @@ BlockFilterMaxHeatFactory::BlockFilterMaxHeatFactory()
     : SubTypeFactory()
 {}
 
-BlockFilterMaxHeat* BlockFilterMaxHeatFactory::createValue(
+BlockFilterMaxHeat* BlockFilterMaxHeatFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new BlockFilterMaxHeat();
-}
-
-void BlockFilterMaxHeatFactory::fromJson(
-    BlockFilterMaxHeat* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setMaxHeat((float)zJson->zValue("heat")->asNumber()->getNumber());
+    BlockFilterMaxHeat* result = new BlockFilterMaxHeat();
+    result->setMaxHeat((float)zJson->zValue("heat")->asNumber()->getNumber());
+    return result;
 }
 
-void BlockFilterMaxHeatFactory::toJson(
-    BlockFilterMaxHeat* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockFilterMaxHeatFactory::toJsonObject(
+    BlockFilterMaxHeat* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "heat", new Framework::JSON::JSONNumber(zObject->getMaxHeat()));
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockFilterMaxHeatFactory::addToValidator(
@@ -527,7 +511,7 @@ JSONObjectValidationBuilder* BlockFilterMaxHeatFactory::addToValidator(
     return builder->withRequiredNumber("heat")->finishNumber();
 }
 
-Framework::Text BlockFilterMaxHeatFactory::getTypeToken() const
+const char* BlockFilterMaxHeatFactory::getTypeToken() const
 {
     return "maxHeat";
 }

+ 32 - 51
FactoryCraft/BlockFilter.h

@@ -29,15 +29,12 @@ class BlockFilterAndFactory : public SubTypeFactory<BlockFilter, BlockFilterAnd>
 {
 public:
     BlockFilterAndFactory();
-    BlockFilterAnd* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterAnd* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterAnd* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BlockFilterAnd* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterAnd* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterOr : public BlockFilter
@@ -56,15 +53,12 @@ class BlockFilterOrFactory : public SubTypeFactory<BlockFilter, BlockFilterOr>
 {
 public:
     BlockFilterOrFactory();
-    BlockFilterOr* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterOr* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterOr* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BlockFilterOr* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterOr* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterNot : public BlockFilter
@@ -84,15 +78,12 @@ class BlockFilterNotFactory : public SubTypeFactory<BlockFilter, BlockFilterNot>
 {
 public:
     BlockFilterNotFactory();
-    BlockFilterNot* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterNot* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterNot* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BlockFilterNot* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterNot* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterBlockType : public BlockFilter
@@ -112,15 +103,13 @@ class BlockFilterBlockTypeFactory
 {
 public:
     BlockFilterBlockTypeFactory();
-    BlockFilterBlockType* createValue(
+    BlockFilterBlockType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterBlockType* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterTypeGroup : public BlockFilter
@@ -140,15 +129,13 @@ class BlockFilterTypeGroupFactory
 {
 public:
     BlockFilterTypeGroupFactory();
-    BlockFilterTypeGroup* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterTypeGroup* zResult,
+    BlockFilterTypeGroup* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterTypeGroup* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterTypeGroup* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterMaxHardness : public BlockFilter
@@ -168,15 +155,13 @@ class BlockFilterMaxHardnessFactory
 {
 public:
     BlockFilterMaxHardnessFactory();
-    BlockFilterMaxHardness* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterMaxHardness* zResult,
+    BlockFilterMaxHardness* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterMaxHardness* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterMaxHardness* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterMinHardness : public BlockFilter
@@ -196,15 +181,13 @@ class BlockFilterMinHardnessFactory
 {
 public:
     BlockFilterMinHardnessFactory();
-    BlockFilterMinHardness* createValue(
+    BlockFilterMinHardness* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterMinHardness* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterMinHardness* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterMinHardness* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class BlockFilterMaxHeat : public BlockFilter
@@ -224,13 +207,11 @@ class BlockFilterMaxHeatFactory
 {
 public:
     BlockFilterMaxHeatFactory();
-    BlockFilterMaxHeat* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockFilterMaxHeat* zResult,
+    BlockFilterMaxHeat* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockFilterMaxHeat* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockFilterMaxHeat* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 11 - 10
FactoryCraft/BlockInstanceGeneratorRule.cpp

@@ -34,23 +34,24 @@ BlockInstanceGeneratorRule* BlockInstanceGeneratorRuleFactory::createValue(
     return new BlockInstanceGeneratorRule();
 }
 
-void BlockInstanceGeneratorRuleFactory::fromJson(
-    BlockInstanceGeneratorRule* zResult,
+BlockInstanceGeneratorRule* BlockInstanceGeneratorRuleFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setBlockTypeId(Game::INSTANCE->getBlockTypeId(
+    BlockInstanceGeneratorRule* result = GeneratorRuleFactory::fromJson(zJson);
+    result->setBlockTypeId(Game::INSTANCE->getBlockTypeId(
         zJson->zValue("blockType")->asString()->getString()));
-    GeneratorRuleFactory::fromJson(zResult, zJson);
+    return result;
 }
 
-void BlockInstanceGeneratorRuleFactory::toJson(
-    BlockInstanceGeneratorRule* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockInstanceGeneratorRuleFactory::toJsonObject(
+    BlockInstanceGeneratorRule* zObject) const
 {
-    zResult->addValue("blockType",
+    Framework::JSON::JSONObject* result
+        = GeneratorRuleFactory::toJsonObject(zObject);
+    result->addValue("blockType",
         new Framework::JSON::JSONString(
             Game::INSTANCE->zBlockType(zObject->getBlockTypeId())->getName()));
-    GeneratorRuleFactory::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockInstanceGeneratorRuleFactory::addToValidator(
@@ -71,7 +72,7 @@ JSONObjectValidationBuilder* BlockInstanceGeneratorRuleFactory::addToValidator(
             ->finishString());
 }
 
-Framework::Text BlockInstanceGeneratorRuleFactory::getTypeToken() const
+const char* BlockInstanceGeneratorRuleFactory::getTypeToken() const
 {
     return "blockInstance";
 }

+ 4 - 4
FactoryCraft/BlockInstanceGeneratorRule.h

@@ -22,11 +22,11 @@ public:
     BlockInstanceGeneratorRuleFactory();
     BlockInstanceGeneratorRule* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockInstanceGeneratorRule* zResult,
+    BlockInstanceGeneratorRule* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockInstanceGeneratorRule* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockInstanceGeneratorRule* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 20 - 15
FactoryCraft/BlockType.h

@@ -104,10 +104,10 @@ public:
         : SubTypeFactory<BlockType, S>()
     {}
 
-    virtual void fromJson(
-        S* zResult, Framework::JSON::JSONObject* zJson) const override
+    virtual S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        BlockType* zType = dynamic_cast<BlockType*>(zResult);
+        S* result = createValue(zJson);
+        BlockType* zType = dynamic_cast<BlockType*>(result);
         zType->setModel(Game::INSTANCE->zTypeRegistry()->fromJson<ModelInfo>(
             zJson->zValue("model")->asObject()));
         zType->setInitialMaxHP(
@@ -130,26 +130,27 @@ public:
         zType->setGroupNames(groupNames);
         zType->setHardness(
             (float)zJson->zValue("hardness")->asNumber()->getNumber());
+        return result;
     }
 
-    virtual void toJson(
-        S* zObject, Framework::JSON::JSONObject* zResult) const override
+    virtual Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
-        BlockType* zType = dynamic_cast<BlockType*>(zResult);
-        zResult->addValue("model",
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+        BlockType* zType = dynamic_cast<BlockType*>(zObject);
+        result->addValue("model",
             Game::INSTANCE->zTypeRegistry()->toJson<ModelInfo>(
                 zType->zModel()));
-        zResult->addValue("maxHp",
+        result->addValue("maxHp",
             new Framework::JSON::JSONNumber((double)zType->getInitialMaxHP()));
-        zResult->addValue("needsClientInstance",
+        result->addValue("needsClientInstance",
             new Framework::JSON::JSONBool(zType->doesNeedClientInstance()));
-        zResult->addValue("lightSource",
+        result->addValue("lightSource",
             new Framework::JSON::JSONBool(zType->isLightSource()));
-        zResult->addValue(
+        result->addValue(
             "name", new Framework::JSON::JSONString(zType->getName()));
-        zResult->addValue("needModelSubscription",
+        result->addValue("needModelSubscription",
             new Framework::JSON::JSONBool(zType->doesNeedModelSubscription()));
-        zResult->addValue("mapColor",
+        result->addValue("mapColor",
             new Framework::JSON::JSONString(
                 Framework::Text(zType->getMapColor())));
         Framework::JSON::JSONArray* groupNames
@@ -158,9 +159,10 @@ public:
         {
             groupNames->addValue(new Framework::JSON::JSONString(*groupName));
         }
-        zResult->addValue("groupNames", groupNames);
-        zResult->addValue(
+        result->addValue("groupNames", groupNames);
+        result->addValue(
             "hardness", new Framework::JSON::JSONNumber(zType->getHardness()));
+        return result;
     }
 
     virtual JSONObjectValidationBuilder* addToValidator(
@@ -194,4 +196,7 @@ public:
             ->withDefault(1.0)
             ->finishNumber();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };

+ 12 - 9
FactoryCraft/BlockTypeGeneratorRule.cpp

@@ -33,21 +33,24 @@ BlockTypeGeneratorRule* BlockTypeGeneratorRuleFactory::createValue(
     return new BlockTypeGeneratorRule();
 }
 
-void BlockTypeGeneratorRuleFactory::fromJson(
-    BlockTypeGeneratorRule* zResult, Framework::JSON::JSONObject* zJson) const
+BlockTypeGeneratorRule* BlockTypeGeneratorRuleFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setBlockTypeId(Game::INSTANCE->getBlockTypeId(
+    BlockTypeGeneratorRule* result = GeneratorRuleFactory::fromJson(zJson);
+    result->setBlockTypeId(Game::INSTANCE->getBlockTypeId(
         zJson->zValue("blockType")->asString()->getString()));
-    GeneratorRuleFactory::fromJson(zResult, zJson);
+    return result;
 }
 
-void BlockTypeGeneratorRuleFactory::toJson(
-    BlockTypeGeneratorRule* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BlockTypeGeneratorRuleFactory::toJsonObject(
+    BlockTypeGeneratorRule* zObject) const
 {
-    zResult->addValue("blockType",
+    Framework::JSON::JSONObject* result
+        = GeneratorRuleFactory::toJsonObject(zObject);
+    result->addValue("blockType",
         new Framework::JSON::JSONString(
             Game::INSTANCE->zBlockType(zObject->getBlockTypeId())->getName()));
-    GeneratorRuleFactory::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* BlockTypeGeneratorRuleFactory::addToValidator(
@@ -68,7 +71,7 @@ JSONObjectValidationBuilder* BlockTypeGeneratorRuleFactory::addToValidator(
             ->finishString());
 }
 
-Framework::Text BlockTypeGeneratorRuleFactory::getTypeToken() const
+const char* BlockTypeGeneratorRuleFactory::getTypeToken() const
 {
     return "blockType";
 }

+ 4 - 4
FactoryCraft/BlockTypeGeneratorRule.h

@@ -22,11 +22,11 @@ public:
     BlockTypeGeneratorRuleFactory();
     BlockTypeGeneratorRule* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BlockTypeGeneratorRule* zResult,
+    BlockTypeGeneratorRule* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BlockTypeGeneratorRule* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BlockTypeGeneratorRule* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 16 - 12
FactoryCraft/Chest.cpp

@@ -167,35 +167,39 @@ Block* ChestBlockType::createBlock(
 }
 
 ChestBlockTypeFactory::ChestBlockTypeFactory()
-    : SubTypeFactory(),
-      super()
+    : BasicBlockTypeFactory()
 {}
 
-ChestBlockType* ChestBlockTypeFactory::createValue(
+BasicBlockType* ChestBlockTypeFactory::createValue(
     Framework::JSON::JSONObject* zJson) const
 {
     return new ChestBlockType();
 }
 
-void ChestBlockTypeFactory::fromJson(
-    ChestBlockType* zResult, Framework::JSON::JSONObject* zJson) const
+BasicBlockType* ChestBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    super.fromJson(zResult, zJson);
+    return BasicBlockTypeFactory::fromJson(zJson);
 }
 
-void ChestBlockTypeFactory::toJson(
-    ChestBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* ChestBlockTypeFactory::toJsonObject(
+    BasicBlockType* zObject) const
 {
-    super.toJson(zObject, zResult);
+    return BasicBlockTypeFactory::toJsonObject(zObject);
 }
 
 JSONObjectValidationBuilder* ChestBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    return super.addToValidator(builder);
+    return BasicBlockTypeFactory::addToValidator(builder);
 }
 
-Framework::Text ChestBlockTypeFactory::getTypeToken() const
+const char* ChestBlockTypeFactory::getTypeToken() const
 {
     return "chest";
-}
+}
+
+const char* ChestBlockTypeFactory::getTypeName() const
+{
+    return typeid(ChestBlockType).name();
+}

+ 7 - 9
FactoryCraft/Chest.h

@@ -30,19 +30,17 @@ public:
         Framework::Vec3<int> position, int dimensionId) const override;
 };
 
-class ChestBlockTypeFactory : public SubTypeFactory<BlockType, ChestBlockType>
+class ChestBlockTypeFactory : public BasicBlockTypeFactory
 {
-    BasicBlockTypeFactory super;
-
 public:
     ChestBlockTypeFactory();
-    ChestBlockType* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(ChestBlockType* zResult,
+    BasicBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(ChestBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BasicBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
+    const char* getTypeName() const;
 };

+ 27 - 27
FactoryCraft/DimensionGenerator.cpp

@@ -72,31 +72,29 @@ JFloatExpression* WorldHeightLayer::zValue() const
 
 WorldHeightLayerFactory::WorldHeightLayerFactory() {}
 
-WorldHeightLayer* WorldHeightLayerFactory::createValue(
+WorldHeightLayer* WorldHeightLayerFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new WorldHeightLayer();
-}
-
-void WorldHeightLayerFactory::fromJson(
-    WorldHeightLayer* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setName(zJson->zValue("name")->asString()->getString());
-    zResult->setNoiseConfig(zJson->getValue("noise")->asObject());
-    zResult->setValue(
+    WorldHeightLayer* result = new WorldHeightLayer();
+    result->setName(zJson->zValue("name")->asString()->getString());
+    result->setNoiseConfig(zJson->getValue("noise")->asObject());
+    result->setValue(
         Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
             zJson->zValue("value")));
+    return result;
 }
 
-void WorldHeightLayerFactory::toJson(
-    WorldHeightLayer* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* WorldHeightLayerFactory::toJsonObject(
+    WorldHeightLayer* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
-    zResult->addValue("noise", zObject->zNoiseConfig());
-    zResult->addValue("value",
+    result->addValue("noise", zObject->zNoiseConfig());
+    result->addValue("value",
         Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
             zObject->zValue()));
+    return result;
 }
 
 JSONObjectValidationBuilder* WorldHeightLayerFactory::addToValidator(
@@ -602,34 +600,36 @@ BiomedCavedDimensionGeneratorFactory::createValue(
     return new BiomedCavedDimensionGenerator();
 }
 
-void BiomedCavedDimensionGeneratorFactory::fromJson(
-    BiomedCavedDimensionGenerator* zResult,
+BiomedCavedDimensionGenerator* BiomedCavedDimensionGeneratorFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setBiomNoiseConfig(zJson->getValue("biomNoise")->asObject());
+    BiomedCavedDimensionGenerator* result
+        = DimensionGeneratorFactory::fromJson(zJson);
+    result->setBiomNoiseConfig(zJson->getValue("biomNoise")->asObject());
     for (Framework::JSON::JSONValue* value : *zJson->zValue("bioms")->asArray())
     {
-        zResult->addBiomGenerator(
+        result->addBiomGenerator(
             Game::INSTANCE->zTypeRegistry()->fromJson<BiomGenerator>(value));
     }
-    DimensionGeneratorFactory::fromJson(zResult, zJson);
+    return result;
 }
 
-void BiomedCavedDimensionGeneratorFactory::toJson(
-    BiomedCavedDimensionGenerator* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BiomedCavedDimensionGeneratorFactory::toJsonObject(
+    BiomedCavedDimensionGenerator* zObject) const
 {
+    Framework::JSON::JSONObject* result
+        = DimensionGeneratorFactory::toJsonObject(zObject);
     Framework::JSON::JSONArray* bioms = new Framework::JSON::JSONArray();
     for (BiomGenerator* biom : zObject->getBiomGenerators())
     {
         bioms->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson<BiomGenerator>(biom));
     }
-    zResult->addValue("bioms", bioms);
-    zResult->addValue("biomNoise",
+    result->addValue("bioms", bioms);
+    result->addValue("biomNoise",
         dynamic_cast<Framework::JSON::JSONValue*>(
             zObject->zBiomNoiseConfig()->getThis()));
-    DimensionGeneratorFactory::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder*
@@ -644,7 +644,7 @@ BiomedCavedDimensionGeneratorFactory::addToValidator(
             ->withRequiredAttribute("biomNoise", JNoise::getValidator(false)));
 }
 
-Framework::Text BiomedCavedDimensionGeneratorFactory::getTypeToken() const
+const char* BiomedCavedDimensionGeneratorFactory::getTypeToken() const
 {
     return "cavedBioms";
 }

+ 22 - 17
FactoryCraft/DimensionGenerator.h

@@ -36,16 +36,14 @@ public:
     JFloatExpression* zValue() const;
 };
 
-class WorldHeightLayerFactory : public TypeFactory<WorldHeightLayer>
+class WorldHeightLayerFactory : public ObjectTypeFactory<WorldHeightLayer>
 {
 public:
     WorldHeightLayerFactory();
-    WorldHeightLayer* createValue(
+    WorldHeightLayer* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(WorldHeightLayer* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(WorldHeightLayer* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        WorldHeightLayer* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -96,10 +94,11 @@ public:
         : SubTypeFactory<DimensionGenerator, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
+        S* result = createValue(zJson);
         DimensionGenerator* zGenerator
-            = dynamic_cast<DimensionGenerator*>(zResult);
+            = dynamic_cast<DimensionGenerator*>(result);
         zGenerator->setName(zJson->zValue("name")->asString()->getString());
         zGenerator->setId((int)zJson->zValue("id")->asNumber()->getNumber());
         zGenerator->setSeed(
@@ -112,17 +111,19 @@ public:
                 Game::INSTANCE->zTypeRegistry()->fromJson<WorldHeightLayer>(
                     layer));
         }
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
         DimensionGenerator* zGenerator
             = dynamic_cast<DimensionGenerator*>(zObject);
-        zResult->addValue(
+        result->addValue(
             "name", new Framework::JSON::JSONString(zGenerator->getName()));
-        zResult->addValue(
+        result->addValue(
             "id", new Framework::JSON::JSONNumber(zGenerator->getId()));
-        zResult->addValue("dimensionSeed",
+        result->addValue("dimensionSeed",
             Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
                 zGenerator->zSeed()));
         Framework::JSON::JSONArray* hightLayers
@@ -132,7 +133,8 @@ public:
             hightLayers->addValue(
                 Game::INSTANCE->zTypeRegistry()->toJson(layer));
         }
-        zResult->addValue("heightLayers", hightLayers);
+        result->addValue("heightLayers", hightLayers);
+        return result;
     }
 
     JSONObjectValidationBuilder* addToValidator(
@@ -151,6 +153,9 @@ public:
             ->withRequiredNumber("id")
             ->finishNumber();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };
 
 class BiomGenerator;
@@ -196,11 +201,11 @@ public:
     BiomedCavedDimensionGeneratorFactory();
     BiomedCavedDimensionGenerator* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BiomedCavedDimensionGenerator* zResult,
+    BiomedCavedDimensionGenerator* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BiomedCavedDimensionGenerator* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BiomedCavedDimensionGenerator* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 16 - 19
FactoryCraft/EntityGenerator.cpp

@@ -53,56 +53,53 @@ Entity* EntityGenerator::generate(Framework::Vec3<float> pos, int dimesnionId)
 }
 
 EntityGeneratorFactory::EntityGeneratorFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-EntityGenerator* EntityGeneratorFactory::createValue(
+EntityGenerator* EntityGeneratorFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new EntityGenerator();
-}
-
-void EntityGeneratorFactory::fromJson(
-    EntityGenerator* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    EntityGenerator* result = new EntityGenerator();
     if (zJson->hasValue("noise"))
     {
-        zResult->noiseConfig = zJson->getValue("noise")->asObject();
+        result->noiseConfig = zJson->getValue("noise")->asObject();
     }
     if (zJson->hasValue("threshold"))
     {
-        zResult->threshold
-            = zJson->zValue("threshold")->asNumber()->getNumber();
+        result->threshold = zJson->zValue("threshold")->asNumber()->getNumber();
     }
     if (zJson->hasValue("type"))
     {
-        zResult->zType
+        result->zType
             = Game::INSTANCE->zEntityType(Game::INSTANCE->getEntityTypeId(
                 zJson->zValue("type")->asString()->getString()));
     }
     if (zJson->hasValue("condition"))
     {
-        zResult->condition
+        result->condition
             = Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(
                 zJson->zValue("condition"));
     }
+    return result;
 }
 
-void EntityGeneratorFactory::toJson(
-    EntityGenerator* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* EntityGeneratorFactory::toJsonObject(
+    EntityGenerator* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     if (zObject->noiseConfig)
     {
-        zResult->addValue("noise",
+        result->addValue("noise",
             dynamic_cast<Framework::JSON::JSONValue*>(
                 zObject->noiseConfig->getThis()));
     }
-    zResult->addValue(
+    result->addValue(
         "threshold", new Framework::JSON::JSONNumber(zObject->threshold));
-    zResult->addValue(
+    result->addValue(
         "type", new Framework::JSON::JSONString(zObject->zType->getName()));
-    zResult->addValue("condition",
+    result->addValue("condition",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->condition));
+    return result;
 }
 
 JSONObjectValidationBuilder* EntityGeneratorFactory::addToValidator(

+ 4 - 6
FactoryCraft/EntityGenerator.h

@@ -32,16 +32,14 @@ public:
     friend EntityGeneratorFactory;
 };
 
-class EntityGeneratorFactory : public TypeFactory<EntityGenerator>
+class EntityGeneratorFactory : public ObjectTypeFactory<EntityGenerator>
 {
 public:
     EntityGeneratorFactory();
-    EntityGenerator* createValue(
+    EntityGenerator* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(EntityGenerator* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(EntityGenerator* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        EntityGenerator* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 1 - 1
FactoryCraft/FactoryCraft.vcxproj

@@ -308,7 +308,7 @@
       <OutputFile>$(RemoteProjectDir)/$(TargetName)$(TargetExt)</OutputFile>
     </Link>
     <ClCompile>
-      <CppLanguageStandard>c++17</CppLanguageStandard>
+      <CppLanguageStandard>c++20</CppLanguageStandard>
       <AdditionalIncludeDirectories>../../../Framework/debug;../../../Network/debug/Network;../../../KsgScript/debug/KsgScript</AdditionalIncludeDirectories>
       <ObjectFileName>%(filename).o</ObjectFileName>
     </ClCompile>

+ 22 - 19
FactoryCraft/FluidBlock.cpp

@@ -347,10 +347,11 @@ FluidBlockType* FluidBlockTypeFactory::createValue(
     return new FluidBlockType();
 }
 
-void FluidBlockTypeFactory::fromJson(
-    FluidBlockType* zResult, Framework::JSON::JSONObject* zJson) const
+FluidBlockType* FluidBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setLightWeights(
+    FluidBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
+    result->setLightWeights(
         Framework::Vec3<float>((float)zJson->zValue("lightWeight")
                                    ->asObject()
                                    ->zValue("red")
@@ -366,21 +367,23 @@ void FluidBlockTypeFactory::fromJson(
                 ->zValue("blue")
                 ->asNumber()
                 ->getNumber()));
-    zResult->setTicktsToFlow(
+    result->setTicktsToFlow(
         (int)zJson->zValue("ticksToFlow")->asNumber()->getNumber());
-    zResult->setFlowDistance(
+    result->setFlowDistance(
         (char)zJson->zValue("flowDistance")->asNumber()->getNumber());
-    zResult->setHungerRecoveryPerL(
+    result->setHungerRecoveryPerL(
         (float)zJson->zValue("hungerRecoveryPerL")->asNumber()->getNumber());
-    zResult->setThirstRecoveryPerL(
+    result->setThirstRecoveryPerL(
         (float)zJson->zValue("thirstRecoveryPerL")->asNumber()->getNumber());
-    zResult->setHeat((float)zJson->zValue("heat")->asNumber()->getNumber());
-    BlockTypeFactoryBase::fromJson(zResult, zJson);
+    result->setHeat((float)zJson->zValue("heat")->asNumber()->getNumber());
+    return result;
 }
 
-void FluidBlockTypeFactory::toJson(
-    FluidBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* FluidBlockTypeFactory::toJsonObject(
+    FluidBlockType* zObject) const
 {
+    Framework::JSON::JSONObject* result
+        = BlockTypeFactoryBase::toJsonObject(zObject);
     Framework::JSON::JSONObject* lightWeight
         = new Framework::JSON::JSONObject();
     lightWeight->addValue(
@@ -389,20 +392,20 @@ void FluidBlockTypeFactory::toJson(
         "green", new Framework::JSON::JSONNumber(zObject->getLightWeights().y));
     lightWeight->addValue(
         "blue", new Framework::JSON::JSONNumber(zObject->getLightWeights().z));
-    zResult->addValue("lightWeight", lightWeight);
-    zResult->addValue("ticksToFlow",
+    result->addValue("lightWeight", lightWeight);
+    result->addValue("ticksToFlow",
         new Framework::JSON::JSONNumber((double)zObject->getTicktsToFlow()));
-    zResult->addValue("flowDistance",
+    result->addValue("flowDistance",
         new Framework::JSON::JSONNumber((double)zObject->getFlowDistance()));
-    zResult->addValue("hungerRecoveryPerL",
+    result->addValue("hungerRecoveryPerL",
         new Framework::JSON::JSONNumber(
             (double)zObject->getHungerRecoveryPerL()));
-    zResult->addValue("thirstRecoveryPerL",
+    result->addValue("thirstRecoveryPerL",
         new Framework::JSON::JSONNumber(
             (double)zObject->getThirstRecoveryPerL()));
-    zResult->addValue(
+    result->addValue(
         "heat", new Framework::JSON::JSONNumber((double)zObject->getHeat()));
-    BlockTypeFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* FluidBlockTypeFactory::addToValidator(
@@ -442,7 +445,7 @@ JSONObjectValidationBuilder* FluidBlockTypeFactory::addToValidator(
             ->finishNumber());
 }
 
-Framework::Text FluidBlockTypeFactory::getTypeToken() const
+const char* FluidBlockTypeFactory::getTypeToken() const
 {
     return "fluid";
 }

+ 4 - 5
FactoryCraft/FluidBlock.h

@@ -89,11 +89,10 @@ public:
     FluidBlockTypeFactory();
     FluidBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(FluidBlockType* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(FluidBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    FluidBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        FluidBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 66 - 65
FactoryCraft/FluidContainer.cpp

@@ -232,61 +232,56 @@ float FluidContainerItemSkillConfig::getXpGain() const
 }
 
 FluidContainerItemSkillConfigFactory::FluidContainerItemSkillConfigFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-FluidContainerItemSkillConfig*
-FluidContainerItemSkillConfigFactory::createValue(
+FluidContainerItemSkillConfig* FluidContainerItemSkillConfigFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new FluidContainerItemSkillConfig();
-}
-
-void FluidContainerItemSkillConfigFactory::fromJson(
-    FluidContainerItemSkillConfig* zResult,
-    Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setTargetFilter(
+    FluidContainerItemSkillConfig* result = new FluidContainerItemSkillConfig();
+    result->setTargetFilter(
         Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
             zJson->asObject()->zValue("targetFilter")));
-    zResult->setStaminaCost((float)zJson->asObject()
-                                ->zValue("staminaCost")
-                                ->asNumber()
-                                ->getNumber());
-    zResult->setStaminaCostDevider((float)zJson->asObject()
-                                       ->zValue("staminaCostDevider")
-                                       ->asNumber()
-                                       ->getNumber());
-    zResult->setStaminaCostDeviderPerLevel(
+    result->setStaminaCost((float)zJson->asObject()
+                               ->zValue("staminaCost")
+                               ->asNumber()
+                               ->getNumber());
+    result->setStaminaCostDevider((float)zJson->asObject()
+                                      ->zValue("staminaCostDevider")
+                                      ->asNumber()
+                                      ->getNumber());
+    result->setStaminaCostDeviderPerLevel(
         (float)zJson->asObject()
             ->zValue("staminaCostDeviderPerLevel")
             ->asNumber()
             ->getNumber());
-    zResult->setCooldownTicks((int)zJson->asObject()
-                                  ->zValue("cooldownTicks")
-                                  ->asNumber()
-                                  ->getNumber());
-    zResult->setXpGain(
+    result->setCooldownTicks((int)zJson->asObject()
+                                 ->zValue("cooldownTicks")
+                                 ->asNumber()
+                                 ->getNumber());
+    result->setXpGain(
         (float)zJson->asObject()->zValue("xpGain")->asNumber()->getNumber());
+    return result;
 }
 
-void FluidContainerItemSkillConfigFactory::toJson(
-    FluidContainerItemSkillConfig* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* FluidContainerItemSkillConfigFactory::toJsonObject(
+    FluidContainerItemSkillConfig* zObject) const
 {
-    zResult->addValue("targetFilter",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("targetFilter",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zTargetFilter()));
-    zResult->addValue("staminaCost",
+    result->addValue("staminaCost",
         new Framework::JSON::JSONNumber(zObject->getStaminaCost()));
-    zResult->addValue("staminaCostDevider",
+    result->addValue("staminaCostDevider",
         new Framework::JSON::JSONNumber(zObject->getStaminaCostDevider()));
-    zResult->addValue("staminaCostDeviderPerLevel",
+    result->addValue("staminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->getStaminaCostDeviderPerLevel()));
-    zResult->addValue("cooldownTicks",
+    result->addValue("cooldownTicks",
         new Framework::JSON::JSONNumber(zObject->getCooldownTicks()));
-    zResult->addValue(
+    result->addValue(
         "xpGain", new Framework::JSON::JSONNumber(zObject->getXpGain()));
+    return result;
 }
 
 JSONObjectValidationBuilder*
@@ -456,15 +451,16 @@ FluidContainerItemSkill* FluidContainerItemSkillFactory::createValue(
     return new FluidContainerItemSkill();
 }
 
-void FluidContainerItemSkillFactory::fromJson(
-    FluidContainerItemSkill* zResult, Framework::JSON::JSONObject* zJson) const
+FluidContainerItemSkill* FluidContainerItemSkillFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    FluidContainerItemSkill* result = ItemSkillFactoryBase::fromJson(zJson);
     for (Framework::JSON::JSONValue* configValue :
         *zJson->zValue("configs")->asArray())
     {
-        zResult->addConfig(Game::INSTANCE->zTypeRegistry()
-                               ->fromJson<FluidContainerItemSkillConfig>(
-                                   configValue->asObject()));
+        result->addConfig(Game::INSTANCE->zTypeRegistry()
+                              ->fromJson<FluidContainerItemSkillConfig>(
+                                  configValue->asObject()));
     }
     FluidContainerItemSkillConfig* invalidConfig
         = new FluidContainerItemSkillConfig();
@@ -480,23 +476,25 @@ void FluidContainerItemSkillFactory::fromJson(
             ->getNumber());
     invalidConfig->setCooldownTicks(
         (int)zJson->zValue("invalidUseCooldownTicks")->asNumber()->getNumber());
-    zResult->setInvalidUseConfig(invalidConfig);
-    ItemSkillFactoryBase::fromJson(zResult, zJson);
+    result->setInvalidUseConfig(invalidConfig);
+    return result;
 }
 
-void FluidContainerItemSkillFactory::toJson(FluidContainerItemSkill* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* FluidContainerItemSkillFactory::toJsonObject(
+    FluidContainerItemSkill* zObject) const
 {
-    zResult->addValue("invalidUseStaminaCost",
+    Framework::JSON::JSONObject* result
+        = ItemSkillFactoryBase::toJsonObject(zObject);
+    result->addValue("invalidUseStaminaCost",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCost()));
-    zResult->addValue("invalidUseStaminaCostDevider",
+    result->addValue("invalidUseStaminaCostDevider",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostDevider()));
-    zResult->addValue("invalidUseStaminaCostDeviderPerLevel",
+    result->addValue("invalidUseStaminaCostDeviderPerLevel",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getStaminaCostDeviderPerLevel()));
-    zResult->addValue("invalidUseCooldownTicks",
+    result->addValue("invalidUseCooldownTicks",
         new Framework::JSON::JSONNumber(
             zObject->zInvalidUseConfig()->getCooldownTicks()));
     Framework::JSON::JSONArray* configs = new Framework::JSON::JSONArray();
@@ -504,8 +502,8 @@ void FluidContainerItemSkillFactory::toJson(FluidContainerItemSkill* zObject,
     {
         configs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(config));
     }
-    zResult->addValue("configs", configs);
-    ItemSkillFactoryBase::toJson(zObject, zResult);
+    result->addValue("configs", configs);
+    return result;
 }
 
 JSONObjectValidationBuilder* FluidContainerItemSkillFactory::addToValidator(
@@ -535,7 +533,7 @@ JSONObjectValidationBuilder* FluidContainerItemSkillFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text FluidContainerItemSkillFactory::getTypeToken() const
+const char* FluidContainerItemSkillFactory::getTypeToken() const
 {
     return "fluidGathering";
 }
@@ -618,7 +616,7 @@ void FluidContainerItemType::setItemAttribute(
     }
     if (name.istGleich("fluidType"))
     {
-        if (zValue->getType() == Framework::JSON::JSONType::STRING)
+        if (zValue->getType() == Framework::AbstractType::STRING)
         {
             int id = ItemType::getTypeId(zValue->asString()->getString());
             if (id)
@@ -641,7 +639,7 @@ void FluidContainerItemType::setItemAttribute(
     }
     else if (name.istGleich("fluidAmount"))
     {
-        if (zValue->getType() == Framework::JSON::JSONType::NUMBER)
+        if (zValue->getType() == Framework::AbstractType::NUMBER)
         {
             item->fluidAmount = (int)zValue->asNumber()->getNumber();
         }
@@ -723,29 +721,32 @@ FluidContainerItemType* FluidContainerItemTypeFactory::createValue(
     return new FluidContainerItemType();
 }
 
-void FluidContainerItemTypeFactory::fromJson(
-    FluidContainerItemType* zResult, Framework::JSON::JSONObject* zJson) const
+FluidContainerItemType* FluidContainerItemTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setItemSkillConfig(zJson->getValue("itemSkill")->asObject());
-    zResult->setLevelUpRule(
+    FluidContainerItemType* result = ItemTypeFactoryBase::fromJson(zJson);
+    result->setItemSkillConfig(zJson->getValue("itemSkill")->asObject());
+    result->setLevelUpRule(
         Game::INSTANCE->zTypeRegistry()->fromJson<ItemSkillLevelUpRule>(
             zJson->zValue("levelUpRule")));
-    zResult->setMaxFluidAmount(
+    result->setMaxFluidAmount(
         (int)zJson->zValue("maxFluidAmount")->asNumber()->getNumber());
-    ItemTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void FluidContainerItemTypeFactory::toJson(
-    FluidContainerItemType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* FluidContainerItemTypeFactory::toJsonObject(
+    FluidContainerItemType* zObject) const
 {
-    zResult->addValue("levelUpRule",
+    Framework::JSON::JSONObject* result
+        = ItemTypeFactoryBase::toJsonObject(zObject);
+    result->addValue("levelUpRule",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zLevelUpRule()));
-    zResult->addValue("itemSkill",
+    result->addValue("itemSkill",
         dynamic_cast<Framework::JSON::JSONObject*>(
             zObject->zItemSkillConfig()->getThis()));
-    zResult->addValue("maxFluidAmount",
+    result->addValue("maxFluidAmount",
         new Framework::JSON::JSONNumber(zObject->getMaxFluidAmount()));
-    ItemTypeFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* FluidContainerItemTypeFactory::addToValidator(
@@ -764,7 +765,7 @@ JSONObjectValidationBuilder* FluidContainerItemTypeFactory::addToValidator(
             ->finishNumber());
 }
 
-Framework::Text FluidContainerItemTypeFactory::getTypeToken() const
+const char* FluidContainerItemTypeFactory::getTypeToken() const
 {
     return "fluidContainer";
 }

+ 12 - 14
FactoryCraft/FluidContainer.h

@@ -61,16 +61,14 @@ public:
 };
 
 class FluidContainerItemSkillConfigFactory
-    : public TypeFactory<FluidContainerItemSkillConfig>
+    : public ObjectTypeFactory<FluidContainerItemSkillConfig>
 {
 public:
     FluidContainerItemSkillConfigFactory();
-    FluidContainerItemSkillConfig* createValue(
+    FluidContainerItemSkillConfig* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(FluidContainerItemSkillConfig* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(FluidContainerItemSkillConfig* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        FluidContainerItemSkillConfig* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -100,13 +98,13 @@ public:
     FluidContainerItemSkillFactory();
     FluidContainerItemSkill* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(FluidContainerItemSkill* zResult,
+    FluidContainerItemSkill* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(FluidContainerItemSkill* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        FluidContainerItemSkill* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class FluidContainerItemType : public ItemType
@@ -150,11 +148,11 @@ public:
     FluidContainerItemTypeFactory();
     FluidContainerItemType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(FluidContainerItemType* zResult,
+    FluidContainerItemType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(FluidContainerItemType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        FluidContainerItemType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 7 - 7
FactoryCraft/Game.cpp

@@ -111,19 +111,19 @@ void Game::initialize()
     // load block types
     Framework::Logging::info() << "Loading block types";
     Framework::Array<BlockType*> blockTypeArray;
-    Framework::JSON::Validator::JSONValidator* validator
-        = Framework::JSON::Validator::JSONValidator::buildForArray()
+    Framework::Validator::DataValidator* validator
+        = Framework::Validator::DataValidator::buildForArray()
               ->addAcceptedTypeInArray(typeRegistry->getValidator<BlockType>())
               ->removeInvalidEntries()
               ->finishArray();
     loadAllJsonsFromDirectory("data/blocks",
         [this, &blockTypeArray, validator](
             Framework::JSON::JSONValue* zValue, Framework::Text path) {
-            Framework::RCArray<Framework::JSON::Validator::JSONValidationResult>
+            Framework::RCArray<Framework::Validator::ValidationResult>
                 validationResults;
             Framework::JSON::JSONValue* validParts
                 = validator->getValidParts(zValue, &validationResults);
-            for (Framework::JSON::Validator::JSONValidationResult* result :
+            for (Framework::Validator::ValidationResult* result :
                 validationResults)
             {
                 Framework::Logging::error() << result->getInvalidInfo();
@@ -161,18 +161,18 @@ void Game::initialize()
     Framework::Logging::info() << "Loading item types";
     Framework::Array<ItemType*> itemTypeArray;
     validator
-        = Framework::JSON::Validator::JSONValidator::buildForArray()
+        = Framework::Validator::DataValidator::buildForArray()
               ->addAcceptedTypeInArray(typeRegistry->getValidator<ItemType>())
               ->removeInvalidEntries()
               ->finishArray();
     loadAllJsonsFromDirectory("data/items",
         [this, &itemTypeArray, validator](
             Framework::JSON::JSONValue* zValue, Framework::Text path) {
-            Framework::RCArray<Framework::JSON::Validator::JSONValidationResult>
+            Framework::RCArray<Framework::Validator::ValidationResult>
                 validationResults;
             Framework::JSON::JSONValue* validParts
                 = validator->getValidParts(zValue, &validationResults);
-            for (Framework::JSON::Validator::JSONValidationResult* result :
+            for (Framework::Validator::ValidationResult* result :
                 validationResults)
             {
                 Framework::Logging::error() << result->getInvalidInfo();

+ 13 - 6
FactoryCraft/GeneratorRule.h

@@ -47,9 +47,10 @@ public:
         : SubTypeFactory<GeneratorRule, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        GeneratorRule* zRule = dynamic_cast<GeneratorRule*>(zResult);
+        S* result = createValue(zJson);
+        GeneratorRule* zRule = dynamic_cast<GeneratorRule*>(result);
         if (zJson->hasValue("noise"))
         {
             zRule->setNoiseConfig(zJson->getValue("noise")->asObject());
@@ -62,23 +63,26 @@ public:
         zRule->setCondition(
             Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(
                 zJson->zValue("condition")));
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
         GeneratorRule* zRule = dynamic_cast<GeneratorRule*>(zObject);
         if (zRule->zNoiseConfig())
         {
-            zResult->addValue("noise",
+            result->addValue("noise",
                 dynamic_cast<Framework::JSON::JSONValue*>(
                     zRule->zNoiseConfig()->getThis()));
         }
-        zResult->addValue("threshold",
+        result->addValue("threshold",
             new Framework::JSON::JSONNumber(zRule->getThreshold()));
-        zResult->addValue("condition",
+        result->addValue("condition",
             Game::INSTANCE->zTypeRegistry()->toJson(
                 dynamic_cast<Framework::JSON::JSONValue*>(
                     zRule->zCondition()->getThis())));
+        return result;
     }
 
     JSONObjectValidationBuilder* addToValidator(
@@ -95,4 +99,7 @@ public:
             ->whichIsLessOrEqual(1.0)
             ->finishNumber();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };

+ 12 - 5
FactoryCraft/GeneratorTemplate.h

@@ -41,18 +41,22 @@ public:
         : SubTypeFactory<GeneratorTemplate, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        GeneratorTemplate* zRecipie = dynamic_cast<GeneratorTemplate*>(zResult);
+        S* result = createValue(zJson);
+        GeneratorTemplate* zRecipie = dynamic_cast<GeneratorTemplate*>(result);
         zRecipie->setPropability(
             (float)zJson->zValue("propability")->asNumber()->getNumber());
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
-        GeneratorTemplate* zRecipie = dynamic_cast<GeneratorTemplate*>(zResult);
-        zResult->addValue("propability",
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+        GeneratorTemplate* zRecipie = dynamic_cast<GeneratorTemplate*>(result);
+        result->addValue("propability",
             new Framework::JSON::JSONNumber(zRecipie->getPropability()));
+        return result;
     };
 
     JSONObjectValidationBuilder* addToValidator(
@@ -60,4 +64,7 @@ public:
     {
         return builder->withRequiredNumber("propability")->finishNumber();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };

+ 15 - 10
FactoryCraft/Grass.cpp

@@ -68,34 +68,39 @@ Block* GrassBlockType::createBlock(
 }
 
 GrassBlockTypeFactory::GrassBlockTypeFactory()
-    : SubTypeFactory()
+    : AdditionalItemSpawningBlockTypeFactory()
 {}
 
-GrassBlockType* GrassBlockTypeFactory::createValue(
+BasicBlockType* GrassBlockTypeFactory::createValue(
     Framework::JSON::JSONObject* zJson) const
 {
     return new GrassBlockType();
 }
 
-void GrassBlockTypeFactory::fromJson(
-    GrassBlockType* zResult, Framework::JSON::JSONObject* zJson) const
+BasicBlockType* GrassBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    super.fromJson(zResult, zJson);
+    return AdditionalItemSpawningBlockTypeFactory::fromJson(zJson);
 }
 
-void GrassBlockTypeFactory::toJson(
-    GrassBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* GrassBlockTypeFactory::toJsonObject(
+    BasicBlockType* zObject) const
 {
-    super.toJson(zObject, zResult);
+    return AdditionalItemSpawningBlockTypeFactory::toJsonObject(zObject);
 }
 
 JSONObjectValidationBuilder* GrassBlockTypeFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
 {
-    return super.addToValidator(builder);
+    return AdditionalItemSpawningBlockTypeFactory::addToValidator(builder);
 }
 
-Framework::Text GrassBlockTypeFactory::getTypeToken() const
+const char* GrassBlockTypeFactory::getTypeToken() const
 {
     return "grass";
 }
+
+const char* GrassBlockTypeFactory::getTypeName() const
+{
+    return typeid(GrassBlockType).name();
+}

+ 7 - 10
FactoryCraft/Grass.h

@@ -38,20 +38,17 @@ public:
     virtual ItemType* createItemType() const override;
 };
 
-class GrassBlockTypeFactory : public SubTypeFactory<BlockType, GrassBlockType>
+class GrassBlockTypeFactory : public AdditionalItemSpawningBlockTypeFactory
 {
-private:
-    AdditionalItemSpawningBlockTypeFactory super;
-
 public:
     GrassBlockTypeFactory();
-    GrassBlockType* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(GrassBlockType* zResult,
+    BasicBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(GrassBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    BasicBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
+    const char* getTypeName() const override;
 };

+ 30 - 27
FactoryCraft/GrowingPlant.cpp

@@ -287,51 +287,53 @@ GrowingPlantBlockType* GrowingPlantBlockTypeFactory::createValue(
     return new GrowingPlantBlockType();
 }
 
-void GrowingPlantBlockTypeFactory::fromJson(
-    GrowingPlantBlockType* zResult, Framework::JSON::JSONObject* zJson) const
+GrowingPlantBlockType* GrowingPlantBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setBlockTypeNameAfterGrowth(
+    GrowingPlantBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
+    result->setBlockTypeNameAfterGrowth(
         zJson->zValue("blockTypeAfterGrowth")->asString()->getString());
-    zResult->setReadableName(
+    result->setReadableName(
         zJson->zValue("readableName")->asString()->getString());
-    zResult->setTicksNeeded(
+    result->setTicksNeeded(
         (int)zJson->zValue("ticksNeeded")->asNumber()->getNumber());
-    zResult->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
-    zResult->setPassable(zJson->zValue("passable")->asBool()->getBool());
-    zResult->setSpeedModifier(
+    result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
+    result->setPassable(zJson->zValue("passable")->asBool()->getBool());
+    result->setSpeedModifier(
         (float)zJson->zValue("speedModifier")->asNumber()->getNumber());
-    zResult->setInteractable(
-        zJson->zValue("interactable")->asBool()->getBool());
+    result->setInteractable(zJson->zValue("interactable")->asBool()->getBool());
     for (Framework::JSON::JSONValue* state :
         *zJson->zValue("states")->asArray())
     {
-        zResult->addGrowthState((float)state->asObject()
-                                    ->zValue("percentage")
-                                    ->asNumber()
-                                    ->getNumber(),
+        result->addGrowthState((float)state->asObject()
+                                   ->zValue("percentage")
+                                   ->asNumber()
+                                   ->getNumber(),
             Game::INSTANCE->zTypeRegistry()->fromJson<ModelInfo>(
                 state->asObject()->zValue("model")));
     }
-    BlockTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void GrowingPlantBlockTypeFactory::toJson(
-    GrowingPlantBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* GrowingPlantBlockTypeFactory::toJsonObject(
+    GrowingPlantBlockType* zObject) const
 {
-    zResult->addValue("readableName",
+    Framework::JSON::JSONObject* result
+        = BlockTypeFactoryBase::toJsonObject(zObject);
+    result->addValue("readableName",
         new Framework::JSON::JSONString(zObject->getReadableName()));
-    zResult->addValue(
+    result->addValue(
         "model", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zModel()));
-    zResult->addValue(
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
-    zResult->addValue(
+    result->addValue(
         "hardness", new Framework::JSON::JSONNumber(zObject->getHardness()));
-    zResult->addValue(
+    result->addValue(
         "mapColor", new Framework::JSON::JSONString(zObject->getMapColor()));
-    zResult->addValue("blockTypeAfterGrowth",
+    result->addValue("blockTypeAfterGrowth",
         new Framework::JSON::JSONString(
             zObject->getBlockTypeNameAfterGrowth()));
-    zResult->addValue("ticksNeeded",
+    result->addValue("ticksNeeded",
         new Framework::JSON::JSONNumber((double)zObject->getTicksNeeded()));
     Framework::JSON::JSONArray* states = new Framework::JSON::JSONArray();
     for (GrowthState* state : zObject->getStates())
@@ -344,13 +346,14 @@ void GrowingPlantBlockTypeFactory::toJson(
             new Framework::JSON::JSONNumber(state->getPercentage()));
         states->addValue(stateObj);
     }
-    zResult->addValue("states", states);
+    result->addValue("states", states);
     Framework::JSON::JSONArray* groupNames = new Framework::JSON::JSONArray();
     for (Framework::Text* groupName : zObject->getGroupNames())
     {
         groupNames->addValue(new Framework::JSON::JSONString(*groupName));
     }
-    zResult->addValue("groupNames", groupNames);
+    result->addValue("groupNames", groupNames);
+    return result;
 }
 
 JSONObjectValidationBuilder* GrowingPlantBlockTypeFactory::addToValidator(
@@ -387,7 +390,7 @@ JSONObjectValidationBuilder* GrowingPlantBlockTypeFactory::addToValidator(
             ->finishBool());
 }
 
-Framework::Text GrowingPlantBlockTypeFactory::getTypeToken() const
+const char* GrowingPlantBlockTypeFactory::getTypeToken() const
 {
     return "growingPlant";
 }

+ 4 - 4
FactoryCraft/GrowingPlant.h

@@ -103,11 +103,11 @@ public:
     GrowingPlantBlockTypeFactory();
     GrowingPlantBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(GrowingPlantBlockType* zResult,
+    GrowingPlantBlockType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(GrowingPlantBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        GrowingPlantBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 10 - 15
FactoryCraft/Item.cpp

@@ -171,36 +171,31 @@ bool Item::canApplyFoodEffectsFully(Entity* zTarget) const
 }
 
 ItemJsonType::ItemJsonType()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-Item* ItemJsonType::createValue(Framework::JSON::JSONObject* zJson) const
-{
-    const ItemType* type = ItemType::zByName(
-        zJson->asObject()->zValue("type")->asString()->getString());
-    return type->createItem();
-}
-
-void ItemJsonType::fromJson(
-    Item* zResult, Framework::JSON::JSONObject* zJson) const
+Item* ItemJsonType::fromJson(Framework::JSON::JSONObject* zJson) const
 {
     const ItemType* type = ItemType::zByName(
         zJson->asObject()->zValue("type")->asString()->getString());
+    Item* result = type->createItem();
     for (auto attribute = zJson->asObject()->getFields(); attribute;
          attribute++)
     {
         if (attribute.val().istGleich("type")) continue;
         type->setItemAttribute(
-            zResult, attribute, zJson->asObject()->zValue(attribute));
+            result, attribute, zJson->asObject()->zValue(attribute));
     }
+    return result;
 }
 
-void ItemJsonType::toJson(
-    Item* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* ItemJsonType::toJsonObject(Item* zObject) const
 {
-    zResult->addValue("type",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("type",
         new Framework::JSON::JSONString(zObject->zItemType()->getName()));
-    zObject->zItemType()->addItemAttributes(zObject, zResult);
+    zObject->zItemType()->addItemAttributes(zObject, result);
+    return result;
 }
 
 JSONObjectValidationBuilder* ItemJsonType::addToValidator(

+ 3 - 6
FactoryCraft/Item.h

@@ -66,15 +66,12 @@ public:
     friend ItemType;
 };
 
-class ItemJsonType : public TypeFactory<Item>
+class ItemJsonType : public ObjectTypeFactory<Item>
 {
 public:
     ItemJsonType();
-    Item* createValue(Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(
-        Item* zResult, Framework::JSON::JSONObject* zJson) const override;
-    void toJson(
-        Item* zObject, Framework::JSON::JSONObject* zResult) const override;
+    Item* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(Item* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 39 - 48
FactoryCraft/ItemFilter.cpp

@@ -137,15 +137,10 @@ CombinedItemFilterFactory::CombinedItemFilterFactory()
     : SubTypeFactory()
 {}
 
-CombinedItemFilter* CombinedItemFilterFactory::createValue(
+CombinedItemFilter* CombinedItemFilterFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new CombinedItemFilter();
-}
-
-void CombinedItemFilterFactory::fromJson(
-    CombinedItemFilter* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    CombinedItemFilter* result = new CombinedItemFilter();
     std::function<bool(bool, bool)> func;
     Framework::Text op = zJson->zValue("operator")->asString()->getString();
     if (op.istGleich("or"))
@@ -212,19 +207,21 @@ void CombinedItemFilterFactory::fromJson(
     {
         func = [](bool a, bool b) { return false; };
     }
-    zResult->setOp(func);
+    result->setOp(func);
     Framework::RCArray<ItemFilter> filters;
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("filters")->asArray())
     {
-        zResult->addFilter(
+        result->addFilter(
             Game::INSTANCE->zTypeRegistry()->fromJson<ItemFilter>(value));
     }
+    return result;
 }
 
-void CombinedItemFilterFactory::toJson(
-    CombinedItemFilter* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* CombinedItemFilterFactory::toJsonObject(
+    CombinedItemFilter* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::Text op;
     std::function<bool(bool, bool)> func = zObject->getOp();
     if (func(0, 0))
@@ -333,14 +330,14 @@ void CombinedItemFilterFactory::toJson(
             }
         }
     }
-    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
-    zResult->addValue("operator", new Framework::JSON::JSONString(op));
+    result->addValue("operator", new Framework::JSON::JSONString(op));
     Framework::JSON::JSONArray* filters = new Framework::JSON::JSONArray();
     for (ItemFilter* filter : zObject->getFilters())
     {
         filters->addValue(Game::INSTANCE->zTypeRegistry()->toJson(filter));
     }
-    zResult->addValue("filters", filters);
+    result->addValue("filters", filters);
+    return result;
 }
 
 JSONObjectValidationBuilder* CombinedItemFilterFactory::addToValidator(
@@ -370,7 +367,7 @@ JSONObjectValidationBuilder* CombinedItemFilterFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text CombinedItemFilterFactory::getTypeToken() const
+const char* CombinedItemFilterFactory::getTypeToken() const
 {
     return "operator";
 }
@@ -393,19 +390,17 @@ AnyItemFilterFactory::AnyItemFilterFactory()
     : SubTypeFactory()
 {}
 
-AnyItemFilter* AnyItemFilterFactory::createValue(
+AnyItemFilter* AnyItemFilterFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
     return new AnyItemFilter();
 }
 
-void AnyItemFilterFactory::fromJson(
-    AnyItemFilter* zResult, Framework::JSON::JSONObject* zJson) const
-{}
-
-void AnyItemFilterFactory::toJson(
-    AnyItemFilter* zObject, Framework::JSON::JSONObject* zResult) const
-{}
+Framework::JSON::JSONObject* AnyItemFilterFactory::toJsonObject(
+    AnyItemFilter* zObject) const
+{
+    return new Framework::JSON::JSONObject();
+}
 
 JSONObjectValidationBuilder* AnyItemFilterFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
@@ -413,7 +408,7 @@ JSONObjectValidationBuilder* AnyItemFilterFactory::addToValidator(
     return builder;
 }
 
-Framework::Text AnyItemFilterFactory::getTypeToken() const
+const char* AnyItemFilterFactory::getTypeToken() const
 {
     return "anyItem";
 }
@@ -449,24 +444,22 @@ TypeItemFilterFactory::TypeItemFilterFactory()
     : SubTypeFactory()
 {}
 
-TypeItemFilter* TypeItemFilterFactory::createValue(
+TypeItemFilter* TypeItemFilterFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new TypeItemFilter();
-}
-
-void TypeItemFilterFactory::fromJson(
-    TypeItemFilter* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setType(Game::INSTANCE->zItemType(Game::INSTANCE->getItemTypeId(
+    TypeItemFilter* result = new TypeItemFilter();
+    result->setType(Game::INSTANCE->zItemType(Game::INSTANCE->getItemTypeId(
         zJson->zValue("itemType")->asString()->getString())));
+    return result;
 }
 
-void TypeItemFilterFactory::toJson(
-    TypeItemFilter* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* TypeItemFilterFactory::toJsonObject(
+    TypeItemFilter* zObject) const
 {
-    zResult->addValue("itemType",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("itemType",
         new Framework::JSON::JSONString(zObject->zType()->getName()));
+    return result;
 }
 
 JSONObjectValidationBuilder* TypeItemFilterFactory::addToValidator(
@@ -486,7 +479,7 @@ JSONObjectValidationBuilder* TypeItemFilterFactory::addToValidator(
         ->finishString();
 }
 
-Framework::Text TypeItemFilterFactory::getTypeToken() const
+const char* TypeItemFilterFactory::getTypeToken() const
 {
     return "type";
 }
@@ -631,31 +624,29 @@ GroupItemFilterFactory::GroupItemFilterFactory()
     : SubTypeFactory()
 {}
 
-GroupItemFilter* GroupItemFilterFactory::createValue(
+GroupItemFilter* GroupItemFilterFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new GroupItemFilter();
-}
-
-void GroupItemFilterFactory::fromJson(
-    GroupItemFilter* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    GroupItemFilter* result = new GroupItemFilter();
     for (Framework::JSON::JSONValue* group :
         *zJson->zValue("groupNames")->asArray())
     {
-        zResult->addGroup(group->asString()->getString());
+        result->addGroup(group->asString()->getString());
     }
+    return result;
 }
 
-void GroupItemFilterFactory::toJson(
-    GroupItemFilter* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* GroupItemFilterFactory::toJsonObject(
+    GroupItemFilter* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* groups = new Framework::JSON::JSONArray();
     for (Framework::Text* group : zObject->getGroups())
     {
         groups->addValue(new Framework::JSON::JSONString(group->getText()));
     }
-    zResult->addValue("groupNames", groups);
+    result->addValue("groupNames", groups);
+    return result;
 }
 
 JSONObjectValidationBuilder* GroupItemFilterFactory::addToValidator(
@@ -667,7 +658,7 @@ JSONObjectValidationBuilder* GroupItemFilterFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text GroupItemFilterFactory::getTypeToken() const
+const char* GroupItemFilterFactory::getTypeToken() const
 {
     return "groups";
 }

+ 16 - 26
FactoryCraft/ItemFilter.h

@@ -44,15 +44,13 @@ class CombinedItemFilterFactory
 {
 public:
     CombinedItemFilterFactory();
-    CombinedItemFilter* createValue(
+    CombinedItemFilter* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(CombinedItemFilter* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(CombinedItemFilter* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        CombinedItemFilter* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class AnyItemFilter : public ItemFilter
@@ -67,15 +65,12 @@ class AnyItemFilterFactory : public SubTypeFactory<ItemFilter, AnyItemFilter>
 {
 public:
     AnyItemFilterFactory();
-    AnyItemFilter* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(AnyItemFilter* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(AnyItemFilter* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    AnyItemFilter* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        AnyItemFilter* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class TypeItemFilter : public ItemFilter
@@ -95,15 +90,12 @@ class TypeItemFilterFactory : public SubTypeFactory<ItemFilter, TypeItemFilter>
 {
 public:
     TypeItemFilterFactory();
-    TypeItemFilter* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(TypeItemFilter* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(TypeItemFilter* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    TypeItemFilter* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        TypeItemFilter* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class SpecificSlotFilter : public ItemFilter
@@ -163,13 +155,11 @@ class GroupItemFilterFactory
 {
 public:
     GroupItemFilterFactory();
-    GroupItemFilter* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(GroupItemFilter* zResult,
+    GroupItemFilter* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(GroupItemFilter* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        GroupItemFilter* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 34 - 42
FactoryCraft/ItemModifier.cpp

@@ -21,19 +21,17 @@ ConsumeItemModifierFactory::ConsumeItemModifierFactory()
     : SubTypeFactory()
 {}
 
-ConsumeItemModifier* ConsumeItemModifierFactory::createValue(
+ConsumeItemModifier* ConsumeItemModifierFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
     return new ConsumeItemModifier();
 }
 
-void ConsumeItemModifierFactory::fromJson(
-    ConsumeItemModifier* zResult, Framework::JSON::JSONObject* zJson) const
-{}
-
-void ConsumeItemModifierFactory::toJson(
-    ConsumeItemModifier* zObject, Framework::JSON::JSONObject* zResult) const
-{}
+Framework::JSON::JSONObject* ConsumeItemModifierFactory::toJsonObject(
+    ConsumeItemModifier* zObject) const
+{
+    return new Framework::JSON::JSONObject();
+}
 
 JSONObjectValidationBuilder* ConsumeItemModifierFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
@@ -41,7 +39,7 @@ JSONObjectValidationBuilder* ConsumeItemModifierFactory::addToValidator(
     return builder;
 }
 
-Framework::Text ConsumeItemModifierFactory::getTypeToken() const
+const char* ConsumeItemModifierFactory::getTypeToken() const
 {
     return "consume";
 }
@@ -59,19 +57,17 @@ DoNothingModifierFactory::DoNothingModifierFactory()
     : SubTypeFactory()
 {}
 
-DoNothingModifier* DoNothingModifierFactory::createValue(
+DoNothingModifier* DoNothingModifierFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
     return new DoNothingModifier();
 }
 
-void DoNothingModifierFactory::fromJson(
-    DoNothingModifier* zResult, Framework::JSON::JSONObject* zJson) const
-{}
-
-void DoNothingModifierFactory::toJson(
-    DoNothingModifier* zObject, Framework::JSON::JSONObject* zResult) const
-{}
+Framework::JSON::JSONObject* DoNothingModifierFactory::toJsonObject(
+    DoNothingModifier* zObject) const
+{
+    return new Framework::JSON::JSONObject();
+}
 
 JSONObjectValidationBuilder* DoNothingModifierFactory::addToValidator(
     JSONObjectValidationBuilder* builder) const
@@ -79,7 +75,7 @@ JSONObjectValidationBuilder* DoNothingModifierFactory::addToValidator(
     return builder;
 }
 
-Framework::Text DoNothingModifierFactory::getTypeToken() const
+const char* DoNothingModifierFactory::getTypeToken() const
 {
     return "doNothing";
 }
@@ -124,40 +120,38 @@ AttributeItemModifierFactory::AttributeItemModifierFactory()
     : SubTypeFactory()
 {}
 
-AttributeItemModifier* AttributeItemModifierFactory::createValue(
+AttributeItemModifier* AttributeItemModifierFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new AttributeItemModifier();
-}
-
-void AttributeItemModifierFactory::fromJson(
-    AttributeItemModifier* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    AttributeItemModifier* result = new AttributeItemModifier();
     auto attribute = zJson->getFields();
     auto value = zJson->getValues();
     while (attribute, value)
     {
         if (!attribute.val().istGleich("type"))
         {
-            zResult->addAttribute(attribute.val(), value);
+            result->addAttribute(attribute.val(), value);
         }
         attribute++;
         value++;
     }
+    return result;
 }
 
-void AttributeItemModifierFactory::toJson(
-    AttributeItemModifier* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* AttributeItemModifierFactory::toJsonObject(
+    AttributeItemModifier* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     auto attribute = zObject->getAttributes().begin();
     auto value = zObject->getValues().begin();
     while (attribute && value)
     {
-        zResult->addValue(attribute->getText(),
+        result->addValue(attribute->getText(),
             dynamic_cast<Framework::JSON::JSONObject*>(value->getThis()));
         attribute++;
         value++;
     }
+    return result;
 }
 
 JSONObjectValidationBuilder* AttributeItemModifierFactory::addToValidator(
@@ -166,7 +160,7 @@ JSONObjectValidationBuilder* AttributeItemModifierFactory::addToValidator(
     return builder->allowAdditionalAttriutes();
 }
 
-Framework::Text AttributeItemModifierFactory::getTypeToken() const
+const char* AttributeItemModifierFactory::getTypeToken() const
 {
     return "attributes";
 }
@@ -198,32 +192,30 @@ CombinedItemModifierFactory::CombinedItemModifierFactory()
     : SubTypeFactory()
 {}
 
-CombinedItemModifier* CombinedItemModifierFactory::createValue(
+CombinedItemModifier* CombinedItemModifierFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new CombinedItemModifier();
-}
-
-void CombinedItemModifierFactory::fromJson(
-    CombinedItemModifier* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    CombinedItemModifier* result = new CombinedItemModifier();
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("modifiers")->asArray())
     {
-        zResult->addModifier(
+        result->addModifier(
             Game::INSTANCE->zTypeRegistry()->fromJson<ItemModifier>(value));
     }
+    return result;
 }
 
-void CombinedItemModifierFactory::toJson(
-    CombinedItemModifier* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* CombinedItemModifierFactory::toJsonObject(
+    CombinedItemModifier* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* modifiers = new Framework::JSON::JSONArray();
     for (ItemModifier* modifier : zObject->getModifiers())
     {
         modifiers->addValue(Game::INSTANCE->zTypeRegistry()->toJson(modifier));
     }
-    zResult->addValue("modifiers", modifiers);
+    result->addValue("modifiers", modifiers);
+    return result;
 }
 
 JSONObjectValidationBuilder* CombinedItemModifierFactory::addToValidator(
@@ -235,7 +227,7 @@ JSONObjectValidationBuilder* CombinedItemModifierFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text CombinedItemModifierFactory::getTypeToken() const
+const char* CombinedItemModifierFactory::getTypeToken() const
 {
     return "combined";
 }

+ 16 - 24
FactoryCraft/ItemModifier.h

@@ -24,15 +24,13 @@ class ConsumeItemModifierFactory
 {
 public:
     ConsumeItemModifierFactory();
-    ConsumeItemModifier* createValue(
+    ConsumeItemModifier* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(ConsumeItemModifier* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(ConsumeItemModifier* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        ConsumeItemModifier* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class DoNothingModifier : public ItemModifier
@@ -47,15 +45,13 @@ class DoNothingModifierFactory
 {
 public:
     DoNothingModifierFactory();
-    DoNothingModifier* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(DoNothingModifier* zResult,
+    DoNothingModifier* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(DoNothingModifier* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        DoNothingModifier* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class AttributeItemModifier : public ItemModifier
@@ -77,15 +73,13 @@ class AttributeItemModifierFactory
 {
 public:
     AttributeItemModifierFactory();
-    AttributeItemModifier* createValue(
+    AttributeItemModifier* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(AttributeItemModifier* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(AttributeItemModifier* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        AttributeItemModifier* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class CombinedItemModifier : public ItemModifier
@@ -104,13 +98,11 @@ class CombinedItemModifierFactory
 {
 public:
     CombinedItemModifierFactory();
-    CombinedItemModifier* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(CombinedItemModifier* zResult,
+    CombinedItemModifier* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(CombinedItemModifier* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        CombinedItemModifier* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 14 - 8
FactoryCraft/ItemSkill.h

@@ -3,6 +3,7 @@
 #include <JSON.h>
 #include <Reader.h>
 #include <ReferenceCounter.h>
+#include <Writer.h>
 
 #include "TypeRegistry.h"
 
@@ -50,26 +51,28 @@ template<typename S> class ItemSkillFactoryBase
 {
 public:
     ItemSkillFactoryBase()
-        : SubTypeFactory<ItemSkill, S>(){};
+        : SubTypeFactory<ItemSkill, S>() {};
 
-    virtual void fromJson(
-        S* zResult, Framework::JSON::JSONObject* zJson) const override
+    virtual S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        ItemSkill* zSkill = dynamic_cast<ItemSkill*>(zResult);
+        S* result = createValue(zJson);
+        ItemSkill* zSkill = dynamic_cast<ItemSkill*>(result);
         zSkill->setMaxXp(
             (float)zJson->zValue("maxXp")->asNumber()->getNumber());
         zSkill->setLevel(
             (float)zJson->zValue("level")->asNumber()->getNumber());
+        return result;
     }
 
-    virtual void toJson(
-        S* zObject, Framework::JSON::JSONObject* zResult) const override
+    virtual Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
         ItemSkill* zSkill = dynamic_cast<ItemSkill*>(zObject);
-        zResult->addValue(
+        result->addValue(
             "maxXp", new Framework::JSON::JSONNumber(zSkill->getMaxXp()));
-        zResult->addValue(
+        result->addValue(
             "level", new Framework::JSON::JSONNumber(zSkill->getLevel()));
+        return result;
     }
 
     virtual JSONObjectValidationBuilder* addToValidator(
@@ -82,4 +85,7 @@ public:
             ->withDefault(1.f)
             ->finishNumber();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };

+ 2 - 2
FactoryCraft/ItemType.cpp

@@ -112,7 +112,7 @@ void ItemType::setItemAttribute(
     Item* zItem, Framework::Text name, Framework::JSON::JSONValue* zValue) const
 {
     bool ok = true;
-    if (zValue->getType() == Framework::JSON::JSONType::NUMBER)
+    if (zValue->getType() == Framework::AbstractType::NUMBER)
     {
         if (name.istGleich("hp"))
             zItem->hp = (float)zValue->asNumber()->getNumber();
@@ -125,7 +125,7 @@ void ItemType::setItemAttribute(
         else
             ok = false;
     }
-    else if (zValue->getType() == Framework::JSON::JSONType::STRING)
+    else if (zValue->getType() == Framework::AbstractType::STRING)
     {
         if (name.istGleich("name"))
             zItem->name = zValue->asString()->getString();

+ 12 - 6
FactoryCraft/ItemType.h

@@ -99,10 +99,10 @@ public:
         : SubTypeFactory<ItemType, S>()
     {}
 
-    virtual void fromJson(
-        S* zResult, Framework::JSON::JSONObject* zJson) const override
+    virtual S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        ItemType* zType = dynamic_cast<ItemType*>(zResult);
+        S* result = createValue(zJson);
+        ItemType* zType = dynamic_cast<ItemType*>(result);
         zType->setModel(Game::INSTANCE->zTypeRegistry()->fromJson<ModelInfo>(
             zJson->zValue("model")->asObject()));
         zType->setName(zJson->zValue("name")->asString()->getString());
@@ -118,12 +118,14 @@ public:
         {
             zType->addGroup(value->asString()->getString());
         }
+        return result;
     }
 
-    virtual void toJson(
-        S* zObject, Framework::JSON::JSONObject* zResult) const override
+    virtual Framework::JSON::JSONObject* toJsonObject(S* zObject) const
     {
-        ItemType* zType = dynamic_cast<ItemType*>(zResult);
+        Framework::JSON::JSONObject* zResult
+            = new Framework::JSON::JSONObject();
+        ItemType* zType = dynamic_cast<ItemType*>(zObject);
         zResult->addValue("model",
             Game::INSTANCE->zTypeRegistry()->toJson<ModelInfo>(
                 zType->zModel()));
@@ -140,6 +142,7 @@ public:
             groupNames->addValue(new Framework::JSON::JSONString(*groupName));
         }
         zResult->addValue("groupNames", groupNames);
+        return zResult;
     }
 
     virtual JSONObjectValidationBuilder* addToValidator(
@@ -162,4 +165,7 @@ public:
             ->finishString()
             ->finishArray();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };

+ 77 - 86
FactoryCraft/JNoise.cpp

@@ -289,15 +289,15 @@ Noise* JNoise::parseNoise(JSON::JSONValue* zConfig, JExpressionMemory* zMemory)
     return 0;
 }
 
-JSON::Validator::JSONValidator* JNoise::getValidator(bool optional)
+Validator::DataValidator* JNoise::getValidator(bool optional)
 {
-    auto validator1 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator2 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator3 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator4 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator5 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator6 = JSON::Validator::JSONValidator::buildForObject();
-    auto validator7 = JSON::Validator::JSONValidator::buildForObject();
+    auto validator1 = Validator::DataValidator::buildForObject();
+    auto validator2 = Validator::DataValidator::buildForObject();
+    auto validator3 = Validator::DataValidator::buildForObject();
+    auto validator4 = Validator::DataValidator::buildForObject();
+    auto validator5 = Validator::DataValidator::buildForObject();
+    auto validator6 = Validator::DataValidator::buildForObject();
+    auto validator7 = Validator::DataValidator::buildForObject();
     if (optional)
     {
         validator1 = validator1->whichIsOptional();
@@ -308,34 +308,27 @@ JSON::Validator::JSONValidator* JNoise::getValidator(bool optional)
         validator6 = validator6->whichIsOptional();
         validator7 = validator7->whichIsOptional();
     }
-    JSON::Validator::JSONValidator* refs
-        = JSON::Validator::JSONValidator::buildForOneOf()
+    Validator::DataValidator* refs
+        = Validator::DataValidator::buildForOneOf()
               ->typeSpecifiedByAttribute("type")
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_random"))
+                  Validator::DataValidator::buildForReference("jn_random"))
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_factorize"))
+                  Validator::DataValidator::buildForReference("jn_factorize"))
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_multiply"))
+                  Validator::DataValidator::buildForReference("jn_multiply"))
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_negate"))
+                  Validator::DataValidator::buildForReference("jn_negate"))
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_flatten"))
+                  Validator::DataValidator::buildForReference("jn_flatten"))
               ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_scale"))
-              ->addAcceptedType(
-                  JSON::Validator::JSONValidator::buildForObjectReference(
-                      "jn_fastNoiseLite"))
+                  Validator::DataValidator::buildForReference("jn_scale"))
+              ->addAcceptedType(Validator::DataValidator::buildForReference(
+                  "jn_fastNoiseLite"))
               ->finishOneOf();
-    return JSON::Validator::JSONValidator::buildForOneOf()
+    return Validator::DataValidator::buildForOneOf()
         ->typeSpecifiedByAttribute("type")
-        ->addAcceptedType(validator1->setObjectReferenceId("jn_random")
+        ->addAcceptedType(validator1->setReferenceId("jn_random")
                               ->withRequiredString("type")
                               ->withExactMatch("random")
                               ->finishString()
@@ -343,66 +336,64 @@ JSON::Validator::JSONValidator* JNoise::getValidator(bool optional)
                                   Game::INSTANCE->zTypeRegistry()
                                       ->getValidator<JFloatExpression>())
                               ->finishObject())
-        ->addAcceptedType(validator2->setObjectReferenceId("jn_factorize")
-                              ->withRequiredString("type")
-                              ->withExactMatch("factorize")
-                              ->finishString()
-                              ->withRequiredNumber("factorA")
-                              ->whichIsGreaterThen(0)
-                              ->whichIsLessThen(1)
-                              ->finishNumber()
-                              ->withRequiredAttribute("noiseA",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->withRequiredAttribute("noiseB",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->finishObject())
-        ->addAcceptedType(validator3->setObjectReferenceId("jn_multiply")
-                              ->withRequiredString("type")
-                              ->withExactMatch("multiply")
-                              ->finishString()
-                              ->withRequiredAttribute("base",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->withRequiredAttribute("multiplier",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->finishObject())
-        ->addAcceptedType(validator4->setObjectReferenceId("jn_negate")
-                              ->withRequiredString("type")
-                              ->withExactMatch("negate")
-                              ->finishString()
-                              ->withRequiredAttribute("noise",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->finishObject())
-        ->addAcceptedType(validator5->setObjectReferenceId("jn_flatten")
-                              ->withRequiredString("type")
-                              ->withExactMatch("flatten")
-                              ->finishString()
-                              ->withRequiredAttribute("noise",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->withRequiredNumber("factor")
-                              ->withDefault(1.0)
-                              ->finishNumber()
-                              ->withRequiredNumber("addition")
-                              ->withDefault(0.0)
-                              ->finishNumber()
-                              ->finishObject())
-        ->addAcceptedType(validator6->setObjectReferenceId("jn_scale")
-                              ->withRequiredString("type")
-                              ->withExactMatch("scale")
-                              ->finishString()
-                              ->withRequiredAttribute("noise",
-                                  dynamic_cast<JSON::Validator::JSONValidator*>(
-                                      refs->getThis()))
-                              ->withRequiredNumber("factor")
-                              ->finishNumber()
-                              ->finishObject())
         ->addAcceptedType(
-            validator7->setObjectReferenceId("jn_fastNoiseLite")
+            validator2->setReferenceId("jn_factorize")
+                ->withRequiredString("type")
+                ->withExactMatch("factorize")
+                ->finishString()
+                ->withRequiredNumber("factorA")
+                ->whichIsGreaterThen(0)
+                ->whichIsLessThen(1)
+                ->finishNumber()
+                ->withRequiredAttribute("noiseA",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->withRequiredAttribute("noiseB",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->finishObject())
+        ->addAcceptedType(
+            validator3->setReferenceId("jn_multiply")
+                ->withRequiredString("type")
+                ->withExactMatch("multiply")
+                ->finishString()
+                ->withRequiredAttribute("base",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->withRequiredAttribute("multiplier",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->finishObject())
+        ->addAcceptedType(
+            validator4->setReferenceId("jn_negate")
+                ->withRequiredString("type")
+                ->withExactMatch("negate")
+                ->finishString()
+                ->withRequiredAttribute("noise",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->finishObject())
+        ->addAcceptedType(
+            validator5->setReferenceId("jn_flatten")
+                ->withRequiredString("type")
+                ->withExactMatch("flatten")
+                ->finishString()
+                ->withRequiredAttribute("noise",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->withRequiredNumber("factor")
+                ->withDefault(1.0)
+                ->finishNumber()
+                ->withRequiredNumber("addition")
+                ->withDefault(0.0)
+                ->finishNumber()
+                ->finishObject())
+        ->addAcceptedType(
+            validator6->setReferenceId("jn_scale")
+                ->withRequiredString("type")
+                ->withExactMatch("scale")
+                ->finishString()
+                ->withRequiredAttribute("noise",
+                    dynamic_cast<Validator::DataValidator*>(refs->getThis()))
+                ->withRequiredNumber("factor")
+                ->finishNumber()
+                ->finishObject())
+        ->addAcceptedType(
+            validator7->setReferenceId("jn_fastNoiseLite")
                 ->withRequiredString("type")
                 ->whichIsOneOf({"Cellular",
                     "ValueCubic",

+ 3 - 3
FactoryCraft/JNoise.h

@@ -2,12 +2,12 @@
 
 #include <JSON.h>
 
-#include "Noise.h"
 #include "JsonExpression.h"
+#include "Noise.h"
 
 namespace JNoise
 {
     Noise* parseNoise(
         Framework::JSON::JSONValue* zConfig, JExpressionMemory* zMemory);
-    Framework::JSON::Validator::JSONValidator* getValidator(bool optional);
-}
+    Framework::Validator::DataValidator* getValidator(bool optional);
+} // namespace JNoise

+ 122 - 149
FactoryCraft/JsonExpression.cpp

@@ -100,23 +100,21 @@ JVariableFloatExpressionFactory::JVariableFloatExpressionFactory()
     : SubTypeFactory()
 {}
 
-JVariableFloatExpression* JVariableFloatExpressionFactory::createValue(
+JVariableFloatExpression* JVariableFloatExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JVariableFloatExpression();
+    JVariableFloatExpression* result = new JVariableFloatExpression();
+    result->setName(zJson->zValue("name")->asString()->getString());
+    return result;
 }
 
-void JVariableFloatExpressionFactory::fromJson(
-    JVariableFloatExpression* zResult, Framework::JSON::JSONObject* zJson) const
+Framework::JSON::JSONObject* JVariableFloatExpressionFactory::toJsonObject(
+    JVariableFloatExpression* zObject) const
 {
-    zResult->setName(zJson->zValue("name")->asString()->getString());
-}
-
-void JVariableFloatExpressionFactory::toJson(JVariableFloatExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
-{
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
+    return result;
 }
 
 JSONObjectValidationBuilder* JVariableFloatExpressionFactory::addToValidator(
@@ -125,7 +123,7 @@ JSONObjectValidationBuilder* JVariableFloatExpressionFactory::addToValidator(
     return builder->withRequiredString("name")->finishString();
 }
 
-Framework::Text JVariableFloatExpressionFactory::getTypeToken() const
+const char* JVariableFloatExpressionFactory::getTypeToken() const
 {
     return "variable";
 }
@@ -153,23 +151,21 @@ JVariableBoolExpressionFactory::JVariableBoolExpressionFactory()
     : SubTypeFactory()
 {}
 
-JVariableBoolExpression* JVariableBoolExpressionFactory::createValue(
+JVariableBoolExpression* JVariableBoolExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JVariableBoolExpression();
-}
-
-void JVariableBoolExpressionFactory::fromJson(
-    JVariableBoolExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setName(zJson->zValue("name")->asString()->getString());
+    JVariableBoolExpression* result = new JVariableBoolExpression();
+    result->setName(zJson->zValue("name")->asString()->getString());
+    return result;
 }
 
-void JVariableBoolExpressionFactory::toJson(JVariableBoolExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JVariableBoolExpressionFactory::toJsonObject(
+    JVariableBoolExpression* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
+    return result;
 }
 
 JSONObjectValidationBuilder* JVariableBoolExpressionFactory::addToValidator(
@@ -178,7 +174,7 @@ JSONObjectValidationBuilder* JVariableBoolExpressionFactory::addToValidator(
     return builder->withRequiredString("name")->finishString();
 }
 
-Framework::Text JVariableBoolExpressionFactory::getTypeToken() const
+const char* JVariableBoolExpressionFactory::getTypeToken() const
 {
     return "variable";
 }
@@ -207,23 +203,21 @@ JConstantFloatExpressionFactory::JConstantFloatExpressionFactory()
     : SubTypeFactory()
 {}
 
-JConstantFloatExpression* JConstantFloatExpressionFactory::createValue(
+JConstantFloatExpression* JConstantFloatExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JConstantFloatExpression();
-}
-
-void JConstantFloatExpressionFactory::fromJson(
-    JConstantFloatExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setValue((float)zJson->zValue("value")->asNumber()->getNumber());
+    JConstantFloatExpression* result = new JConstantFloatExpression();
+    result->setValue((float)zJson->zValue("value")->asNumber()->getNumber());
+    return result;
 }
 
-void JConstantFloatExpressionFactory::toJson(JConstantFloatExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JConstantFloatExpressionFactory::toJsonObject(
+    JConstantFloatExpression* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "value", new Framework::JSON::JSONNumber(zObject->getValue()));
+    return result;
 }
 
 JSONObjectValidationBuilder* JConstantFloatExpressionFactory::addToValidator(
@@ -232,7 +226,7 @@ JSONObjectValidationBuilder* JConstantFloatExpressionFactory::addToValidator(
     return builder->withRequiredNumber("value")->finishNumber();
 }
 
-Framework::Text JConstantFloatExpressionFactory::getTypeToken() const
+const char* JConstantFloatExpressionFactory::getTypeToken() const
 {
     return "constant";
 }
@@ -260,23 +254,21 @@ JConstantBoolExpressionFactory::JConstantBoolExpressionFactory()
     : SubTypeFactory()
 {}
 
-JConstantBoolExpression* JConstantBoolExpressionFactory::createValue(
+JConstantBoolExpression* JConstantBoolExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JConstantBoolExpression();
+    JConstantBoolExpression* result = new JConstantBoolExpression();
+    result->setValue(zJson->zValue("value")->asBool()->getBool());
+    return result;
 }
 
-void JConstantBoolExpressionFactory::fromJson(
-    JConstantBoolExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setValue(zJson->zValue("value")->asBool()->getBool());
-}
-
-void JConstantBoolExpressionFactory::toJson(JConstantBoolExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JConstantBoolExpressionFactory::toJsonObject(
+    JConstantBoolExpression* zObject) const
 {
+    Framework::JSON::JSONObject* zResult = new Framework::JSON::JSONObject();
     zResult->addValue(
         "value", new Framework::JSON::JSONBool(zObject->getValue()));
+    return zResult;
 }
 
 JSONObjectValidationBuilder* JConstantBoolExpressionFactory::addToValidator(
@@ -285,7 +277,7 @@ JSONObjectValidationBuilder* JConstantBoolExpressionFactory::addToValidator(
     return builder->withRequiredBool("value")->finishBool();
 }
 
-Framework::Text JConstantBoolExpressionFactory::getTypeToken() const
+const char* JConstantBoolExpressionFactory::getTypeToken() const
 {
     return "constant";
 }
@@ -357,35 +349,33 @@ JNoiseFloatExpressionFactory::JNoiseFloatExpressionFactory()
     : SubTypeFactory()
 {}
 
-JNoiseFloatExpression* JNoiseFloatExpressionFactory::createValue(
+JNoiseFloatExpression* JNoiseFloatExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JNoiseFloatExpression();
-}
-
-void JNoiseFloatExpressionFactory::fromJson(
-    JNoiseFloatExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setName(zJson->zValue("name")->asString()->getString());
-    zResult->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    JNoiseFloatExpression* result = new JNoiseFloatExpression();
+    result->setName(zJson->zValue("name")->asString()->getString());
+    result->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("x")));
-    zResult->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    result->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("y")));
-    zResult->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    result->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("z")));
+    return result;
 }
 
-void JNoiseFloatExpressionFactory::toJson(
-    JNoiseFloatExpression* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JNoiseFloatExpressionFactory::toJsonObject(
+    JNoiseFloatExpression* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "name", new Framework::JSON::JSONString(zObject->getName()));
-    zResult->addValue(
+    result->addValue(
         "x", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zX()));
-    zResult->addValue(
+    result->addValue(
         "y", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zY()));
-    zResult->addValue(
+    result->addValue(
         "z", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zZ()));
+    return result;
 }
 
 JSONObjectValidationBuilder* JNoiseFloatExpressionFactory::addToValidator(
@@ -401,7 +391,7 @@ JSONObjectValidationBuilder* JNoiseFloatExpressionFactory::addToValidator(
             Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>());
 }
 
-Framework::Text JNoiseFloatExpressionFactory::getTypeToken() const
+const char* JNoiseFloatExpressionFactory::getTypeToken() const
 {
     return "noise";
 }
@@ -457,44 +447,41 @@ JOperatorFloatExpressionFactory::JOperatorFloatExpressionFactory()
     : SubTypeFactory()
 {}
 
-JOperatorFloatExpression* JOperatorFloatExpressionFactory::createValue(
+JOperatorFloatExpression* JOperatorFloatExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JOperatorFloatExpression();
-}
-
-void JOperatorFloatExpressionFactory::fromJson(
-    JOperatorFloatExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    JOperatorFloatExpression* result = new JOperatorFloatExpression();
     Framework::Text op = zJson->zValue("operator")->asString()->getString();
     if (op.istGleich("+"))
     {
-        zResult->setOperator("+", [](float a, float b) { return a + b; });
+        result->setOperator("+", [](float a, float b) { return a + b; });
     }
     else if (op.istGleich("-"))
     {
-        zResult->setOperator("-", [](float a, float b) { return a - b; });
+        result->setOperator("-", [](float a, float b) { return a - b; });
     }
     else if (op.istGleich("*"))
     {
-        zResult->setOperator("*", [](float a, float b) { return a * b; });
+        result->setOperator("*", [](float a, float b) { return a * b; });
     }
     else if (op.istGleich("/"))
     {
-        zResult->setOperator("/", [](float a, float b) { return a / b; });
+        result->setOperator("/", [](float a, float b) { return a / b; });
     }
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("values")->asArray())
     {
-        zResult->addValue(
+        result->addValue(
             Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(value));
     }
+    return result;
 }
 
-void JOperatorFloatExpressionFactory::toJson(JOperatorFloatExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JOperatorFloatExpressionFactory::toJsonObject(
+    JOperatorFloatExpression* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "operator", new Framework::JSON::JSONString(zObject->getOperator()));
     Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
     for (JFloatExpression* expression : zObject->getValues())
@@ -503,7 +490,8 @@ void JOperatorFloatExpressionFactory::toJson(JOperatorFloatExpression* zObject,
             Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
                 expression));
     }
-    zResult->addValue("values", values);
+    result->addValue("values", values);
+    return result;
 }
 
 JSONObjectValidationBuilder* JOperatorFloatExpressionFactory::addToValidator(
@@ -518,7 +506,7 @@ JSONObjectValidationBuilder* JOperatorFloatExpressionFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text JOperatorFloatExpressionFactory::getTypeToken() const
+const char* JOperatorFloatExpressionFactory::getTypeToken() const
 {
     return "operator";
 }
@@ -573,36 +561,32 @@ JBoolOperatorBoolExpressionFactory::JBoolOperatorBoolExpressionFactory()
     : SubTypeFactory()
 {}
 
-JBoolOperatorBoolExpression* JBoolOperatorBoolExpressionFactory::createValue(
+JBoolOperatorBoolExpression* JBoolOperatorBoolExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JBoolOperatorBoolExpression();
-}
-
-void JBoolOperatorBoolExpressionFactory::fromJson(
-    JBoolOperatorBoolExpression* zResult,
-    Framework::JSON::JSONObject* zJson) const
-{
-    for (Framework::JSON::JSONValue* value : *zJson->zValue("values")->asArray())
+    JBoolOperatorBoolExpression* result = new JBoolOperatorBoolExpression();
+    for (Framework::JSON::JSONValue* value :
+        *zJson->zValue("values")->asArray())
     {
-        zResult->addValue(
+        result->addValue(
             Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(value));
     }
     Framework::Text op = zJson->zValue("operator")->asString()->getString();
     if (op.istGleich("&&"))
     {
-        zResult->setOperator("&&", [](bool a, bool b) { return a && b; });
+        result->setOperator("&&", [](bool a, bool b) { return a && b; });
     }
     else if (op.istGleich("||"))
     {
-        zResult->setOperator("||", [](bool a, bool b) { return a || b; });
+        result->setOperator("||", [](bool a, bool b) { return a || b; });
     }
+    return result;
 }
 
-void JBoolOperatorBoolExpressionFactory::toJson(
-    JBoolOperatorBoolExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JBoolOperatorBoolExpressionFactory::toJsonObject(
+    JBoolOperatorBoolExpression* zObject) const
 {
+    Framework::JSON::JSONObject* zResult = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
     for (JBoolExpression* expression : zObject->getValues())
     {
@@ -613,6 +597,7 @@ void JBoolOperatorBoolExpressionFactory::toJson(
     zResult->addValue("values", values);
     zResult->addValue(
         "operator", new Framework::JSON::JSONString(zObject->getOperator()));
+    return zResult;
 }
 
 JSONObjectValidationBuilder* JBoolOperatorBoolExpressionFactory::addToValidator(
@@ -627,7 +612,7 @@ JSONObjectValidationBuilder* JBoolOperatorBoolExpressionFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text JBoolOperatorBoolExpressionFactory::getTypeToken() const
+const char* JBoolOperatorBoolExpressionFactory::getTypeToken() const
 {
     return "operator";
 }
@@ -678,90 +663,79 @@ JFloatOperatorBoolExpressionFactory::JFloatOperatorBoolExpressionFactory()
     : SubTypeFactory()
 {}
 
-JFloatOperatorBoolExpression* JFloatOperatorBoolExpressionFactory::createValue(
-    Framework::JSON::JSONObject* zJson) const
-{
-    return new JFloatOperatorBoolExpression();
-}
-
-void JFloatOperatorBoolExpressionFactory::fromJson(
-    JFloatOperatorBoolExpression* zResult,
+JFloatOperatorBoolExpression* JFloatOperatorBoolExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
+    JFloatOperatorBoolExpression* result = new JFloatOperatorBoolExpression();
     Framework::Text op = zJson->zValue("operator")->asString()->getString();
     if (op.istGleich(">"))
     {
-        zResult->setOperator(
-            ">", [](float a, float b) { return a > b; });
+        result->setOperator(">", [](float a, float b) { return a > b; });
     }
     else if (op.istGleich("<"))
     {
-        zResult->setOperator(
-            "<", [](float a, float b) { return a < b; });
+        result->setOperator("<", [](float a, float b) { return a < b; });
     }
     else if (op.istGleich(">="))
     {
-        zResult->setOperator(
-            ">=", [](float a, float b) { return a >= b; });
+        result->setOperator(">=", [](float a, float b) { return a >= b; });
     }
     else if (op.istGleich("<="))
     {
-        zResult->setOperator(
-            "<=", [](float a, float b) { return a <= b; });
+        result->setOperator("<=", [](float a, float b) { return a <= b; });
     }
     else if (op.istGleich("=="))
     {
-        zResult->setOperator(
-            "==", [](float a, float b) { return a == b; });
+        result->setOperator("==", [](float a, float b) { return a == b; });
     }
     else if (op.istGleich("!="))
     {
-        zResult->setOperator(
-            "!=", [](float a, float b) { return a != b; });
+        result->setOperator("!=", [](float a, float b) { return a != b; });
     }
     else if (op.istGleich(">i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             ">i", [](float a, float b) { return (int)a > (int)b; });
     }
     else if (op.istGleich("<i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             "<i", [](float a, float b) { return (int)a < (int)b; });
     }
     else if (op.istGleich(">=i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             ">=i", [](float a, float b) { return (int)a >= (int)b; });
     }
     else if (op.istGleich("<=i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             "<=i", [](float a, float b) { return (int)a <= (int)b; });
     }
     else if (op.istGleich("==i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             "==i", [](float a, float b) { return (int)a == (int)b; });
     }
     else if (op.istGleich("!=i"))
     {
-        zResult->setOperator(
+        result->setOperator(
             "!=i", [](float a, float b) { return (int)a != (int)b; });
     }
     for (Framework::JSON::JSONValue* value :
         *zJson->zValue("values")->asArray())
     {
-        zResult->addValue(
+        result->addValue(
             Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(value));
     }
+    return result;
 }
 
-void JFloatOperatorBoolExpressionFactory::toJson(
-    JFloatOperatorBoolExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JFloatOperatorBoolExpressionFactory::toJsonObject(
+    JFloatOperatorBoolExpression* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "operator", new Framework::JSON::JSONString(zObject->getOperator()));
     Framework::JSON::JSONArray* values = new Framework::JSON::JSONArray();
     for (JFloatExpression* expression : zObject->getValues())
@@ -770,7 +744,8 @@ void JFloatOperatorBoolExpressionFactory::toJson(
             Game::INSTANCE->zTypeRegistry()->toJson<JFloatExpression>(
                 expression));
     }
-    zResult->addValue("values", values);
+    result->addValue("values", values);
+    return result;
 }
 
 JSONObjectValidationBuilder*
@@ -797,7 +772,7 @@ JFloatOperatorBoolExpressionFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text JFloatOperatorBoolExpressionFactory::getTypeToken() const
+const char* JFloatOperatorBoolExpressionFactory::getTypeToken() const
 {
     return "comparsion";
 }
@@ -879,37 +854,35 @@ JBlockTypeBoolExpressionFactory::JBlockTypeBoolExpressionFactory()
     : SubTypeFactory()
 {}
 
-JBlockTypeBoolExpression* JBlockTypeBoolExpressionFactory::createValue(
+JBlockTypeBoolExpression* JBlockTypeBoolExpressionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new JBlockTypeBoolExpression();
-}
-
-void JBlockTypeBoolExpressionFactory::fromJson(
-    JBlockTypeBoolExpression* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setTypeId(Game::INSTANCE->getBlockTypeId(
+    JBlockTypeBoolExpression* result = new JBlockTypeBoolExpression();
+    result->setTypeId(Game::INSTANCE->getBlockTypeId(
         zJson->zValue("blockType")->asString()->getString()));
-    zResult->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    result->setX(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("x")));
-    zResult->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    result->setY(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("y")));
-    zResult->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
+    result->setZ(Game::INSTANCE->zTypeRegistry()->fromJson<JFloatExpression>(
         zJson->zValue("z")));
+    return result;
 }
 
-void JBlockTypeBoolExpressionFactory::toJson(JBlockTypeBoolExpression* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* JBlockTypeBoolExpressionFactory::toJsonObject(
+    JBlockTypeBoolExpression* zObject) const
 {
-    zResult->addValue("blockType",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("blockType",
         new Framework::JSON::JSONString(
             Game::INSTANCE->zBlockType(zObject->getTypeId())->getName()));
-    zResult->addValue(
+    result->addValue(
         "x", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zX()));
-    zResult->addValue(
+    result->addValue(
         "y", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zY()));
-    zResult->addValue(
+    result->addValue(
         "z", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zZ()));
+    return result;
 }
 
 JSONObjectValidationBuilder* JBlockTypeBoolExpressionFactory::addToValidator(
@@ -935,7 +908,7 @@ JSONObjectValidationBuilder* JBlockTypeBoolExpressionFactory::addToValidator(
             Game::INSTANCE->zTypeRegistry()->getValidator<JFloatExpression>());
 }
 
-Framework::Text JBlockTypeBoolExpressionFactory::getTypeToken() const
+const char* JBlockTypeBoolExpressionFactory::getTypeToken() const
 {
     return "blockType";
 }

+ 36 - 54
FactoryCraft/JsonExpression.h

@@ -77,15 +77,13 @@ class JVariableFloatExpressionFactory
 {
 public:
     JVariableFloatExpressionFactory();
-    JVariableFloatExpression* createValue(
+    JVariableFloatExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JVariableFloatExpression* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JVariableFloatExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JVariableFloatExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JVariableBoolExpression : public JBoolExpression
@@ -106,15 +104,13 @@ class JVariableBoolExpressionFactory
 {
 public:
     JVariableBoolExpressionFactory();
-    JVariableBoolExpression* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JVariableBoolExpression* zResult,
+    JVariableBoolExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JVariableBoolExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JVariableBoolExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JConstantFloatExpression : public JFloatExpression
@@ -135,15 +131,13 @@ class JConstantFloatExpressionFactory
 {
 public:
     JConstantFloatExpressionFactory();
-    JConstantFloatExpression* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JConstantFloatExpression* zResult,
+    JConstantFloatExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JConstantFloatExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JConstantFloatExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JConstantBoolExpression : public JBoolExpression
@@ -164,15 +158,13 @@ class JConstantBoolExpressionFactory
 {
 public:
     JConstantBoolExpressionFactory();
-    JConstantBoolExpression* createValue(
+    JConstantBoolExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JConstantBoolExpression* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JConstantBoolExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JConstantBoolExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JNoiseFloatExpression : public JFloatExpression
@@ -203,15 +195,13 @@ class JNoiseFloatExpressionFactory
 {
 public:
     JNoiseFloatExpressionFactory();
-    JNoiseFloatExpression* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JNoiseFloatExpression* zResult,
+    JNoiseFloatExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JNoiseFloatExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JNoiseFloatExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JOperatorFloatExpression : public JFloatExpression
@@ -237,15 +227,13 @@ class JOperatorFloatExpressionFactory
 {
 public:
     JOperatorFloatExpressionFactory();
-    JOperatorFloatExpression* createValue(
+    JOperatorFloatExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JOperatorFloatExpression* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JOperatorFloatExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JOperatorFloatExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JBoolOperatorBoolExpression : public JBoolExpression
@@ -271,15 +259,13 @@ class JBoolOperatorBoolExpressionFactory
 {
 public:
     JBoolOperatorBoolExpressionFactory();
-    JBoolOperatorBoolExpression* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JBoolOperatorBoolExpression* zResult,
+    JBoolOperatorBoolExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JBoolOperatorBoolExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JBoolOperatorBoolExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JFloatOperatorBoolExpression : public JBoolExpression
@@ -305,15 +291,13 @@ class JFloatOperatorBoolExpressionFactory
 {
 public:
     JFloatOperatorBoolExpressionFactory();
-    JFloatOperatorBoolExpression* createValue(
+    JFloatOperatorBoolExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JFloatOperatorBoolExpression* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JFloatOperatorBoolExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JFloatOperatorBoolExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class JBlockTypeBoolExpression : public JBoolExpression
@@ -344,13 +328,11 @@ class JBlockTypeBoolExpressionFactory
 {
 public:
     JBlockTypeBoolExpressionFactory();
-    JBlockTypeBoolExpression* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(JBlockTypeBoolExpression* zResult,
+    JBlockTypeBoolExpression* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(JBlockTypeBoolExpression* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        JBlockTypeBoolExpression* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 28 - 28
FactoryCraft/LightSources.cpp

@@ -20,15 +20,15 @@ LightSourceItemType::LightSourceItemType(Framework::Text name,
     int maxStackSize,
     Framework::RCArray<Framework::Text> groups)
     : BasicBlockItemType(name,
-        model,
-        true,
-        true,
-        0.f,
-        1.f,
-        blockTypeName,
-        0,
-        maxStackSize,
-        groups)
+          model,
+          true,
+          true,
+          0.f,
+          1.f,
+          blockTypeName,
+          0,
+          maxStackSize,
+          groups)
 {}
 
 void LightSourceItemType::loadSuperItem(
@@ -228,35 +228,35 @@ BasicLightSourceBlockType* BasicLightSourceBlockTypeFactory::createValue(
     return new BasicLightSourceBlockType();
 }
 
-void BasicLightSourceBlockTypeFactory::fromJson(
-    BasicLightSourceBlockType* zResult,
+BasicLightSourceBlockType* BasicLightSourceBlockTypeFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setItemTypeName(zJson->zValue("itemType")->asString()->getString());
-    zResult->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
-    zResult->setPassable(zJson->zValue("passable")->asBool()->getBool());
-    zResult->setInteractable(
-        zJson->zValue("interactable")->asBool()->getBool());
-    zResult->setLightColor(
+    BasicLightSourceBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
+    result->setItemTypeName(zJson->zValue("itemType")->asString()->getString());
+    result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
+    result->setPassable(zJson->zValue("passable")->asBool()->getBool());
+    result->setInteractable(zJson->zValue("interactable")->asBool()->getBool());
+    result->setLightColor(
         (int)zJson->zValue("lightColor")->asString()->getString());
-    BlockTypeFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void BasicLightSourceBlockTypeFactory::toJson(
-    BasicLightSourceBlockType* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* BasicLightSourceBlockTypeFactory::toJsonObject(
+    BasicLightSourceBlockType* zObject) const
 {
-    zResult->addValue("itemType",
+    Framework::JSON::JSONObject* result
+        = BlockTypeFactoryBase::toJsonObject(zObject);
+    result->addValue("itemType",
         new Framework::JSON::JSONString(zObject->getItemTypeName()));
-    zResult->addValue(
+    result->addValue(
         "transparent", new Framework::JSON::JSONBool(zObject->isTransparent()));
-    zResult->addValue(
+    result->addValue(
         "passable", new Framework::JSON::JSONBool(zObject->isPassable()));
-    zResult->addValue("interactable",
+    result->addValue("interactable",
         new Framework::JSON::JSONBool(zObject->isInteractable()));
-    zResult->addValue("lightColor",
+    result->addValue("lightColor",
         new Framework::JSON::JSONString(zObject->getLightColor()));
-    BlockTypeFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* BasicLightSourceBlockTypeFactory::addToValidator(
@@ -278,7 +278,7 @@ JSONObjectValidationBuilder* BasicLightSourceBlockTypeFactory::addToValidator(
             ->finishString());
 }
 
-Framework::Text BasicLightSourceBlockTypeFactory::getTypeToken() const
+const char* BasicLightSourceBlockTypeFactory::getTypeToken() const
 {
     return "lightSource";
 }

+ 4 - 4
FactoryCraft/LightSources.h

@@ -107,11 +107,11 @@ public:
     BasicLightSourceBlockTypeFactory();
     BasicLightSourceBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(BasicLightSourceBlockType* zResult,
+    BasicLightSourceBlockType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(BasicLightSourceBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        BasicLightSourceBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 16 - 19
FactoryCraft/ModelInfo.cpp

@@ -83,45 +83,42 @@ float ModelInfo::getSize() const
 }
 
 ModelInfoFactory::ModelInfoFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-ModelInfo* ModelInfoFactory::createValue(
-    Framework::JSON::JSONObject* zJson) const
+ModelInfo* ModelInfoFactory::fromJson(Framework::JSON::JSONObject* zJson) const
 {
-    return new ModelInfo();
-}
-
-void ModelInfoFactory::fromJson(
-    ModelInfo* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setModelPath(
+    ModelInfo* result = new ModelInfo();
+    result->setModelPath(
         zJson->asObject()->zValue("modelPath")->asString()->getString());
     for (Framework::JSON::JSONValue* v :
         *zJson->asObject()->zValue("texturePaths")->asArray())
     {
-        zResult->addTexturePath(v->asString()->getString());
+        result->addTexturePath(v->asString()->getString());
     }
-    zResult->setTransparent(
+    result->setTransparent(
         zJson->asObject()->zValue("transparent")->asBool()->getBool());
-    zResult->setSize(
+    result->setSize(
         (float)zJson->asObject()->zValue("size")->asNumber()->getNumber());
+    return result;
 }
 
-void ModelInfoFactory::toJson(
-    ModelInfo* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* ModelInfoFactory::toJsonObject(
+    ModelInfo* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* arr = new Framework::JSON::JSONArray();
     for (Framework::Text* t : zObject->texturePaths)
     {
         arr->addValue(new Framework::JSON::JSONString(t->getText()));
     }
-    zResult->addValue("texturePaths", arr);
-    zResult->addValue(
+    result->addValue("texturePaths", arr);
+    result->addValue(
         "modelPath", new Framework::JSON::JSONString(zObject->modelPath));
-    zResult->addValue(
+    result->addValue(
         "transparent", new Framework::JSON::JSONBool(zObject->transparent));
-    zResult->addValue("size", new Framework::JSON::JSONNumber(zObject->size));
+    result->addValue("size", new Framework::JSON::JSONNumber(zObject->size));
+    return result;
 }
 
 JSONObjectValidationBuilder* ModelInfoFactory::addToValidator(

+ 4 - 6
FactoryCraft/ModelInfo.h

@@ -36,15 +36,13 @@ public:
     friend ModelInfoFactory;
 };
 
-class ModelInfoFactory : public TypeFactory<ModelInfo>
+class ModelInfoFactory : public ObjectTypeFactory<ModelInfo>
 {
 public:
     ModelInfoFactory();
-    ModelInfo* createValue(Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(
-        ModelInfo* zResult, Framework::JSON::JSONObject* zJson) const override;
-    void toJson(ModelInfo* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    ModelInfo* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        ModelInfo* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 43 - 53
FactoryCraft/PlaceableProof.cpp

@@ -39,32 +39,30 @@ PlaceableProofAndFactory::PlaceableProofAndFactory()
     : SubTypeFactory()
 {}
 
-PlaceableProofAnd* PlaceableProofAndFactory::createValue(
+PlaceableProofAnd* PlaceableProofAndFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new PlaceableProofAnd();
-}
-
-void PlaceableProofAndFactory::fromJson(
-    PlaceableProofAnd* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    PlaceableProofAnd* result = new PlaceableProofAnd();
     for (Framework::JSON::JSONValue* zProof :
         *zJson->zValue("proofs")->asArray())
     {
-        zResult->addProof(
+        result->addProof(
             Game::INSTANCE->zTypeRegistry()->fromJson<PlaceableProof>(zProof));
     }
+    return result;
 }
 
-void PlaceableProofAndFactory::toJson(
-    PlaceableProofAnd* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* PlaceableProofAndFactory::toJsonObject(
+    PlaceableProofAnd* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* proofs = new Framework::JSON::JSONArray();
     for (PlaceableProof* proof : zObject->getProofs())
     {
         proofs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(proof));
     }
-    zResult->addValue("proofs", proofs);
+    result->addValue("proofs", proofs);
+    return result;
 }
 
 JSONObjectValidationBuilder* PlaceableProofAndFactory::addToValidator(
@@ -76,7 +74,7 @@ JSONObjectValidationBuilder* PlaceableProofAndFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text PlaceableProofAndFactory::getTypeToken() const
+const char* PlaceableProofAndFactory::getTypeToken() const
 {
     return "and";
 }
@@ -112,32 +110,30 @@ PlaceableProofOrFactory::PlaceableProofOrFactory()
     : SubTypeFactory()
 {}
 
-PlaceableProofOr* PlaceableProofOrFactory::createValue(
+PlaceableProofOr* PlaceableProofOrFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new PlaceableProofOr();
-}
-
-void PlaceableProofOrFactory::fromJson(
-    PlaceableProofOr* zResult, Framework::JSON::JSONObject* zJson) const
-{
+    PlaceableProofOr* result = new PlaceableProofOr();
     for (Framework::JSON::JSONValue* zProof :
         *zJson->zValue("proofs")->asArray())
     {
-        zResult->addProof(
+        result->addProof(
             Game::INSTANCE->zTypeRegistry()->fromJson<PlaceableProof>(zProof));
     }
+    return result;
 }
 
-void PlaceableProofOrFactory::toJson(
-    PlaceableProofOr* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* PlaceableProofOrFactory::toJsonObject(
+    PlaceableProofOr* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* proofs = new Framework::JSON::JSONArray();
     for (PlaceableProof* proof : zObject->getProofs())
     {
         proofs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(proof));
     }
-    zResult->addValue("proofs", proofs);
+    result->addValue("proofs", proofs);
+    return result;
 }
 
 JSONObjectValidationBuilder* PlaceableProofOrFactory::addToValidator(
@@ -149,7 +145,7 @@ JSONObjectValidationBuilder* PlaceableProofOrFactory::addToValidator(
         ->finishArray();
 }
 
-Framework::Text PlaceableProofOrFactory::getTypeToken() const
+const char* PlaceableProofOrFactory::getTypeToken() const
 {
     return "or";
 }
@@ -181,24 +177,22 @@ PlaceableProofNotFactory::PlaceableProofNotFactory()
     : SubTypeFactory()
 {}
 
-PlaceableProofNot* PlaceableProofNotFactory::createValue(
+PlaceableProofNot* PlaceableProofNotFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new PlaceableProofNot();
-}
-
-void PlaceableProofNotFactory::fromJson(
-    PlaceableProofNot* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setProof(Game::INSTANCE->zTypeRegistry()->fromJson<PlaceableProof>(
+    PlaceableProofNot* result = new PlaceableProofNot();
+    result->setProof(Game::INSTANCE->zTypeRegistry()->fromJson<PlaceableProof>(
         zJson->zValue("proof")));
+    return result;
 }
 
-void PlaceableProofNotFactory::toJson(
-    PlaceableProofNot* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* PlaceableProofNotFactory::toJsonObject(
+    PlaceableProofNot* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "proof", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zProof()));
+    return result;
 }
 
 JSONObjectValidationBuilder* PlaceableProofNotFactory::addToValidator(
@@ -208,7 +202,7 @@ JSONObjectValidationBuilder* PlaceableProofNotFactory::addToValidator(
         Game::INSTANCE->zTypeRegistry()->getValidator<PlaceableProof>());
 }
 
-Framework::Text PlaceableProofNotFactory::getTypeToken() const
+const char* PlaceableProofNotFactory::getTypeToken() const
 {
     return "not";
 }
@@ -268,16 +262,10 @@ PlaceableProofBlockFilterFactory::PlaceableProofBlockFilterFactory()
     : SubTypeFactory()
 {}
 
-PlaceableProofBlockFilter* PlaceableProofBlockFilterFactory::createValue(
-    Framework::JSON::JSONObject* zJson) const
-{
-    return new PlaceableProofBlockFilter();
-}
-
-void PlaceableProofBlockFilterFactory::fromJson(
-    PlaceableProofBlockFilter* zResult,
+PlaceableProofBlockFilter* PlaceableProofBlockFilterFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
+    PlaceableProofBlockFilter* result = new PlaceableProofBlockFilter();
     Direction dir = NO_DIRECTION;
     if (zJson->zValue("direction")->asString()->getString().istGleich("top"))
     {
@@ -318,15 +306,16 @@ void PlaceableProofBlockFilterFactory::fromJson(
     {
         dir = WEST;
     }
-    zResult->setDirection(dir);
-    zResult->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
+    result->setDirection(dir);
+    result->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<BlockFilter>(
         zJson->zValue("filter")));
+    return result;
 }
 
-void PlaceableProofBlockFilterFactory::toJson(
-    PlaceableProofBlockFilter* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* PlaceableProofBlockFilterFactory::toJsonObject(
+    PlaceableProofBlockFilter* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::Text dir = "";
     if (zObject->getDirection() == NORTH)
     {
@@ -352,11 +341,12 @@ void PlaceableProofBlockFilterFactory::toJson(
     {
         dir = "bottom";
     }
-    zResult->addValue("direction", new Framework::JSON::JSONString(dir));
-    zResult->addValue(
+    result->addValue("direction", new Framework::JSON::JSONString(dir));
+    result->addValue(
         "distance", new Framework::JSON::JSONNumber(zObject->getDistance()));
-    zResult->addValue(
+    result->addValue(
         "filter", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zFilter()));
+    return result;
 }
 
 JSONObjectValidationBuilder* PlaceableProofBlockFilterFactory::addToValidator(
@@ -373,7 +363,7 @@ JSONObjectValidationBuilder* PlaceableProofBlockFilterFactory::addToValidator(
             Game::INSTANCE->zTypeRegistry()->getValidator<BlockFilter>());
 }
 
-Framework::Text PlaceableProofBlockFilterFactory::getTypeToken() const
+const char* PlaceableProofBlockFilterFactory::getTypeToken() const
 {
     return "blockFilter";
 }

+ 16 - 24
FactoryCraft/PlaceableProof.h

@@ -36,15 +36,13 @@ class PlaceableProofAndFactory
 {
 public:
     PlaceableProofAndFactory();
-    PlaceableProofAnd* createValue(
+    PlaceableProofAnd* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(PlaceableProofAnd* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(PlaceableProofAnd* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        PlaceableProofAnd* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class PlaceableProofOr : public PlaceableProof
@@ -65,15 +63,13 @@ class PlaceableProofOrFactory
 {
 public:
     PlaceableProofOrFactory();
-    PlaceableProofOr* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(PlaceableProofOr* zResult,
+    PlaceableProofOr* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(PlaceableProofOr* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        PlaceableProofOr* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class PlaceableProofNot : public PlaceableProof
@@ -95,15 +91,13 @@ class PlaceableProofNotFactory
 {
 public:
     PlaceableProofNotFactory();
-    PlaceableProofNot* createValue(
+    PlaceableProofNot* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(PlaceableProofNot* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(PlaceableProofNot* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        PlaceableProofNot* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class PlaceableProofBlockFilter : public PlaceableProof
@@ -131,15 +125,13 @@ class PlaceableProofBlockFilterFactory
 {
 public:
     PlaceableProofBlockFilterFactory();
-    PlaceableProofBlockFilter* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(PlaceableProofBlockFilter* zResult,
+    PlaceableProofBlockFilter* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(PlaceableProofBlockFilter* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        PlaceableProofBlockFilter* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 // TODO: add item Filter

+ 87 - 100
FactoryCraft/Quest.cpp

@@ -33,31 +33,29 @@ const Framework::Text& QuestRequirementStorage::getRequirementId() const
 }
 
 QuestRequirementStorageType::QuestRequirementStorageType()
-    : TypeFactory<QuestRequirementStorage>()
+    : ObjectTypeFactory<QuestRequirementStorage>()
 {}
 
-QuestRequirementStorage* QuestRequirementStorageType::createValue(
+QuestRequirementStorage* QuestRequirementStorageType::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new QuestRequirementStorage();
-}
-
-void QuestRequirementStorageType::fromJson(
-    QuestRequirementStorage* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setRequirementId(
+    QuestRequirementStorage* result = new QuestRequirementStorage();
+    result->setRequirementId(
         zJson->asObject()->zValue("requirementId")->asString()->getString());
-    zResult->setFullfilled(
+    result->setFullfilled(
         zJson->asObject()->zValue("fulfilled")->asBool()->getBool());
+    return result;
 }
 
-void QuestRequirementStorageType::toJson(QuestRequirementStorage* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestRequirementStorageType::toJsonObject(
+    QuestRequirementStorage* zObject) const
 {
-    zResult->addValue("requirementId",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("requirementId",
         new Framework::JSON::JSONString(zObject->getRequirementId()));
-    zResult->addValue(
+    result->addValue(
         "fulfilled", new Framework::JSON::JSONBool(zObject->isFullfilled()));
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestRequirementStorageType::addToValidator(
@@ -159,44 +157,41 @@ bool QuestStorage::containsKey(Framework::Text key) const
 }
 
 QuestStorageType::QuestStorageType()
-    : TypeFactory<QuestStorage>()
+    : ObjectTypeFactory<QuestStorage>()
 {}
 
-QuestStorage* QuestStorageType::createValue(
+QuestStorage* QuestStorageType::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new QuestStorage();
-}
-
-void QuestStorageType::fromJson(
-    QuestStorage* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setQuestId(
+    QuestStorage* result = new QuestStorage();
+    result->setQuestId(
         zJson->asObject()->zValue("questId")->asString()->getString());
-    zResult->setQuestFinished(
+    result->setQuestFinished(
         zJson->asObject()->zValue("finished")->asBool()->getBool());
-    zResult->setQuestRewarded(
+    result->setQuestRewarded(
         zJson->asObject()->zValue("rewarded")->asBool()->getBool());
     Framework::JSON::JSONArray* rewardsArray
         = zJson->asObject()->zValue("requirements")->asArray();
     for (int i = 0; i < rewardsArray->getLength(); i++)
     {
-        zResult->requirements.add(
+        result->requirements.add(
             Game::INSTANCE->zTypeRegistry()->fromJson<QuestRequirementStorage>(
                 rewardsArray->zValue(i)->asObject()));
     }
-    zResult->data->release();
-    zResult->data = zJson->asObject()->getValue("data")->asObject();
+    result->data->release();
+    result->data = zJson->asObject()->getValue("data")->asObject();
+    return result;
 }
 
-void QuestStorageType::toJson(
-    QuestStorage* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestStorageType::toJsonObject(
+    QuestStorage* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "questId", new Framework::JSON::JSONString(zObject->questId));
-    zResult->addValue(
+    result->addValue(
         "finished", new Framework::JSON::JSONBool(zObject->finished));
-    zResult->addValue(
+    result->addValue(
         "rewarded", new Framework::JSON::JSONBool(zObject->rewarded));
     Framework::JSON::JSONArray* rewardsArray = new Framework::JSON::JSONArray();
     for (QuestRequirementStorage* storage : zObject->requirements)
@@ -204,9 +199,10 @@ void QuestStorageType::toJson(
         rewardsArray->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson(storage));
     }
-    zResult->addValue("requirements", rewardsArray);
+    result->addValue("requirements", rewardsArray);
     Framework::Text dataString = zObject->data->toString();
-    zResult->addValue("data", Framework::JSON::Parser::getValue(dataString));
+    result->addValue("data", Framework::JSON::Parser::getValue(dataString));
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestStorageType::addToValidator(
@@ -283,44 +279,40 @@ QuestParty* QuestParty::clone() const
 }
 
 QuestPartyType::QuestPartyType()
-    : TypeFactory<QuestParty>()
+    : ObjectTypeFactory<QuestParty>()
 {}
 
-QuestParty* QuestPartyType::createValue(
-    Framework::JSON::JSONObject* zJson) const
-{
-    return new QuestParty();
-}
-
-void QuestPartyType::fromJson(
-    QuestParty* zResult, Framework::JSON::JSONObject* zJson) const
+QuestParty* QuestPartyType::fromJson(Framework::JSON::JSONObject* zJson) const
 {
+    QuestParty* result = new QuestParty();
     Framework::JSON::JSONArray* membersArray
         = zJson->asObject()->zValue("members")->asArray();
     for (int i = 0; i < membersArray->getLength(); i++)
     {
-        zResult->memberEntityIds.add(
+        result->memberEntityIds.add(
             (int)membersArray->zValue(i)->asNumber()->getNumber());
     }
     Framework::JSON::JSONArray* storagesArray
         = zJson->asObject()->zValue("quests")->asArray();
     for (int i = 0; i < storagesArray->getLength(); i++)
     {
-        zResult->questStorage.add(
+        result->questStorage.add(
             Game::INSTANCE->zTypeRegistry()->fromJson<QuestStorage>(
                 storagesArray->zValue(i)->asObject()));
     }
+    return result;
 }
 
-void QuestPartyType::toJson(
-    QuestParty* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestPartyType::toJsonObject(
+    QuestParty* zObject) const
 {
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
     Framework::JSON::JSONArray* membersArray = new Framework::JSON::JSONArray();
     for (int memberEntityId : zObject->memberEntityIds)
     {
         membersArray->addValue(new Framework::JSON::JSONNumber(memberEntityId));
     }
-    zResult->addValue("members", membersArray);
+    result->addValue("members", membersArray);
     Framework::JSON::JSONArray* storagesArray
         = new Framework::JSON::JSONArray();
     for (QuestStorage* storage : zObject->questStorage)
@@ -328,7 +320,8 @@ void QuestPartyType::toJson(
         storagesArray->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson(storage));
     }
-    zResult->addValue("quests", storagesArray);
+    result->addValue("quests", storagesArray);
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestPartyType::addToValidator(
@@ -429,22 +422,17 @@ void Quest::setVisible(bool visible, QuestParty* zParty, QuestManager* zManager)
 }
 
 QuestType::QuestType()
-    : TypeFactory<Quest>()
+    : ObjectTypeFactory<Quest>()
 {}
 
-Quest* QuestType::createValue(Framework::JSON::JSONObject* zJson) const
-{
-    return new Quest();
-}
-
-void QuestType::fromJson(
-    Quest* zResult, Framework::JSON::JSONObject* zJson) const
+Quest* QuestType::fromJson(Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setQuestId(
+    Quest* result = new Quest();
+    result->setQuestId(
         zJson->asObject()->zValue("questId")->asString()->getString());
-    zResult->questName
+    result->questName
         = zJson->asObject()->zValue("questName")->asString()->getString();
-    zResult->description
+    result->description
         = zJson->asObject()->zValue("description")->asString()->getString();
     Framework::JSON::JSONArray* requiredQuestGroups
         = zJson->asObject()->zValue("requiredQuestIds")->asArray();
@@ -454,16 +442,16 @@ void QuestType::fromJson(
             = requiredQuestGroups->zValue(i)->asArray();
         for (int j = 0; j < requiredQuestIdsArray->getLength(); j++)
         {
-            zResult->requiredQuestsIds.add(new Framework::Text(
+            result->requiredQuestsIds.add(new Framework::Text(
                 requiredQuestIdsArray->zValue(j)->asString()->getString()));
-            zResult->requiredQuestsGroups.add(i);
+            result->requiredQuestsGroups.add(i);
         }
     }
     Framework::JSON::JSONArray* requirementsArray
         = zJson->asObject()->zValue("requirements")->asArray();
     for (int i = 0; i < requirementsArray->getLength(); i++)
     {
-        zResult->requirements.add(
+        result->requirements.add(
             Game::INSTANCE->zTypeRegistry()->fromJson<QuestRequirement>(
                 requirementsArray->zValue(i)));
     }
@@ -471,22 +459,23 @@ void QuestType::fromJson(
         = zJson->asObject()->zValue("rewards")->asArray();
     for (int i = 0; i < rewardsArray->getLength(); i++)
     {
-        zResult->rewards.add(
+        result->rewards.add(
             Game::INSTANCE->zTypeRegistry()->fromJson<QuestReward>(
                 rewardsArray->zValue(i)));
     }
-    zResult->imagePath
+    result->imagePath
         = zJson->asObject()->zValue("imagePath")->asString()->getString();
+    return result;
 }
 
-void QuestType::toJson(
-    Quest* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestType::toJsonObject(Quest* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "questId", new Framework::JSON::JSONString(zObject->questId));
-    zResult->addValue(
+    result->addValue(
         "questName", new Framework::JSON::JSONString(zObject->questName));
-    zResult->addValue(
+    result->addValue(
         "description", new Framework::JSON::JSONString(zObject->description));
     Framework::JSON::JSONArray* requiredQuestGroupArray
         = new Framework::JSON::JSONArray();
@@ -515,7 +504,7 @@ void QuestType::toJson(
         requiredQuestGroupArray->addValue(requiredQuestIdsArray);
         requiredQuestIdsArray = new Framework::JSON::JSONArray();
     }
-    zResult->addValue("requiredQuestIds", requiredQuestGroupArray);
+    result->addValue("requiredQuestIds", requiredQuestGroupArray);
     Framework::JSON::JSONArray* requirementsArray
         = new Framework::JSON::JSONArray();
     for (QuestRequirement* requirement : zObject->requirements)
@@ -523,15 +512,16 @@ void QuestType::toJson(
         requirementsArray->addValue(
             Game::INSTANCE->zTypeRegistry()->toJson(requirement));
     }
-    zResult->addValue("requirements", requirementsArray);
+    result->addValue("requirements", requirementsArray);
     Framework::JSON::JSONArray* rewardsArray = new Framework::JSON::JSONArray();
     for (QuestReward* reward : zObject->rewards)
     {
         rewardsArray->addValue(Game::INSTANCE->zTypeRegistry()->toJson(reward));
     }
-    zResult->addValue("rewards", rewardsArray);
-    zResult->addValue(
+    result->addValue("rewards", rewardsArray);
+    result->addValue(
         "imagePath", new Framework::JSON::JSONString(zObject->imagePath));
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestType::addToValidator(
@@ -618,39 +608,36 @@ void QuestCollection::setQuestVisible(bool visible,
 }
 
 QuestCollectionType::QuestCollectionType()
-    : TypeFactory<QuestCollection>()
+    : ObjectTypeFactory<QuestCollection>()
 {}
 
-QuestCollection* QuestCollectionType::createValue(
+QuestCollection* QuestCollectionType::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new QuestCollection();
-}
-
-void QuestCollectionType::fromJson(
-    QuestCollection* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setName(
-        zJson->asObject()->zValue("name")->asString()->getString());
+    QuestCollection* result = new QuestCollection();
+    result->setName(zJson->asObject()->zValue("name")->asString()->getString());
     Framework::JSON::JSONArray* questsArray
         = zJson->asObject()->zValue("quests")->asArray();
     for (int i = 0; i < questsArray->getLength(); i++)
     {
-        zResult->quests.add(Game::INSTANCE->zTypeRegistry()->fromJson<Quest>(
+        result->quests.add(Game::INSTANCE->zTypeRegistry()->fromJson<Quest>(
             questsArray->zValue(i)->asObject()));
     }
+    return result;
 }
 
-void QuestCollectionType::toJson(
-    QuestCollection* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestCollectionType::toJsonObject(
+    QuestCollection* zObject) const
 {
-    zResult->addValue("name", new Framework::JSON::JSONString(zObject->name));
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("name", new Framework::JSON::JSONString(zObject->name));
     Framework::JSON::JSONArray* questsArray = new Framework::JSON::JSONArray();
     for (Quest* quest : zObject->quests)
     {
         questsArray->addValue(Game::INSTANCE->zTypeRegistry()->toJson(quest));
     }
-    zResult->addValue("quests", questsArray);
+    result->addValue("quests", questsArray);
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestCollectionType::addToValidator(
@@ -708,7 +695,7 @@ void QuestManager::loadQuests()
     }
     Framework::JSON::JSONValue* value
         = Framework::JSON::loadJSONFromFile(questDir + "/quests.json");
-    if (!value || value->getType() == Framework::JSON::JSONType::NULL_)
+    if (!value || value->getType() == Framework::AbstractType::NULL_)
     {
         Framework::Logging::warning()
             << "No valid quests.json found in " << questDir;
@@ -720,18 +707,18 @@ void QuestManager::loadQuests()
     else
     {
         Framework::Logging::info() << "loading quests ...";
-        Framework::JSON::Validator::JSONValidator* validator
-            = Framework::JSON::Validator::JSONValidator::buildForArray()
+        Framework::Validator::DataValidator* validator
+            = Framework::Validator::DataValidator::buildForArray()
                   ->addAcceptedTypeInArray(
                       Game::INSTANCE->zTypeRegistry()
                           ->getValidator<QuestCollection>())
                   ->removeInvalidEntries()
                   ->finishArray();
-        Framework::RCArray<Framework::JSON::Validator::JSONValidationResult>
+        Framework::RCArray<Framework::Validator::ValidationResult>
             validationResult;
         Framework::JSON::JSONArray* valid
             = validator->getValidParts(value, &validationResult)->asArray();
-        for (Framework::JSON::Validator::JSONValidationResult* invalidPart :
+        for (Framework::Validator::ValidationResult* invalidPart :
             validationResult)
         {
             Framework::Logging::error() << invalidPart->getInvalidInfo();
@@ -747,7 +734,7 @@ void QuestManager::loadQuests()
         validator->release();
     }
     value = Framework::JSON::loadJSONFromFile(questDir + "/parties.json");
-    if (!value || value->getType() == Framework::JSON::JSONType::NULL_)
+    if (!value || value->getType() == Framework::AbstractType::NULL_)
     {
         if (value)
         {
@@ -757,17 +744,17 @@ void QuestManager::loadQuests()
     else
     {
         Framework::Logging::info() << "loading quest parties ...";
-        Framework::JSON::Validator::JSONValidator* validator
-            = Framework::JSON::Validator::JSONValidator::buildForArray()
+        Framework::Validator::DataValidator* validator
+            = Framework::Validator::DataValidator::buildForArray()
                   ->addAcceptedTypeInArray(Game::INSTANCE->zTypeRegistry()
                                                ->getValidator<QuestParty>())
                   ->removeInvalidEntries()
                   ->finishArray();
-        Framework::RCArray<Framework::JSON::Validator::JSONValidationResult>
+        Framework::RCArray<Framework::Validator::ValidationResult>
             validationResult;
         Framework::JSON::JSONArray* valid
             = validator->getValidParts(value, &validationResult)->asArray();
-        for (Framework::JSON::Validator::JSONValidationResult* invalidPart :
+        for (Framework::Validator::ValidationResult* invalidPart :
             validationResult)
         {
             Framework::Logging::error() << invalidPart->getInvalidInfo();

+ 20 - 32
FactoryCraft/Quest.h

@@ -26,16 +26,15 @@ public:
     friend QuestRequirementStorageType;
 };
 
-class QuestRequirementStorageType : public TypeFactory<QuestRequirementStorage>
+class QuestRequirementStorageType
+    : public ObjectTypeFactory<QuestRequirementStorage>
 {
 public:
     QuestRequirementStorageType();
-    QuestRequirementStorage* createValue(
+    QuestRequirementStorage* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(QuestRequirementStorage* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestRequirementStorage* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestRequirementStorage* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -73,16 +72,13 @@ public:
     friend QuestStorageType;
 };
 
-class QuestStorageType : public TypeFactory<QuestStorage>
+class QuestStorageType : public ObjectTypeFactory<QuestStorage>
 {
 public:
     QuestStorageType();
-    QuestStorage* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(QuestStorage* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestStorage* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    QuestStorage* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestStorage* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -108,16 +104,13 @@ public:
     friend QuestPartyType;
 };
 
-class QuestPartyType : public TypeFactory<QuestParty>
+class QuestPartyType : public ObjectTypeFactory<QuestParty>
 {
 public:
     QuestPartyType();
-    QuestParty* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(
-        QuestParty* zResult, Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestParty* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    QuestParty* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestParty* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -153,15 +146,12 @@ public:
     friend QuestDialog;
 };
 
-class QuestType : public TypeFactory<Quest>
+class QuestType : public ObjectTypeFactory<Quest>
 {
 public:
     QuestType();
-    Quest* createValue(Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(
-        Quest* zResult, Framework::JSON::JSONObject* zJson) const override;
-    void toJson(
-        Quest* zObject, Framework::JSON::JSONObject* zResult) const override;
+    Quest* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(Quest* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -192,16 +182,14 @@ public:
     friend QuestDialog;
 };
 
-class QuestCollectionType : public TypeFactory<QuestCollection>
+class QuestCollectionType : public ObjectTypeFactory<QuestCollection>
 {
 public:
     QuestCollectionType();
-    QuestCollection* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(QuestCollection* zResult,
+    QuestCollection* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestCollection* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestCollection* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 12 - 9
FactoryCraft/QuestRequirement.cpp

@@ -108,20 +108,23 @@ QuestRequirementOpenDialog* QuestRequirementOpenDialogType::createValue(
     return new QuestRequirementOpenDialog();
 }
 
-void QuestRequirementOpenDialogType::fromJson(
-    QuestRequirementOpenDialog* zResult,
+QuestRequirementOpenDialog* QuestRequirementOpenDialogType::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setDialogId(zJson->zValue("dialogId")->asString()->getString());
-    QuestRequirementFactoryBase::fromJson(zResult, zJson);
+    QuestRequirementOpenDialog* result
+        = QuestRequirementFactoryBase::fromJson(zJson);
+    result->setDialogId(zJson->zValue("dialogId")->asString()->getString());
+    return result;
 }
 
-void QuestRequirementOpenDialogType::toJson(QuestRequirementOpenDialog* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestRequirementOpenDialogType::toJsonObject(
+    QuestRequirementOpenDialog* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result
+        = QuestRequirementFactoryBase::toJsonObject(zObject);
+    result->addValue(
         "dialogId", new Framework::JSON::JSONString(zObject->dialogId));
-    QuestRequirementFactoryBase::toJson(zObject, zResult);
+    return result;
 }
 
 JSONObjectValidationBuilder* QuestRequirementOpenDialogType::addToValidator(
@@ -136,7 +139,7 @@ JSONObjectValidationBuilder* QuestRequirementOpenDialogType::addToValidator(
             ->finishString());
 }
 
-Framework::Text QuestRequirementOpenDialogType::getTypeToken() const
+const char* QuestRequirementOpenDialogType::getTypeToken() const
 {
     return "open_dialog";
 }

+ 16 - 9
FactoryCraft/QuestRequirement.h

@@ -35,24 +35,28 @@ public:
         : SubTypeFactory<QuestRequirement, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
+        S* result = createValue(zJson);
         QuestRequirement* zRequirement
-            = dynamic_cast<QuestRequirement*>(zResult);
+            = dynamic_cast<QuestRequirement*>(result);
         zRequirement->setRequirementId(
             zJson->zValue("id")->asString()->getString());
         zRequirement->setDescription(
             zJson->zValue("description")->asString()->getString());
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
         QuestRequirement* zRequirement
             = dynamic_cast<QuestRequirement*>(zObject);
-        zResult->addValue("id",
+        result->addValue("id",
             new Framework::JSON::JSONString(zRequirement->getRequirementId()));
-        zResult->addValue("description",
+        result->addValue("description",
             new Framework::JSON::JSONString(zRequirement->getDescription()));
+        return result;
     }
 
     JSONObjectValidationBuilder* addToValidator(
@@ -63,6 +67,9 @@ public:
             ->withRequiredString("description")
             ->finishString();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };
 
 class QuestRequirementOpenDialogType;
@@ -91,13 +98,13 @@ public:
     QuestRequirementOpenDialogType();
     QuestRequirementOpenDialog* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(QuestRequirementOpenDialog* zResult,
+    QuestRequirementOpenDialog* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestRequirementOpenDialog* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestRequirementOpenDialog* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class QuestRequirementBlockBreak : public QuestRequirement

+ 23 - 22
FactoryCraft/QuestReward.cpp

@@ -65,31 +65,29 @@ int ItemStackInfo::getCount() const
 }
 
 ItemStackInfoType::ItemStackInfoType()
-    : TypeFactory<ItemStackInfo>()
+    : ObjectTypeFactory<ItemStackInfo>()
 {}
 
-ItemStackInfo* ItemStackInfoType::createValue(
+ItemStackInfo* ItemStackInfoType::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new ItemStackInfo();
-}
-
-void ItemStackInfoType::fromJson(
-    ItemStackInfo* zObject, Framework::JSON::JSONObject* zJson) const
-{
-    zObject->setItem(Game::INSTANCE->zTypeRegistry()->fromJson<Item>(
+    ItemStackInfo* result = new ItemStackInfo();
+    result->setItem(Game::INSTANCE->zTypeRegistry()->fromJson<Item>(
         zJson->asObject()->zValue("item")));
-    zObject->setCount(
+    result->setCount(
         (int)zJson->asObject()->zValue("count")->asNumber()->getNumber());
+    return result;
 }
 
-void ItemStackInfoType::toJson(
-    ItemStackInfo* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* ItemStackInfoType::toJsonObject(
+    ItemStackInfo* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "item", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zItem()));
-    zResult->addValue(
+    result->addValue(
         "count", new Framework::JSON::JSONNumber((double)zObject->getCount()));
+    return result;
 }
 
 JSONObjectValidationBuilder* ItemStackInfoType::addToValidator(
@@ -200,21 +198,24 @@ QuestRewardGiveItems* QuestRewardGiveItemsType::createValue(
     return new QuestRewardGiveItems();
 }
 
-void QuestRewardGiveItemsType::fromJson(
-    QuestRewardGiveItems* zResult, Framework::JSON::JSONObject* zJson) const
+QuestRewardGiveItems* QuestRewardGiveItemsType::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    QuestRewardGiveItems* result = QuestRewardFactoryBase::fromJson(zJson);
     Framework::JSON::JSONArray* itemsJson = zJson->zValue("items")->asArray();
     for (Framework::JSON::JSONValue* itemJson : *itemsJson)
     {
-        zResult->items.add(
+        result->items.add(
             Game::INSTANCE->zTypeRegistry()->fromJson<ItemStackInfo>(itemJson));
     }
-    QuestRewardFactoryBase::fromJson(zResult, zJson);
+    return result;
 }
 
-void QuestRewardGiveItemsType::toJson(
-    QuestRewardGiveItems* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* QuestRewardGiveItemsType::toJsonObject(
+    QuestRewardGiveItems* zObject) const
 {
+    Framework::JSON::JSONObject* zResult
+        = QuestRewardFactoryBase::toJsonObject(zObject);
     zResult->addValue(
         "rewardId", new Framework::JSON::JSONString(zObject->getRewardId()));
     Framework::JSON::JSONArray* itemsJson = new Framework::JSON::JSONArray();
@@ -223,7 +224,7 @@ void QuestRewardGiveItemsType::toJson(
         itemsJson->addValue(Game::INSTANCE->zTypeRegistry()->toJson(item));
     }
     zResult->addValue("items", itemsJson);
-    QuestRewardFactoryBase::toJson(zObject, zResult);
+    return zResult;
 }
 
 JSONObjectValidationBuilder* QuestRewardGiveItemsType::addToValidator(
@@ -236,7 +237,7 @@ JSONObjectValidationBuilder* QuestRewardGiveItemsType::addToValidator(
             ->finishArray());
 }
 
-Framework::Text QuestRewardGiveItemsType::getTypeToken() const
+const char* QuestRewardGiveItemsType::getTypeToken() const
 {
     return "give_items";
 }

+ 22 - 17
FactoryCraft/QuestReward.h

@@ -39,17 +39,22 @@ public:
         : SubTypeFactory<QuestReward, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        QuestReward* zRequirement = dynamic_cast<QuestReward*>(zResult);
-        zRequirement->setRewardId(zJson->zValue("rewardId")->asString()->getString());
+        S* result = createValue(zJson);
+        QuestReward* zRequirement = dynamic_cast<QuestReward*>(result);
+        zRequirement->setRewardId(
+            zJson->zValue("rewardId")->asString()->getString());
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
         QuestReward* zRequirement = dynamic_cast<QuestReward*>(zObject);
-        zResult->addValue(
-            "rewardId", new Framework::JSON::JSONString(zRequirement->getRewardId()));
+        result->addValue("rewardId",
+            new Framework::JSON::JSONString(zRequirement->getRewardId()));
+        return result;
     }
 
     JSONObjectValidationBuilder* addToValidator(
@@ -57,6 +62,9 @@ public:
     {
         return builder->withRequiredString("rewardId")->finishString();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };
 
 class ItemStackInfo : public virtual Framework::ReferenceCounter
@@ -74,16 +82,13 @@ public:
     int getCount() const;
 };
 
-class ItemStackInfoType : public TypeFactory<ItemStackInfo>
+class ItemStackInfoType : public ObjectTypeFactory<ItemStackInfo>
 {
 public:
     ItemStackInfoType();
-    ItemStackInfo* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(ItemStackInfo* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(ItemStackInfo* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    ItemStackInfo* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        ItemStackInfo* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -115,11 +120,11 @@ public:
     QuestRewardGiveItemsType();
     QuestRewardGiveItems* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(QuestRewardGiveItems* zResult,
+    QuestRewardGiveItems* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(QuestRewardGiveItems* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        QuestRewardGiveItems* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 60 - 61
FactoryCraft/Recipie.cpp

@@ -52,36 +52,33 @@ int RecipieInput::getAmount() const
 }
 
 RecipieInputFactory::RecipieInputFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-RecipieInput* RecipieInputFactory::createValue(
+RecipieInput* RecipieInputFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new RecipieInput();
-}
-
-void RecipieInputFactory::fromJson(
-    RecipieInput* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<ItemFilter>(
+    RecipieInput* result = new RecipieInput();
+    result->setFilter(Game::INSTANCE->zTypeRegistry()->fromJson<ItemFilter>(
         zJson->asObject()->zValue("filter")));
-    zResult->setModifier(
-        Game::INSTANCE->zTypeRegistry()->fromJson<ItemModifier>(
-            zJson->asObject()->zValue("modifier")));
-    zResult->setAmount(
+    result->setModifier(Game::INSTANCE->zTypeRegistry()->fromJson<ItemModifier>(
+        zJson->asObject()->zValue("modifier")));
+    result->setAmount(
         (int)zJson->asObject()->zValue("amount")->asNumber()->getNumber());
+    return result;
 }
 
-void RecipieInputFactory::toJson(
-    RecipieInput* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* RecipieInputFactory::toJsonObject(
+    RecipieInput* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue(
         "filter", Game::INSTANCE->zTypeRegistry()->toJson(zObject->zFilter()));
-    zResult->addValue("modifier",
+    result->addValue("modifier",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zModifier()));
-    zResult->addValue("amount",
+    result->addValue("amount",
         new Framework::JSON::JSONNumber((double)zObject->getAmount()));
+    return result;
 }
 
 JSONObjectValidationBuilder* RecipieInputFactory::addToValidator(
@@ -162,37 +159,34 @@ Item* RecipieOutput::createItem() const
 }
 
 RecipieOutputFactory::RecipieOutputFactory()
-    : TypeFactory()
+    : ObjectTypeFactory()
 {}
 
-RecipieOutput* RecipieOutputFactory::createValue(
+RecipieOutput* RecipieOutputFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    return new RecipieOutput();
-}
-
-void RecipieOutputFactory::fromJson(
-    RecipieOutput* zResult, Framework::JSON::JSONObject* zJson) const
-{
-    zResult->setItemTypeId(Game::INSTANCE->getItemTypeId(
+    RecipieOutput* result = new RecipieOutput();
+    result->setItemTypeId(Game::INSTANCE->getItemTypeId(
         zJson->asObject()->zValue("itemType")->asString()->getString()));
-    zResult->setAmount(
+    result->setAmount(
         (int)zJson->asObject()->zValue("amount")->asNumber()->getNumber());
-    zResult->setModifier(
-        Game::INSTANCE->zTypeRegistry()->fromJson<ItemModifier>(
-            zJson->asObject()->zValue("modifier")));
+    result->setModifier(Game::INSTANCE->zTypeRegistry()->fromJson<ItemModifier>(
+        zJson->asObject()->zValue("modifier")));
+    return result;
 }
 
-void RecipieOutputFactory::toJson(
-    RecipieOutput* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* RecipieOutputFactory::toJsonObject(
+    RecipieOutput* zObject) const
 {
-    zResult->addValue("itemType",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("itemType",
         new Framework::JSON::JSONString(
             Game::INSTANCE->zItemType(zObject->getItemTypeId())->getName()));
-    zResult->addValue("amount",
+    result->addValue("amount",
         new Framework::JSON::JSONNumber((double)zObject->getAmount()));
-    zResult->addValue("modifier",
+    result->addValue("modifier",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zModifier()));
+    return result;
 }
 
 JSONObjectValidationBuilder* RecipieOutputFactory::addToValidator(
@@ -376,28 +370,30 @@ UnshapedRecipie* UnshapedRecipieFactory::createValue(
     return new UnshapedRecipie();
 }
 
-void UnshapedRecipieFactory::fromJson(
-    UnshapedRecipie* zResult, Framework::JSON::JSONObject* zJson) const
+UnshapedRecipie* UnshapedRecipieFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    UnshapedRecipie* result = RecipieFactory::fromJson(zJson);
     for (Framework::JSON::JSONValue* input :
         *zJson->zValue("inputs")->asArray())
     {
-        zResult->addInput(
+        result->addInput(
             Game::INSTANCE->zTypeRegistry()->fromJson<RecipieInput>(input));
     }
-    RecipieFactory::fromJson(zResult, zJson);
+    return result;
 }
 
-void UnshapedRecipieFactory::toJson(
-    UnshapedRecipie* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* UnshapedRecipieFactory::toJsonObject(
+    UnshapedRecipie* zObject) const
 {
+    Framework::JSON::JSONObject* result = RecipieFactory::toJsonObject(zObject);
     Framework::JSON::JSONArray* inputs = new Framework::JSON::JSONArray();
     for (RecipieInput* input : zObject->getInputs())
     {
         inputs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(input));
     }
-    zResult->addValue("inputs", inputs);
-    RecipieFactory::toJson(zObject, zResult);
+    result->addValue("inputs", inputs);
+    return result;
 }
 
 JSONObjectValidationBuilder* UnshapedRecipieFactory::addToValidator(
@@ -410,7 +406,7 @@ JSONObjectValidationBuilder* UnshapedRecipieFactory::addToValidator(
             ->finishArray());
 }
 
-Framework::Text UnshapedRecipieFactory::getTypeToken() const
+const char* UnshapedRecipieFactory::getTypeToken() const
 {
     return "unshaped";
 }
@@ -540,14 +536,15 @@ ShapedRecipie* ShapedRecipieFactory::createValue(
     return new ShapedRecipie();
 }
 
-void ShapedRecipieFactory::fromJson(
-    ShapedRecipie* zResult, Framework::JSON::JSONObject* zJson) const
+ShapedRecipie* ShapedRecipieFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
+    ShapedRecipie* result = RecipieFactory::fromJson(zJson);
     int width = (int)zJson->zValue("width")->asNumber()->getNumber();
     int height = (int)zJson->zValue("height")->asNumber()->getNumber();
     for (int i = 0; i < width * height; i++)
     {
-        zResult->addInput(new RecipieInput());
+        result->addInput(new RecipieInput());
     }
     for (Framework::JSON::JSONValue* input :
         *zJson->zValue("inputs")->asArray())
@@ -558,24 +555,26 @@ void ShapedRecipieFactory::fromJson(
         {
             Framework::Logging::warning()
                 << "Invalid input position in shaped recipie with width="
-                << width << ", height=" << height << ", x=" << x << ", y=" << y;
-            return;
+                << width << ", height=" << height << ", x=" << x << ", y=" << y
+                << " input " << input->toString() << " will be ignored.";
+            continue;
         }
-        zResult->setInput(y * width + x,
+        result->setInput(y * width + x,
             Game::INSTANCE->zTypeRegistry()->fromJson<RecipieInput>(
                 input->asObject()->zValue("input")));
     }
-    zResult->setWidth((int)zJson->zValue("width")->asNumber()->getNumber());
-    zResult->setHeight((int)zJson->zValue("height")->asNumber()->getNumber());
-    RecipieFactory::fromJson(zResult, zJson);
+    result->setWidth((int)zJson->zValue("width")->asNumber()->getNumber());
+    result->setHeight((int)zJson->zValue("height")->asNumber()->getNumber());
+    return result;
 }
 
-void ShapedRecipieFactory::toJson(
-    ShapedRecipie* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* ShapedRecipieFactory::toJsonObject(
+    ShapedRecipie* zObject) const
 {
-    zResult->addValue(
+    Framework::JSON::JSONObject* result = RecipieFactory::toJsonObject(zObject);
+    result->addValue(
         "width", new Framework::JSON::JSONNumber(zObject->getWidth()));
-    zResult->addValue(
+    result->addValue(
         "height", new Framework::JSON::JSONNumber(zObject->getHeight()));
     Framework::JSON::JSONArray* inputs = new Framework::JSON::JSONArray();
     for (int i = 0; i < zObject->getWidth() * zObject->getHeight(); i++)
@@ -589,8 +588,8 @@ void ShapedRecipieFactory::toJson(
             Game::INSTANCE->zTypeRegistry()->toJson(zObject->getInputs().z(i)));
         inputs->addValue(input);
     }
-    zResult->addValue("inputs", inputs);
-    RecipieFactory::toJson(zObject, zResult);
+    result->addValue("inputs", inputs);
+    return result;
 }
 
 JSONObjectValidationBuilder* ShapedRecipieFactory::addToValidator(
@@ -617,7 +616,7 @@ JSONObjectValidationBuilder* ShapedRecipieFactory::addToValidator(
             ->finishNumber());
 }
 
-Framework::Text ShapedRecipieFactory::getTypeToken() const
+const char* ShapedRecipieFactory::getTypeToken() const
 {
     return "shaped";
 }

+ 29 - 29
FactoryCraft/Recipie.h

@@ -37,16 +37,13 @@ public:
     int getAmount() const;
 };
 
-class RecipieInputFactory : public TypeFactory<RecipieInput>
+class RecipieInputFactory : public ObjectTypeFactory<RecipieInput>
 {
 public:
     RecipieInputFactory();
-    RecipieInput* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(RecipieInput* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(RecipieInput* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    RecipieInput* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        RecipieInput* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -70,16 +67,13 @@ public:
     Item* createItem() const;
 };
 
-class RecipieOutputFactory : public TypeFactory<RecipieOutput>
+class RecipieOutputFactory : public ObjectTypeFactory<RecipieOutput>
 {
 public:
     RecipieOutputFactory();
-    RecipieOutput* createValue(
-        Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(RecipieOutput* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(RecipieOutput* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    RecipieOutput* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        RecipieOutput* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };
@@ -110,9 +104,10 @@ public:
         : SubTypeFactory<Recipie, S>()
     {}
 
-    void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const override
+    S* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
-        Recipie* zRecipie = dynamic_cast<Recipie*>(zResult);
+        S* result = createValue(zJson);
+        Recipie* zRecipie = dynamic_cast<Recipie*>(result);
         for (Framework::JSON::JSONValue* output :
             *zJson->zValue("outputs")->asArray())
         {
@@ -121,19 +116,22 @@ public:
                     output));
         }
         zRecipie->setGroupName(zJson->zValue("group")->asString()->getString());
+        return result;
     }
 
-    void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(S* zObject) const override
     {
-        Recipie* zRecipie = dynamic_cast<Recipie*>(zResult);
+        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+        Recipie* zRecipie = dynamic_cast<Recipie*>(result);
         Framework::JSON::JSONArray* outputs = new Framework::JSON::JSONArray();
         for (RecipieOutput* output : zRecipie->getOutputs())
         {
             outputs->addValue(Game::INSTANCE->zTypeRegistry()->toJson(output));
         }
-        zResult->addValue("outputs", outputs);
-        zResult->addValue(
+        result->addValue("outputs", outputs);
+        result->addValue(
             "group", new Framework::JSON::JSONString(zRecipie->getGroupName()));
+        return result;
     };
 
     JSONObjectValidationBuilder* addToValidator(
@@ -146,6 +144,9 @@ public:
             ->withRequiredString("group")
             ->finishString();
     }
+
+protected:
+    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
 };
 
 class UnshapedRecipie : public Recipie
@@ -168,13 +169,13 @@ public:
     UnshapedRecipieFactory();
     UnshapedRecipie* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(UnshapedRecipie* zResult,
+    UnshapedRecipie* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(UnshapedRecipie* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        UnshapedRecipie* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };
 
 class ShapedRecipie : public Recipie
@@ -204,11 +205,10 @@ public:
     ShapedRecipieFactory();
     ShapedRecipie* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(ShapedRecipie* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(ShapedRecipie* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    ShapedRecipie* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        ShapedRecipie* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 5 - 5
FactoryCraft/RecipieLoader.cpp

@@ -10,7 +10,7 @@
 #include "JsonUtils.h"
 
 using namespace Framework::JSON;
-using namespace Validator;
+using namespace Framework::Validator;
 
 RecipieLoader::RecipieLoader()
     : Framework::ReferenceCounter(),
@@ -28,15 +28,15 @@ void RecipieLoader::loadRecipies(const char* path)
         path, [this](JSONValue* zJson, Framework::Text path) {
             Framework::Logging::info()
                 << "loading recipies from '" << path << "'";
-            JSONValidator* validator
-                = Framework::JSON::Validator::JSONValidator::buildForArray()
+            DataValidator* validator
+                = Framework::Validator::DataValidator::buildForArray()
                       ->addAcceptedTypeInArray(Game::INSTANCE->zTypeRegistry()
                                                    ->getValidator<Recipie>())
                       ->removeInvalidEntries()
                       ->finishArray();
-            Framework::RCArray<JSONValidationResult> invalidParts;
+            Framework::RCArray<ValidationResult> invalidParts;
             JSONValue* valid = validator->getValidParts(zJson, &invalidParts);
-            for (JSONValidationResult* invalidPart : invalidParts)
+            for (ValidationResult* invalidPart : invalidParts)
             {
                 Framework::Logging::error() << invalidPart->getInvalidInfo();
             }

+ 1 - 1
FactoryCraft/RecipieLoader.h

@@ -7,7 +7,7 @@ class RecipieLoader : public virtual Framework::ReferenceCounter
 {
 private:
     Framework::RCArray<RecipieList> lists;
-    Framework::JSON::Validator::JSONValidator* validator;
+    Framework::Validator::DataValidator* validator;
 
 public:
     RecipieLoader();

+ 24 - 26
FactoryCraft/StructureCollection.cpp

@@ -72,7 +72,8 @@ void StructureTemplateCollection::generateStructures(int x,
     }
 }
 
-void StructureTemplateCollection::setThreshold(double threshold) {
+void StructureTemplateCollection::setThreshold(double threshold)
+{
     this->threshold = threshold;
 }
 
@@ -81,9 +82,10 @@ double StructureTemplateCollection::getThreshold() const
     return threshold;
 }
 
-void StructureTemplateCollection::setCondition(JBoolExpression* condition) {
-	if (this->condition) this->condition->release();
-	this->condition = condition;
+void StructureTemplateCollection::setCondition(JBoolExpression* condition)
+{
+    if (this->condition) this->condition->release();
+    this->condition = condition;
 }
 
 JBoolExpression* StructureTemplateCollection::zCondition() const
@@ -155,55 +157,51 @@ Framework::Vec3<int> StructureTemplateCollection::getMaxAffected() const
 }
 
 StructureTemplateCollectionFactory::StructureTemplateCollectionFactory()
-    : TypeFactory<StructureTemplateCollection>()
+    : ObjectTypeFactory<StructureTemplateCollection>()
 {}
 
-StructureTemplateCollection* StructureTemplateCollectionFactory::createValue(
-    Framework::JSON::JSONObject* zJson) const
-{
-    return new StructureTemplateCollection();
-}
-
-void StructureTemplateCollectionFactory::fromJson(
-    StructureTemplateCollection* zResult,
+StructureTemplateCollection* StructureTemplateCollectionFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setActiveNoiseConfig(zJson->getValue("activeNoise")->asObject());
-    zResult->setStructureNoiseConfig(
+    StructureTemplateCollection* result = new StructureTemplateCollection();
+    result->setActiveNoiseConfig(zJson->getValue("activeNoise")->asObject());
+    result->setStructureNoiseConfig(
         zJson->getValue("structureNoise")->asObject());
-    zResult->setThreshold(zJson->zValue("threshold")->asNumber()->getNumber());
-    zResult->setCondition(
+    result->setThreshold(zJson->zValue("threshold")->asNumber()->getNumber());
+    result->setCondition(
         Game::INSTANCE->zTypeRegistry()->fromJson<JBoolExpression>(
             zJson->zValue("condition")));
     for (Framework::JSON::JSONValue* structure :
         *zJson->zValue("structures")->asArray())
     {
-        zResult->addStructure(
+        result->addStructure(
             Game::INSTANCE->zTypeRegistry()->fromJson<GeneratorTemplate>(
                 structure->asObject()));
     }
+    return result;
 }
 
-void StructureTemplateCollectionFactory::toJson(
-    StructureTemplateCollection* zObject,
-    Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* StructureTemplateCollectionFactory::toJsonObject(
+    StructureTemplateCollection* zObject) const
 {
-    zResult->addValue("activeNoise",
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("activeNoise",
         dynamic_cast<Framework::JSON::JSONValue*>(
             zObject->zActiveNoiseConfig()->getThis()));
-    zResult->addValue("structureNoise",
+    result->addValue("structureNoise",
         dynamic_cast<Framework::JSON::JSONValue*>(
             zObject->zStructureNoiseConfig()->getThis()));
-    zResult->addValue(
+    result->addValue(
         "threshold", new Framework::JSON::JSONNumber(zObject->getThreshold()));
-    zResult->addValue("condition",
+    result->addValue("condition",
         Game::INSTANCE->zTypeRegistry()->toJson(zObject->zCondition()));
     Framework::JSON::JSONArray* structures = new Framework::JSON::JSONArray();
     for (GeneratorTemplate* t : zObject->getStructures())
     {
         structures->addValue(Game::INSTANCE->zTypeRegistry()->toJson(t));
     }
-    zResult->addValue("structures", structures);
+    result->addValue("structures", structures);
+    return result;
 }
 
 JSONObjectValidationBuilder* StructureTemplateCollectionFactory::addToValidator(

+ 4 - 6
FactoryCraft/StructureCollection.h

@@ -48,16 +48,14 @@ public:
 };
 
 class StructureTemplateCollectionFactory
-    : public TypeFactory<StructureTemplateCollection>
+    : public ObjectTypeFactory<StructureTemplateCollection>
 {
 public:
     StructureTemplateCollectionFactory();
-    StructureTemplateCollection* createValue(
+    StructureTemplateCollection* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(StructureTemplateCollection* zResult,
-        Framework::JSON::JSONObject* zJson) const override;
-    void toJson(StructureTemplateCollection* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        StructureTemplateCollection* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
 };

+ 17 - 17
FactoryCraft/TreeSeblingBlock.cpp

@@ -244,27 +244,27 @@ TreeSeblingBlockType* TreeSeblingBlockTypeFactory::createValue(
     return new TreeSeblingBlockType();
 }
 
-void TreeSeblingBlockTypeFactory::fromJson(
-    TreeSeblingBlockType* zResult, Framework::JSON::JSONObject* zJson) const
+TreeSeblingBlockType* TreeSeblingBlockTypeFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
 {
-    zResult->setItemTypeName(
-        zJson->zValue("itemType")->asString()->getString());
-    zResult->setWoodTypeName(
-        zJson->zValue("woodType")->asString()->getString());
-    zResult->setLeavesTypeName(
+    TreeSeblingBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
+    result->setItemTypeName(zJson->zValue("itemType")->asString()->getString());
+    result->setWoodTypeName(zJson->zValue("woodType")->asString()->getString());
+    result->setLeavesTypeName(
         zJson->zValue("leavesType")->asString()->getString());
-    zResult->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
-    zResult->setPassable(zJson->zValue("passable")->asBool()->getBool());
-    zResult->setSpeedModifier(
+    result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
+    result->setPassable(zJson->zValue("passable")->asBool()->getBool());
+    result->setSpeedModifier(
         (float)zJson->zValue("speedModifier")->asNumber()->getNumber());
-    zResult->setInteractable(
-        zJson->zValue("interactable")->asBool()->getBool());
-    BlockTypeFactoryBase::fromJson(zResult, zJson);
+    result->setInteractable(zJson->zValue("interactable")->asBool()->getBool());
+    return result;
 }
 
-void TreeSeblingBlockTypeFactory::toJson(
-    TreeSeblingBlockType* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* TreeSeblingBlockTypeFactory::toJsonObject(
+    TreeSeblingBlockType* zObject) const
 {
+    Framework::JSON::JSONObject* zResult
+        = BlockTypeFactoryBase::toJsonObject(zObject);
     zResult->addValue("itemType",
         new Framework::JSON::JSONString(zObject->getItemTypeName()));
     zResult->addValue("woodType",
@@ -279,7 +279,7 @@ void TreeSeblingBlockTypeFactory::toJson(
         new Framework::JSON::JSONNumber(zObject->getSpeedModifier()));
     zResult->addValue("interactable",
         new Framework::JSON::JSONNumber(zObject->isInteractable()));
-    BlockTypeFactoryBase::toJson(zObject, zResult);
+    return zResult;
 }
 
 JSONObjectValidationBuilder* TreeSeblingBlockTypeFactory::addToValidator(
@@ -306,7 +306,7 @@ JSONObjectValidationBuilder* TreeSeblingBlockTypeFactory::addToValidator(
             ->finishBool());
 }
 
-Framework::Text TreeSeblingBlockTypeFactory::getTypeToken() const
+const char* TreeSeblingBlockTypeFactory::getTypeToken() const
 {
     return "treeSapling";
 }

+ 4 - 4
FactoryCraft/TreeSeblingBlock.h

@@ -82,11 +82,11 @@ public:
     TreeSeblingBlockTypeFactory();
     TreeSeblingBlockType* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(TreeSeblingBlockType* zResult,
+    TreeSeblingBlockType* fromJson(
         Framework::JSON::JSONObject* zJson) const override;
-    void toJson(TreeSeblingBlockType* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        TreeSeblingBlockType* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 19 - 15
FactoryCraft/TreeTemplate.cpp

@@ -121,33 +121,37 @@ TreeTemplate* TreeTemplateFactory::createValue(
     return new TreeTemplate();
 }
 
-void TreeTemplateFactory::fromJson(
-    TreeTemplate* zResult, Framework::JSON::JSONObject* zConfig) const
+TreeTemplate* TreeTemplateFactory::fromJson(
+    Framework::JSON::JSONObject* zConfig) const
 {
-    zResult->setWoodTypeId(BlockType::getTypeId(
+    TreeTemplate* result = GeneratorTemplateFactory::fromJson(zConfig);
+    result->setWoodTypeId(BlockType::getTypeId(
         zConfig->asObject()->zValue("wood")->asString()->getString()));
-    zResult->setLeavesTypeId(BlockType::getTypeId(
+    result->setLeavesTypeId(BlockType::getTypeId(
         zConfig->asObject()->zValue("leaves")->asString()->getString()));
-    zResult->setMinHeight(
+    result->setMinHeight(
         (int)(zConfig->asObject()->zValue("minSize")->asNumber()->getNumber()));
-    zResult->setMaxHeight(
+    result->setMaxHeight(
         (int)(zConfig->asObject()->zValue("maxSize")->asNumber()->getNumber()));
-    GeneratorTemplateFactory::fromJson(zResult, zConfig);
+    return result;
 }
 
-void TreeTemplateFactory::toJson(
-    TreeTemplate* zObject, Framework::JSON::JSONObject* zResult) const
+Framework::JSON::JSONObject* TreeTemplateFactory::toJsonObject(
+    TreeTemplate* zObject) const
 {
-    zResult->addValue("propability",
+    Framework::JSON::JSONObject* result
+        = GeneratorTemplateFactory::toJsonObject(zObject);
+    result->addValue("propability",
         new Framework::JSON::JSONNumber((double)zObject->getPropability()));
-    zResult->addValue("wood",
+    result->addValue("wood",
         new Framework::JSON::JSONString(zObject->zWoodType()->getName()));
-    zResult->addValue("leaves",
+    result->addValue("leaves",
         new Framework::JSON::JSONString(zObject->zLeavesType()->getName()));
-    zResult->addValue("minSize",
+    result->addValue("minSize",
         new Framework::JSON::JSONNumber((double)zObject->getMinHeight()));
-    zResult->addValue("maxSize",
+    result->addValue("maxSize",
         new Framework::JSON::JSONNumber((double)zObject->getMaxHeight()));
+    return result;
 }
 
 JSONObjectValidationBuilder* TreeTemplateFactory::addToValidator(
@@ -180,7 +184,7 @@ JSONObjectValidationBuilder* TreeTemplateFactory::addToValidator(
             ->finishNumber());
 }
 
-Framework::Text TreeTemplateFactory::getTypeToken() const
+const char* TreeTemplateFactory::getTypeToken() const
 {
     return "Tree";
 }

+ 4 - 5
FactoryCraft/TreeTemplate.h

@@ -31,11 +31,10 @@ public:
     TreeTemplateFactory();
     TreeTemplate* createValue(
         Framework::JSON::JSONObject* zJson) const override;
-    void fromJson(TreeTemplate* zResult,
-        Framework::JSON::JSONObject* zConfig) const override;
-    void toJson(TreeTemplate* zObject,
-        Framework::JSON::JSONObject* zResult) const override;
+    TreeTemplate* fromJson(Framework::JSON::JSONObject* zConfig) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        TreeTemplate* zObject) const override;
     JSONObjectValidationBuilder* addToValidator(
         JSONObjectValidationBuilder* builder) const override;
-    virtual Framework::Text getTypeToken() const override;
+    const char* getTypeToken() const override;
 };

+ 1 - 1
FactoryCraft/TypeRegistry.cpp

@@ -131,7 +131,7 @@ void TypeRegistry::writeSyntaxInfo(Framework::Text folderPath) const
     {
         TypeFatoryRef* factory
             = parsableTypes.z(typeId->getText(), typeId->getLength());
-        Framework::JSON::Validator::JSONValidator* validator
+        Framework::Validator::DataValidator* validator
             = factory->getValidator();
         Framework::Datei syntaxFile(
             new Framework::Text(folderPath + "/" + *typeId + ".xml"));

+ 152 - 200
FactoryCraft/TypeRegistry.h

@@ -2,6 +2,7 @@
 
 #include <Array.h>
 #include <cstdlib>
+#include <DataValidator.h>
 #include <JSON.h>
 #include <Logging.h>
 #include <Trie.h>
@@ -9,34 +10,55 @@
 
 class TypeRegistry;
 
-#define JSONObjectValidationBuilder                      \
-    Framework::JSON::Validator::ObjectValidationBuilder< \
-        Framework::JSON::Validator::JSONValidator>
+#define JSONObjectValidationBuilder                \
+    Framework::Validator::ObjectValidationBuilder< \
+        Framework::Validator::DataValidator>
+
+template<typename T> class SimpleTypeFactory
+    : public Framework::ReferenceCounter
+{
+public:
+    SimpleTypeFactory()
+        : ReferenceCounter() {};
+    virtual T fromJson(Framework::JSON::JSONValue* zJson) const = 0;
+    virtual Framework::JSON::JSONValue* toJson(T value) const = 0;
+    virtual Framework::Validator::DataValidator* getValidator() const = 0;
+};
 
 /*
  * Used to convert an object of type T to a JSONValue and vice versa.
  * Can be registered at the TypeRegistry to be used by the JSON system
  */
-template<typename T> class TypeFactory : public Framework::ReferenceCounter
+template<typename T> class ObjectTypeFactory : public SimpleTypeFactory<T*>
 {
 public:
-    TypeFactory()
-        : ReferenceCounter(){};
-    virtual T* createValue(Framework::JSON::JSONObject* zJson) const = 0;
-    virtual void fromJson(T* zResult, Framework::JSON::JSONObject* zJson) const
-        = 0;
-    virtual void toJson(T* zObject, Framework::JSON::JSONObject* zResult) const
-        = 0;
-    virtual JSONObjectValidationBuilder* addToValidator(
-        JSONObjectValidationBuilder* builder) const
-        = 0;
+    ObjectTypeFactory()
+        : SimpleTypeFactory<T*>() {};
 
-    virtual Framework::JSON::Validator::JSONValidator* getValidator() const
+    T* fromJson(Framework::JSON::JSONValue* zJson) const final override
+    {
+        return fromJson(zJson->asObject());
+    }
+
+    Framework::JSON::JSONValue* toJson(T* value) const final override
+    {
+        return toJsonObject(value);
+    }
+
+    virtual Framework::Validator::DataValidator* getValidator() const override
     {
         return addToValidator(
-            Framework::JSON::Validator::JSONValidator::buildForObject())
+            Framework::Validator::DataValidator::buildForObject())
             ->finishObject();
     };
+
+    virtual JSONObjectValidationBuilder* addToValidator(
+        JSONObjectValidationBuilder* builder) const
+        = 0;
+
+protected:
+    virtual T* fromJson(Framework::JSON::JSONObject* zJson) const = 0;
+    virtual Framework::JSON::JSONObject* toJsonObject(T* zObject) const = 0;
 };
 
 /*
@@ -47,53 +69,53 @@ public:
 template<typename T,
     typename S,
     typename = std::enable_if<std::is_base_of<T, S>::value>>
-class SubTypeFactory : public Framework::ReferenceCounter
+class SubTypeFactory : public ObjectTypeFactory<S>
 {
 public:
     SubTypeFactory()
-        : ReferenceCounter(){};
-    virtual S* createValue(Framework::JSON::JSONObject* zJson) const = 0;
-    virtual void fromJson(S* zResult, Framework::JSON::JSONObject* zJson) const
-        = 0;
-    virtual void toJson(S* zObject, Framework::JSON::JSONObject* zResult) const
-        = 0;
-    virtual JSONObjectValidationBuilder* addToValidator(
-        JSONObjectValidationBuilder* builder) const
-        = 0;
+        : ObjectTypeFactory<S>() {};
 
-    virtual Framework::JSON::Validator::JSONValidator* getValidator() const
+    virtual Framework::Validator::DataValidator*
+    getValidator() const final override
     {
-        return addToValidator(
-            Framework::JSON::Validator::JSONValidator::buildForObject())
+        Framework::Text referenceId = "_type_";
+        referenceId.append() << typeid(T).name() << "_" << getTypeToken();
+        return this
+            ->addToValidator(
+                Framework::Validator::DataValidator::buildForObject()
+                    ->withRequiredString("type")
+                    ->withExactMatch(getTypeToken())
+                    ->finishString()
+                    ->setReferenceId(referenceId))
             ->finishObject();
     };
 
-    virtual Framework::Text getTypeToken() const = 0;
+    virtual const char* getTypeToken() const = 0;
+
+    virtual const char* getTypeName() const
+    {
+        return typeid(S).name();
+    }
 };
 
 template<typename T> class SubTypeFactoryRef
     : public Framework::ReferenceCounter
 {
 private:
-    Framework::Text typetoken;
-    std::function<T*(Framework::JSON::JSONObject*)> createJValueFunc;
-    std::function<void(T*, Framework::JSON::JSONObject*)> fromJsonFunc;
-    std::function<void(T*, Framework::JSON::JSONObject*)> toJsonFunc;
-    std::function<JSONObjectValidationBuilder*(JSONObjectValidationBuilder*)>
-        getValidatorFunc;
+    std::function<const char*()> typetokenFunc;
+    std::function<T*(Framework::JSON::JSONValue*)> fromJsonFunc;
+    std::function<Framework::JSON::JSONValue*(T*)> toJsonFunc;
+    std::function<Framework::Validator::DataValidator*()> getValidatorFunc;
     Framework::ReferenceCounter* factory;
 
 public:
-    SubTypeFactoryRef(Framework::Text typetoken,
-        std::function<T*(Framework::JSON::JSONObject*)> createJValueFunc,
-        std::function<void(T*, Framework::JSON::JSONObject*)> fromJsonFunc,
-        std::function<void(T*, Framework::JSON::JSONObject*)> toJsonFunc,
-        std::function<JSONObjectValidationBuilder*(
-            JSONObjectValidationBuilder*)> getValidatorFunc,
+    SubTypeFactoryRef(std::function<const char*()> typetokenFunc,
+        std::function<T*(Framework::JSON::JSONValue*)> fromJsonFunc,
+        std::function<Framework::JSON::JSONValue*(T*)> toJsonFunc,
+        std::function<Framework::Validator::DataValidator*()> getValidatorFunc,
         Framework::ReferenceCounter* factory)
         : ReferenceCounter(),
-          createJValueFunc(createJValueFunc),
-          typetoken(typetoken),
+          typetokenFunc(typetokenFunc),
           fromJsonFunc(fromJsonFunc),
           toJsonFunc(toJsonFunc),
           getValidatorFunc(getValidatorFunc),
@@ -105,34 +127,28 @@ public:
         factory->release();
     }
 
-    T* createValue(Framework::JSON::JSONObject* zJson) const
+    T* fromJson(Framework::JSON::JSONValue* zJson) const
     {
-        return createJValueFunc(zJson);
+        return fromJsonFunc(zJson);
     }
 
-    void fromJson(T* zResult, Framework::JSON::JSONObject* zJson) const
+    Framework::JSON::JSONValue* toJson(T* zObject) const
     {
-        fromJsonFunc(zResult, zJson);
+        return toJsonFunc(zObject);
     }
 
-    void toJSON(T* zObject, Framework::JSON::JSONObject* zResult) const
-    {
-        toJsonFunc(zObject, zResult);
-    }
-
-    JSONObjectValidationBuilder* addToValidator(
-        JSONObjectValidationBuilder* builder) const
+    Framework::Validator::DataValidator* getValidator() const
     {
-        return getValidatorFunc(builder);
+        return getValidatorFunc();
     }
 
-    const Framework::Text& getTypetoken() const
+    const char* getTypeToken() const
     {
-        return typetoken;
+        return typetokenFunc();
     }
 };
 
-template<typename T> class PolymorphTypeFactory : public TypeFactory<T>
+template<typename T> class PolymorphTypeFactory : public ObjectTypeFactory<T>
 {
 private:
     Framework::RCArray<SubTypeFactoryRef<T>> factories;
@@ -141,54 +157,45 @@ private:
 
 public:
     PolymorphTypeFactory()
-        : TypeFactory<T>()
+        : ObjectTypeFactory<T>()
     {}
 
-    T* createValue(Framework::JSON::JSONObject* zJson) const override
+    T* fromJson(Framework::JSON::JSONObject* zJson) const override
     {
         for (SubTypeFactoryRef<T>* factory : factories)
         {
-            if (zJson->asObject()
-                    ->zValue("type")
-                    ->asString()
-                    ->getString()
-                    .istGleich(factory->getTypetoken()))
+            if (zJson->zValue("type")->asString()->getString().istGleich(
+                    factory->getTypeToken()))
             {
-                return factory->createValue(zJson->asObject());
+                return factory->fromJson(zJson);
             }
         }
+        Framework::Logging::error()
+            << "No Sub Type Factory for typetoken "
+            << zJson->zValue("type")->asString()->getString() << " of type "
+            << typeid(T).name() << " was found.";
         return 0;
     }
 
-    void fromJson(T* zResult, Framework::JSON::JSONObject* zJson) const override
-    {
-        for (SubTypeFactoryRef<T>* factory : factories)
-        {
-            if (zJson->asObject()
-                    ->zValue("type")
-                    ->asString()
-                    ->getString()
-                    .istGleich(factory->getTypetoken()))
-            {
-                factory->fromJson(zResult, zJson->asObject());
-            }
-        }
-    }
-
-    void toJson(T* zObject, Framework::JSON::JSONObject* zResult) const override
+    Framework::JSON::JSONObject* toJsonObject(T* zObject) const override
     {
         auto name = typeNames.begin();
         for (SubTypeFactoryRef<T>* factory : factories)
         {
             if (name->istGleich(typeid(*zObject).name()))
             {
-                factory->toJSON(zObject, zResult);
-                zResult->addValue("type",
-                    new Framework::JSON::JSONString(factory->getTypetoken()));
-                return;
+                Framework::JSON::JSONObject* result
+                    = factory->toJson(zObject)->asObject();
+                result->addValue("type",
+                    new Framework::JSON::JSONString(factory->getTypeToken()));
+                return result;
             }
             name++;
         }
+        Framework::Logging::error()
+            << "No Sub Type Factory for subtype " << typeid(*zObject).name()
+            << " of type " << typeid(T).name() << " was found.";
+        return new Framework::JSON::JSONObject();
     }
 
     JSONObjectValidationBuilder* addToValidator(
@@ -202,31 +209,18 @@ public:
               "validation builder";
     }
 
-    Framework::JSON::Validator::JSONValidator* getValidator() const override
+    Framework::Validator::DataValidator* getValidator() const override
     {
-        Framework::JSON::Validator::JSONValidator* result;
+        Framework::Validator::DataValidator* result;
         if (!insideGetValidator)
         {
             insideGetValidator = true;
             auto validator
-                = Framework::JSON::Validator::JSONValidator::buildForOneOf()
+                = Framework::Validator::DataValidator::buildForOneOf()
                       ->typeSpecifiedByAttribute("type");
             for (SubTypeFactoryRef<T>* factory : factories)
             {
-                validator = validator->addAcceptedType(
-                    factory
-                        ->addToValidator(
-                            Framework::JSON::Validator::JSONValidator::
-                                buildForObject()
-                                    ->withRequiredString("type")
-                                    ->withExactMatch(factory->getTypetoken())
-                                    ->finishString()
-                                    ->setObjectReferenceId(
-                                        ((Framework::Text("_type_")
-                                             += typeid(T).name())
-                                            += "_")
-                                        += factory->getTypetoken()))
-                        ->finishObject());
+                validator = validator->addAcceptedType(factory->getValidator());
             }
             result = validator->finishOneOf();
             insideGetValidator = false;
@@ -234,15 +228,14 @@ public:
         else
         {
             auto validator
-                = Framework::JSON::Validator::JSONValidator::buildForOneOf()
+                = Framework::Validator::DataValidator::buildForOneOf()
                       ->typeSpecifiedByAttribute("type");
             for (SubTypeFactoryRef<T>* factory : factories)
             {
-                validator = validator->addAcceptedType(Framework::JSON::
-                        Validator::JSONValidator::buildForObjectReference(
-                            ((Framework::Text("_type_") += typeid(T).name())
-                                += "_")
-                            += factory->getTypetoken()));
+                validator = validator->addAcceptedType(
+                    Framework::Validator::DataValidator::buildForReference(
+                        ((Framework::Text("_type_") += typeid(T).name()) += "_")
+                        += factory->getTypeToken()));
             }
             result = validator->finishOneOf();
         }
@@ -254,26 +247,21 @@ public:
     void addFactory(SubTypeFactory<T, S>* factory)
     {
         factories.add(new SubTypeFactoryRef<T>(
-            factory->getTypeToken(),
-            [factory](Framework::JSON::JSONObject* zJson) {
-                S* value = factory->createValue(zJson);
+            [factory]() { return factory->getTypeToken(); },
+            [factory](Framework::JSON::JSONValue* zJson) {
+                S* value = factory->fromJson(zJson);
                 if (value)
                 {
                     return dynamic_cast<T*>(value);
                 }
                 return (T*)0;
             },
-            [factory](T* zResult, Framework::JSON::JSONObject* zJson) {
-                factory->fromJson(dynamic_cast<S*>(zResult), zJson);
-            },
-            [factory](T* zObject, Framework::JSON::JSONObject* zResult) {
-                factory->toJson(dynamic_cast<S*>(zObject), zResult);
-            },
-            [factory](JSONObjectValidationBuilder* builder) {
-                return factory->addToValidator(builder);
+            [factory](T* zObject) {
+                return factory->toJson(dynamic_cast<S*>(zObject));
             },
+            [factory]() { return factory->getValidator(); },
             dynamic_cast<Framework::ReferenceCounter*>(factory)));
-        typeNames.add(new Framework::Text(typeid(S).name()));
+        typeNames.add(new Framework::Text(factory->getTypeName()));
     }
 };
 
@@ -283,31 +271,21 @@ thread_local bool PolymorphTypeFactory<T>::insideGetValidator = false;
 class TypeFatoryRef : public Framework::ReferenceCounter
 {
 private:
-    std::function<void*(Framework::JSON::JSONObject*)> createValueFunc;
-    std::function<void(void*, Framework::JSON::JSONObject*)> fromJsonFunc;
-    std::function<void(void*, Framework::JSON::JSONObject*)> toJsonFunc;
-    std::function<Framework::JSON::Validator::JSONValidator*()>
-        getValidatorFunc;
-    std::function<JSONObjectValidationBuilder*(JSONObjectValidationBuilder*)>
-        addToValidatorFunc;
+    std::function<void*(Framework::JSON::JSONValue*)> fromJsonFunc;
+    std::function<Framework::JSON::JSONValue*(void*)> toJsonFunc;
+    std::function<Framework::Validator::DataValidator*()> getValidatorFunc;
     Framework::ReferenceCounter* factory;
 
 public:
     TypeFatoryRef(
-        std::function<void*(Framework::JSON::JSONObject*)> createValueFunc,
-        std::function<void(void*, Framework::JSON::JSONObject*)> fromJsonFunc,
-        std::function<void(void*, Framework::JSON::JSONObject*)> toJsonFunc,
-        std::function<Framework::JSON::Validator::JSONValidator*()>
-            getValidatorFunc,
-        std::function<JSONObjectValidationBuilder*(
-            JSONObjectValidationBuilder*)> addToValidatorFunc,
+        std::function<void*(Framework::JSON::JSONValue*)> fromJsonFunc,
+        std::function<Framework::JSON::JSONValue*(void*)> toJsonFunc,
+        std::function<Framework::Validator::DataValidator*()> getValidatorFunc,
         Framework::ReferenceCounter* factory)
         : ReferenceCounter(),
-          createValueFunc(createValueFunc),
           fromJsonFunc(fromJsonFunc),
           toJsonFunc(toJsonFunc),
           getValidatorFunc(getValidatorFunc),
-          addToValidatorFunc(addToValidatorFunc),
           factory(factory)
     {}
 
@@ -316,35 +294,24 @@ public:
         factory->release();
     }
 
-    void* createValue(Framework::JSON::JSONObject* zJson) const
+    void* fromJson(Framework::JSON::JSONValue* zJson) const
     {
-        return createValueFunc(zJson);
+        return fromJsonFunc(zJson);
     }
 
-    void fromJson(void* zResult, Framework::JSON::JSONObject* zJson) const
+    Framework::JSON::JSONValue* toJson(void* zObject) const
     {
-        return fromJsonFunc(zResult, zJson);
+        return toJsonFunc(zObject);
     }
 
-    void toJSON(void* zObject, Framework::JSON::JSONObject* zResult) const
-    {
-        return toJsonFunc(zObject, zResult);
-    }
-
-    Framework::JSON::Validator::JSONValidator* getValidator() const
+    Framework::Validator::DataValidator* getValidator() const
     {
         return getValidatorFunc();
     }
 
-    JSONObjectValidationBuilder* addToValidator(
-        JSONObjectValidationBuilder* builder) const
+    Framework::ReferenceCounter* zFactory() const
     {
-        return addToValidatorFunc(builder);
-    }
-
-    template<typename T> TypeFactory<T>* zFactory() const
-    {
-        return (TypeFactory<T>*)(factory);
+        return factory;
     }
 };
 
@@ -375,7 +342,7 @@ public:
         }
         PolymorphTypeFactory<T>* polymorphFactory
             = dynamic_cast<PolymorphTypeFactory<T>*>(
-                typeFactoryRef->zFactory<T>());
+                typeFactoryRef->zFactory());
         if (!polymorphFactory)
         {
             Framework::Logging::error()
@@ -384,12 +351,17 @@ public:
             throw Framework::Text("Type not registered as Polymorphic type: ")
                 + typeId;
         }
-        polymorphFactory->template addFactory<S>(factory);
+        polymorphFactory->addFactory<S>(factory);
     }
 
-    template<typename T> void registerType(TypeFactory<T>* factory)
+    template<typename T> void registerType(ObjectTypeFactory<T>* factory)
+    {
+        registerType(typeid(T).name(), factory);
+    }
+
+    template<typename T>
+    void registerType(Framework::Text typeId, SimpleTypeFactory<T>* factory)
     {
-        Framework::Text typeId = typeid(T).name();
         TypeFatoryRef* typeFactoryRef
             = parsableTypes.z(typeId, typeId.getLength());
         if (typeFactoryRef)
@@ -399,27 +371,19 @@ public:
             throw Framework::Text("Type already registered: ") + typeId;
         }
         typeFactoryRef = new TypeFatoryRef(
-            [factory](Framework::JSON::JSONObject* zJson) {
-                return (void*)factory->createValue(zJson);
-            },
-            [factory](void* zResult, Framework::JSON::JSONObject* zJson) {
-                factory->fromJson((T*)zResult, zJson);
-            },
-            [factory](void* zObject, Framework::JSON::JSONObject* zResult) {
-                factory->toJson((T*)zObject, zResult);
+            [factory](Framework::JSON::JSONValue* zJson) {
+                return (void*)factory->fromJson(zJson);
             },
+            [factory](void* zObject) { return factory->toJson((T)zObject); },
             [factory]() { return factory->getValidator(); },
-            [factory](JSONObjectValidationBuilder* builder) {
-                return factory->addToValidator(builder);
-            },
             factory);
         parsableTypes.set(typeId, typeId.getLength(), typeFactoryRef);
         parsableTypeNames.add(new Framework::Text(typeId));
     }
 
-    template<typename T> T* fromJson(Framework::JSON::JSONValue* zJson) const
+    template<typename T>
+    T fromJson(Framework::Text typeId, Framework::JSON::JSONValue* zJson) const
     {
-        Framework::Text typeId = typeid(T).name();
         TypeFatoryRef* typeFactoryRef
             = parsableTypes.z(typeId, typeId.getLength());
         if (!typeFactoryRef)
@@ -428,31 +392,22 @@ public:
                 << Framework::Text("Type not registered: ") + typeId;
             throw Framework::Text("Type not registered: ") + typeId;
         }
-        T* result = (T*)(typeFactoryRef->createValue(zJson->asObject()));
-        (typeFactoryRef->fromJson(result, zJson->asObject()));
-        return result;
+        return (T)(typeFactoryRef->fromJson(zJson));
+    }
+
+    template<typename T> T* fromJson(Framework::JSON::JSONValue* zJson) const
+    {
+        return fromJson<T*>(typeid(T).name(), zJson);
     }
 
     template<typename T> Framework::JSON::JSONValue* toJson(T* zObject) const
     {
-        Framework::Text typeId = typeid(T).name();
-        TypeFatoryRef* typeFactoryRef
-            = parsableTypes.z(typeId, typeId.getLength());
-        if (!typeFactoryRef)
-        {
-            Framework::Logging::error()
-                << Framework::Text("Type not registered: ") + typeId;
-            throw Framework::Text("Type not registered: ") + typeId;
-        }
-        Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
-        typeFactoryRef->toJSON(zObject, result);
-        return result;
+        return toJson<T*>(typeid(T).name(), zObject);
     }
 
     template<typename T>
-    Framework::JSON::Validator::JSONValidator* getValidator() const
+    Framework::JSON::JSONValue* toJson(Framework::Text typeId, T zObject) const
     {
-        Framework::Text typeId = typeid(T).name();
         TypeFatoryRef* typeFactoryRef
             = parsableTypes.z(typeId, typeId.getLength());
         if (!typeFactoryRef)
@@ -461,11 +416,11 @@ public:
                 << Framework::Text("Type not registered: ") + typeId;
             throw Framework::Text("Type not registered: ") + typeId;
         }
-        return typeFactoryRef->getValidator();
+        return typeFactoryRef->toJson(zObject);
     }
 
-    template<typename T> JSONObjectValidationBuilder* addToValidator(
-        JSONObjectValidationBuilder* builder) const
+    template<typename T>
+    Framework::Validator::DataValidator* getValidator() const
     {
         Framework::Text typeId = typeid(T).name();
         TypeFatoryRef* typeFactoryRef
@@ -476,20 +431,17 @@ public:
                 << Framework::Text("Type not registered: ") + typeId;
             throw Framework::Text("Type not registered: ") + typeId;
         }
-        return typeFactoryRef->addToValidator(builder);
+        return typeFactoryRef->getValidator();
     }
 
     template<typename T> Framework::JSON::JSONValue* getValidParts(
         Framework::JSON::JSONValue* zJson) const
     {
-        Framework::RCArray<Framework::JSON::Validator::JSONValidationResult>
-            invalidParts;
-        Framework::JSON::Validator::JSONValidator* validator
-            = getValidator<T>();
+        Framework::RCArray<Framework::Validator::ValidationResult> invalidParts;
+        Framework::Validator::DataValidator* validator = getValidator<T>();
         Framework::JSON::JSONValue* result
             = validator->getValidParts(zJson, &invalidParts);
-        for (Framework::JSON::Validator::JSONValidationResult* invalidPart :
-            invalidParts)
+        for (Framework::Validator::ValidationResult* invalidPart : invalidParts)
         {
             Framework::Logging::error() << invalidPart->getInvalidInfo();
         }

+ 5 - 5
FactoryCraft/WorldGenerator.cpp

@@ -11,7 +11,7 @@
 
 using namespace Framework;
 using namespace Framework::JSON;
-using namespace Framework::JSON::Validator;
+using namespace Framework::Validator;
 
 WorldGenerator::WorldGenerator(int seed)
     : Thread(),
@@ -22,8 +22,8 @@ WorldGenerator::WorldGenerator(int seed)
     Framework::Logging::info()
         << "loading world generator configs. Changes at the config files "
            "may lead to a sudden change in landscape.";
-    JSONValidator* configValidator
-        = JSONValidator::buildForArray()
+    DataValidator* configValidator
+        = DataValidator::buildForArray()
               ->removeInvalidEntries()
               ->addAcceptedTypeInArray(Game::INSTANCE->zTypeRegistry()
                                            ->getValidator<DimensionGenerator>())
@@ -33,10 +33,10 @@ WorldGenerator::WorldGenerator(int seed)
             Framework::JSON::JSONValue* zValue, Framework::Text path) {
             Framework::Logging::info()
                 << "loading dimension configs from '" << path << "'";
-            Framework::RCArray<JSONValidationResult> invalidParts;
+            Framework::RCArray<ValidationResult> invalidParts;
             JSONValue* valid
                 = configValidator->getValidParts(zValue, &invalidParts);
-            for (JSONValidationResult* invalidPart : invalidParts)
+            for (ValidationResult* invalidPart : invalidParts)
             {
                 Framework::Logging::error() << invalidPart->getInvalidInfo();
             }

+ 1 - 0
Windows Version/Windows Version.vcxproj

@@ -116,6 +116,7 @@
       <PreprocessorDefinitions>_DEBUG;_CONSOLE;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <ConformanceMode>true</ConformanceMode>
       <LanguageStandard>stdcpp20</LanguageStandard>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
       <SubSystem>Console</SubSystem>