Procházet zdrojové kódy

add camp fire dialog and first camp fire recipie

Kolja Strohm před 4 měsíci
rodič
revize
713d107008

+ 20 - 1
FactoryCraft/BasicBlocks.cpp

@@ -33,6 +33,24 @@ bool BasicBlock::onTick(TickQueue* zQueue, int numTicks, bool& blocked)
 
 void BasicBlock::onPostTick() {}
 
+void BasicBlock::getLightEmisionColor(unsigned char* result) const
+{
+    Block::getLightEmisionColor(result);
+    for (BlockComponent* component : components)
+    {
+        int color = component->getLightColor();
+        result[0] = (unsigned char)MIN(result[0] + ((color >> 16) & 0xFF), 255);
+        result[1] = (unsigned char)MIN(result[1] + ((color >> 8) & 0xFF), 255);
+        result[2] = (unsigned char)MIN(result[2] + (color & 0xFF), 255);
+    }
+}
+
+TickSourceType BasicBlock::isTickSource() const
+{
+    return components.getEintragAnzahl() > 0 ? TickSourceType::EACH_TICK
+                                             : TickSourceType::NONE;
+}
+
 BasicBlockType::BasicBlockType()
     : BlockType(),
       itemTypeName(),
@@ -105,7 +123,8 @@ void BasicBlockType::createSuperBlock(Block* zBlock, Item* zItem) const
 Block* BasicBlockType::createBlock(
     Framework::Vec3<int> position, int dimensionId) const
 {
-    return new BasicBlock(getId(), position, dimensionId);
+    return new BasicBlock(
+        getId(), position, dimensionId, itemSlots.getEintragAnzahl() > 0);
 }
 
 Item* BasicBlockType::createItem() const

+ 2 - 0
FactoryCraft/BasicBlocks.h

@@ -25,6 +25,8 @@ public:
     virtual bool onTick(
         TickQueue* zQueue, int numTicks, bool& blocked) override;
     virtual void onPostTick() override;
+    void getLightEmisionColor(unsigned char* result) const override;
+    virtual TickSourceType isTickSource() const override;
 
     friend BasicBlockType;
 };

+ 4 - 2
FactoryCraft/Block.cpp

@@ -380,9 +380,11 @@ bool Block::isDeadAndRemoved() const
     return deadAndRemoved;
 }
 
-const unsigned char* Block::getLightEmisionColor() const
+void Block::getLightEmisionColor(unsigned char* result) const
 {
-    return lightEmisionColor;
+    result[0] = lightEmisionColor[0];
+    result[1] = lightEmisionColor[0];
+    result[2] = lightEmisionColor[0];
 }
 
 void Block::filterPassingLight(unsigned char rgb[3]) const

+ 1 - 1
FactoryCraft/Block.h

@@ -112,7 +112,7 @@ public:
     void setHP(
         Entity* zActor, Item* zUsedItem, ItemSkill* zUsedSkill, float hp);
     bool isDeadAndRemoved() const;
-    const unsigned char* getLightEmisionColor() const;
+    virtual void getLightEmisionColor(unsigned char* result) const;
     virtual void filterPassingLight(unsigned char rgb[3]) const;
     Block* zNeighbor(Direction dir) const;
     void updateModel(ModelInfo* zInfo) const;

+ 10 - 0
FactoryCraft/BlockComponent.cpp

@@ -3,3 +3,13 @@
 BlockComponent::BlockComponent()
     : Framework::ReferenceCounter()
 {}
+
+bool BlockComponent::isLightSource() const
+{
+    return 0;
+}
+
+int BlockComponent::getLightColor() const
+{
+    return 0;
+}

+ 2 - 0
FactoryCraft/BlockComponent.h

@@ -16,4 +16,6 @@ public:
     virtual Framework::XML::Element* getUIML() const = 0;
     virtual void loadComponent(Framework::StreamReader* zReader) = 0;
     virtual void saveComponent(Framework::StreamWriter* zWriter) const = 0;
+    virtual bool isLightSource() const;
+    virtual int getLightColor() const;
 };

+ 4 - 4
FactoryCraft/BlockInfoCommand.cpp

@@ -57,6 +57,8 @@ bool BlockInfoCommand::execute(
         else
         {
             Block* zBlock = block.getA();
+            unsigned char lightColor[3];
+            zBlock->getLightEmisionColor(lightColor);
             result.append()
                 << "Block instance found.\n"
                 << "  Block Type: " << zBlock->zBlockType()->getName() << " ("
@@ -69,10 +71,8 @@ bool BlockInfoCommand::execute(
                 << "  Tick source: " << zBlock->isTickSource() << "\n"
                 << "  Interactable by hand: " << zBlock->isInteractable(0)
                 << "\n"
-                << "  Light emission: ("
-                << (int)zBlock->getLightEmisionColor()[0] << ", "
-                << (int)zBlock->getLightEmisionColor()[1] << ", "
-                << (int)zBlock->getLightEmisionColor()[2] << ")\n";
+                << "  Light emission: (" << (int)lightColor[0] << ", "
+                << (int)lightColor[1] << ", " << (int)lightColor[2] << ")\n";
         }
         result += "  Light data: ";
         Chunk* zChunk = Game::INSTANCE->zDimension(dimension)->zChunk(

+ 1 - 1
FactoryCraft/BlockType.h

@@ -56,7 +56,7 @@ protected:
 
 public:
     virtual bool initialize(Game* zGame);
-    BlockType* initializeDefault();
+    virtual BlockType* initializeDefault();
     void addDropConfig(DropConfig* config);
     const Framework::RCArray<DropConfig>& getDropConfigs() const;
     virtual const Block* zDefault() const;

+ 3 - 2
FactoryCraft/Dimension.cpp

@@ -154,6 +154,7 @@ void Dimension::thread()
     double time = 0;
     bool isForeground = 0;
     Framework::Array<Framework::Vec3<int>> internalLightUpdateQueue;
+    unsigned char tmp[3];
     while (!stop)
     {
         Vec3<int> position;
@@ -261,9 +262,9 @@ void Dimension::thread()
                 }
                 const Block* current = zBlockOrDefault(position);
                 // add own light emission
+                current->getLightEmisionColor(tmp);
                 for (int j = 3; j < 6; j++)
-                    newLight[j] = (unsigned char)MAX(
-                        newLight[j], current->getLightEmisionColor()[j - 3]);
+                    newLight[j] = (unsigned char)MAX(newLight[j], tmp[j - 3]);
                 current->filterPassingLight(newLight);
                 current->filterPassingLight(newLight + 3);
                 for (int i = 0; i < 6; i++)

+ 4 - 0
FactoryCraft/FactoryCraft.vcxproj

@@ -211,9 +211,11 @@
     <ClInclude Include="TypeRegistry.h" />
     <ClInclude Include="UIController.h" />
     <ClInclude Include="UICraftingGrid.h" />
+    <ClInclude Include="UICraftingProgress.h" />
     <ClInclude Include="UIDialog.h" />
     <ClInclude Include="UIDialogElement.h" />
     <ClInclude Include="UIElement.h" />
+    <ClInclude Include="UIFuelState.h" />
     <ClInclude Include="UIInventory.h" />
     <ClInclude Include="UIReference.h" />
     <ClInclude Include="UIText.h" />
@@ -333,9 +335,11 @@
     <ClCompile Include="TypeRegistry.cpp" />
     <ClCompile Include="UIController.cpp" />
     <ClCompile Include="UICraftingGrid.cpp" />
+    <ClCompile Include="UICraftingProgress.cpp" />
     <ClCompile Include="UIDialog.cpp" />
     <ClCompile Include="UIDialogElement.cpp" />
     <ClCompile Include="UIElement.cpp" />
+    <ClCompile Include="UIFuelState.cpp" />
     <ClCompile Include="UIInventory.cpp" />
     <ClCompile Include="UIReference.cpp" />
     <ClCompile Include="UIText.cpp" />

+ 12 - 0
FactoryCraft/FactoryCraft.vcxproj.filters

@@ -498,6 +498,12 @@
     <ClInclude Include="FireBasedProcessingBlockComponent.h">
       <Filter>world\blocks\components</Filter>
     </ClInclude>
+    <ClInclude Include="UICraftingProgress.h">
+      <Filter>UI\UIElements</Filter>
+    </ClInclude>
+    <ClInclude Include="UIFuelState.h">
+      <Filter>UI\UIElements</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Server.cpp">
@@ -860,5 +866,11 @@
     <ClCompile Include="FireBasedProcessingBlockComponent.cpp">
       <Filter>world\blocks\components</Filter>
     </ClCompile>
+    <ClCompile Include="UICraftingProgress.cpp">
+      <Filter>UI\UIElements</Filter>
+    </ClCompile>
+    <ClCompile Include="UIFuelState.cpp">
+      <Filter>UI\UIElements</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 29 - 10
FactoryCraft/FireBasedProcessingBlockComponent.cpp

@@ -287,6 +287,16 @@ void FireBasedProcessingBlockComponent::saveComponent(
     zWriter->schreibe((char*)&index, 4);
 }
 
+bool FireBasedProcessingBlockComponent::isLightSource() const
+{
+    return 1;
+}
+
+int FireBasedProcessingBlockComponent::getLightColor() const
+{
+    return burning ? burnLight : 0;
+}
+
 FireBasedProcessingBlockComponentFactory::
     FireBasedProcessingBlockComponentFactory()
     : SubTypeFactory()
@@ -330,6 +340,8 @@ FireBasedProcessingBlockComponentFactory::fromJson(
         = zJson->zValue("inputInventorySlotName")->asString()->getString();
     component->outputInventorySlotName
         = zJson->zValue("outputInventorySlotName")->asString()->getString();
+    component->burnLight
+        = (int)zJson->zValue("lightColor")->asString()->getString();
     return component;
 }
 
@@ -357,6 +369,9 @@ FireBasedProcessingBlockComponentFactory::toJsonObject(
     result->addValue("outputInventorySlotName",
         new Framework::JSON::JSONString(
             zObject->outputInventorySlotName.getText()));
+    Framework::Text color = "0x";
+    color.appendHex(zObject->burnLight);
+    result->addValue("lightColor", new Framework::JSON::JSONString(color));
     return result;
 }
 
@@ -369,16 +384,20 @@ FireBasedProcessingBlockComponentFactory::addToValidator(
             Game::INSTANCE->zTypeRegistry()->getValidator<ItemFilter>())
         ->withRequiredAttribute("fuelItemFilter",
             Game::INSTANCE->zTypeRegistry()->getValidator<ItemFilter>())
-        ->withRequiredAttribute("recipieGroup",
-            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>())
-        ->withRequiredAttribute("fuelInventorySlotName",
-            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>())
-        ->withRequiredAttribute("fireStartingInventorySlotName",
-            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>())
-        ->withRequiredAttribute("inputInventorySlotName",
-            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>())
-        ->withRequiredAttribute("outputInventorySlotName",
-            Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>());
+        ->withRequiredString("recipieGroup")
+        ->finishString()
+        ->withRequiredString("fuelInventorySlotName")
+        ->finishString()
+        ->withRequiredString("fireStartingInventorySlotName")
+        ->finishString()
+        ->withRequiredString("inputInventorySlotName")
+        ->finishString()
+        ->withRequiredString("outputInventorySlotName")
+        ->finishString()
+        ->withRequiredString("lightColor")
+        ->whichStartsWithMatch("0x")
+        ->withDefault("0x0")
+        ->finishString();
     return builder;
 }
 

+ 3 - 0
FactoryCraft/FireBasedProcessingBlockComponent.h

@@ -18,6 +18,7 @@ private:
     Framework::Text fireStartingInventorySlotName;
     Framework::Text inputInventorySlotName;
     Framework::Text outputInventorySlotName;
+    int burnLight;
     int ticksNeeded;
     Recipie* currentRecipie;
     int fuelBuffer;
@@ -44,6 +45,8 @@ public:
     virtual int getStorageDimensionId() const override;
     virtual void loadComponent(Framework::StreamReader* zReader) override;
     virtual void saveComponent(Framework::StreamWriter* zWriter) const override;
+    virtual bool isLightSource() const override;
+    virtual int getLightColor() const override;
 
     friend class FireBasedProcessingBlockComponentFactory;
 };

+ 2 - 2
FactoryCraft/Recipie.cpp

@@ -658,7 +658,7 @@ Framework::JSON::JSONObject* MachineRecipieFactory::toJsonObject(
         = UnshapedRecipieFactory::toJsonObject(zObject);
     result->addValue("ticksNeeded",
         new Framework::JSON::JSONNumber(zObject->getTicksNeeded()));
-    result->addValue("fuelNeeded",
+    result->addValue("fuelPerTickNeeded",
         new Framework::JSON::JSONNumber(zObject->getFuelPerTickNeeded()));
     return result;
 }
@@ -671,7 +671,7 @@ JSONObjectValidationBuilder* MachineRecipieFactory::addToValidator(
         ->whichIsGreaterOrEqual(1.0)
         ->withDefault(1.0)
         ->finishNumber()
-        ->withRequiredNumber("fuelNeeded")
+        ->withRequiredNumber("fuelPerTickNeeded")
         ->whichIsGreaterOrEqual(0.0)
         ->withDefault(0.0)
         ->finishNumber();

+ 6 - 0
FactoryCraft/TypeRegistry.cpp

@@ -36,7 +36,9 @@
 #include "TreeSeblingBlock.h"
 #include "TreeTemplate.h"
 #include "UICraftingGrid.h"
+#include "UICraftingProgress.h"
 #include "UIDialogElement.h"
+#include "UIFuelState.h"
 #include "UIInventory.h"
 #include "UIReference.h"
 #include "UIText.h"
@@ -101,6 +103,7 @@ TypeRegistry::TypeRegistry()
     registerType(new RecipieOutputFactory());
     registerSubType(new ShapedRecipieFactory());
     registerSubType(new UnshapedRecipieFactory<UnshapedRecipie>());
+    registerSubType(new MachineRecipieFactory());
 
     // item modifiers
     registerSubType(new ConsumeItemModifierFactory());
@@ -157,11 +160,14 @@ TypeRegistry::TypeRegistry()
 
     // UI Elements
     registerSubType(new UITargetReferenceFactory());
+    registerSubType(new UITargetComponentReferenceFactory());
     registerSubType(new UITActorReferenceFactory());
     registerSubType(new UITextElementFactory());
     registerSubType(new UIInventoryElementFactory());
     registerSubType(new UIDialogElementFactory());
     registerSubType(new UICraftingGridElementFactory());
+    registerSubType(new UICraftingProgressFactory());
+    registerSubType(new UIFuelStateFactory());
 
     // interactions
     registerSubType(new OpenDialogInteractionConfigFactory());

+ 135 - 0
FactoryCraft/UICraftingProgress.cpp

@@ -0,0 +1,135 @@
+#include "UICraftingProgress.h"
+
+#include "UIReference.h"
+
+UICraftingProgress::UICraftingProgress()
+    : UIElement(),
+      reference(0)
+{}
+
+UICraftingProgress::~UICraftingProgress()
+{
+    if (reference)
+    {
+        reference->release();
+    }
+}
+
+void UICraftingProgress::setReference(UIReference* reference)
+{
+    if (this->reference)
+    {
+        this->reference->release();
+    }
+    this->reference = reference;
+}
+
+UIReference* UICraftingProgress::zReference() const
+{
+    return reference;
+}
+
+void UICraftingProgress::setBackgroundImagePath(
+    const Framework::Text& backgroundImagePath)
+{
+    this->backgroundImagePath = backgroundImagePath;
+}
+
+const Framework::Text& UICraftingProgress::getBackgroundImagePath() const
+{
+    return backgroundImagePath;
+}
+
+void UICraftingProgress::setForegroundImagePath(
+    const Framework::Text& foregroundImagePath)
+{
+    this->foregroundImagePath = foregroundImagePath;
+}
+
+const Framework::Text& UICraftingProgress::getForegroundImagePath() const
+{
+    return foregroundImagePath;
+}
+
+void UICraftingProgress::setDirection(const Framework::Text& direction)
+{
+    this->direction = direction;
+}
+
+const Framework::Text& UICraftingProgress::getDirection() const
+{
+    return direction;
+}
+
+Framework::XML::Element* UICraftingProgress::toUIML(
+    Framework::Either<Block*, Entity*> zTarget, Entity* zActor) const
+{
+    Framework::XML::Element* element = UIElement::toUIML(zTarget, zActor);
+    element->setName("craftingProgress");
+    element->setAttribute("target", reference->getReferenceId(zTarget, zActor));
+    element->setAttribute("backgroundImagePath", backgroundImagePath);
+    element->setAttribute("foregroundImagePath", foregroundImagePath);
+    element->setAttribute("direction", direction);
+    return element;
+}
+
+UICraftingProgressFactory::UICraftingProgressFactory()
+    : UIElementFactory()
+{}
+
+JSONObjectValidationBuilder* UICraftingProgressFactory::addToValidator(
+    JSONObjectValidationBuilder* builder) const
+{
+    return UIElementFactory::addToValidator(builder)
+        ->withRequiredAttribute("reference",
+            Game::INSTANCE->zTypeRegistry()->getValidator<UIReference>())
+        ->withRequiredString("backgroundImagePath")
+        ->finishString()
+        ->withRequiredString("foregroundImagePath")
+        ->finishString()
+        ->withRequiredString("direction")
+        ->whichIsOneOf({"TOP", "LEFT", "BOTTOM", "RIGHT"})
+        ->finishString();
+}
+
+UICraftingProgress* UICraftingProgressFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
+{
+    UICraftingProgress* result = UIElementFactory::fromJson(zJson);
+    result->setReference(Game::INSTANCE->zTypeRegistry()->fromJson<UIReference>(
+        zJson->zValue("reference")));
+    result->setBackgroundImagePath(
+        zJson->zValue("backgroundImagePath")->asString()->getString());
+    result->setForegroundImagePath(
+        zJson->zValue("foregroundImagePath")->asString()->getString());
+    result->setDirection(zJson->zValue("direction")->asString()->getString());
+
+    return result;
+}
+
+Framework::JSON::JSONObject* UICraftingProgressFactory::toJsonObject(
+    UICraftingProgress* zObject) const
+{
+    Framework::JSON::JSONObject* result
+        = UIElementFactory::toJsonObject(zObject);
+    result->addValue("reference",
+        Game::INSTANCE->zTypeRegistry()->toJson(zObject->zReference()));
+    result->addValue("backgroundImagePath",
+        new Framework::JSON::JSONString(zObject->getBackgroundImagePath()));
+    result->addValue("foregroundImagePath",
+        new Framework::JSON::JSONString(zObject->getForegroundImagePath()));
+    result->addValue(
+        "direction", new Framework::JSON::JSONString(zObject->getDirection()));
+    return result;
+}
+
+UICraftingProgress* UICraftingProgressFactory::createElement(
+    Framework::JSON::JSONObject* zJson) const
+{
+    return new UICraftingProgress();
+}
+
+const char* UICraftingProgressFactory::getTypeToken() const
+{
+    return "craftingProgress";
+}

+ 44 - 0
FactoryCraft/UICraftingProgress.h

@@ -0,0 +1,44 @@
+#pragma once
+
+#include "UIElement.h"
+
+class UIReference;
+
+class UICraftingProgress : public UIElement
+{
+private:
+    UIReference* reference;
+    Framework::Text backgroundImagePath;
+    Framework::Text foregroundImagePath;
+    Framework::Text direction;
+
+public:
+    UICraftingProgress();
+    ~UICraftingProgress();
+    void setReference(UIReference* reference);
+    UIReference* zReference() const;
+    void setBackgroundImagePath(const Framework::Text& backgroundImagePath);
+    const Framework::Text& getBackgroundImagePath() const;
+    void setForegroundImagePath(const Framework::Text& foregroundImagePath);
+    const Framework::Text& getForegroundImagePath() const;
+    void setDirection(const Framework::Text& direction);
+    const Framework::Text& getDirection() const;
+    virtual Framework::XML::Element* toUIML(
+        Framework::Either<Block*, Entity*> zTarget,
+        Entity* zActor) const override;
+};
+
+class UICraftingProgressFactory : public UIElementFactory<UICraftingProgress>
+{
+public:
+    UICraftingProgressFactory();
+    JSONObjectValidationBuilder* addToValidator(
+        JSONObjectValidationBuilder* builder) const override;
+    UICraftingProgress* fromJson(
+        Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        UICraftingProgress* zObject) const override;
+    UICraftingProgress* createElement(
+        Framework::JSON::JSONObject* zJson) const override;
+    const char* getTypeToken() const override;
+};

+ 135 - 0
FactoryCraft/UIFuelState.cpp

@@ -0,0 +1,135 @@
+#include "UIFuelState.h"
+
+#include "UIReference.h"
+
+UIFuelState::UIFuelState()
+    : UIElement(),
+      reference(0)
+{}
+
+UIFuelState::~UIFuelState()
+{
+    if (reference)
+    {
+        reference->release();
+    }
+}
+
+void UIFuelState::setReference(UIReference* reference)
+{
+    if (this->reference)
+    {
+        this->reference->release();
+    }
+    this->reference = reference;
+}
+
+UIReference* UIFuelState::zReference() const
+{
+    return reference;
+}
+
+void UIFuelState::setBackgroundImagePath(
+    const Framework::Text& backgroundImagePath)
+{
+    this->backgroundImagePath = backgroundImagePath;
+}
+
+const Framework::Text& UIFuelState::getBackgroundImagePath() const
+{
+    return backgroundImagePath;
+}
+
+void UIFuelState::setForegroundImagePath(
+    const Framework::Text& foregroundImagePath)
+{
+    this->foregroundImagePath = foregroundImagePath;
+}
+
+const Framework::Text& UIFuelState::getForegroundImagePath() const
+{
+    return foregroundImagePath;
+}
+
+void UIFuelState::setDirection(const Framework::Text& direction)
+{
+    this->direction = direction;
+}
+
+const Framework::Text& UIFuelState::getDirection() const
+{
+    return direction;
+}
+
+Framework::XML::Element* UIFuelState::toUIML(
+    Framework::Either<Block*, Entity*> zTarget, Entity* zActor) const
+{
+    Framework::XML::Element* element = UIElement::toUIML(zTarget, zActor);
+    element->setName("fuelState");
+    element->setAttribute("target", reference->getReferenceId(zTarget, zActor));
+    element->setAttribute("backgroundImagePath", backgroundImagePath);
+    element->setAttribute("foregroundImagePath", foregroundImagePath);
+    element->setAttribute("direction", direction);
+    return element;
+}
+
+UIFuelStateFactory::UIFuelStateFactory()
+    : UIElementFactory()
+{}
+
+JSONObjectValidationBuilder* UIFuelStateFactory::addToValidator(
+    JSONObjectValidationBuilder* builder) const
+{
+    return UIElementFactory::addToValidator(builder)
+        ->withRequiredAttribute("reference",
+            Game::INSTANCE->zTypeRegistry()->getValidator<UIReference>())
+        ->withRequiredString("backgroundImagePath")
+        ->finishString()
+        ->withRequiredString("foregroundImagePath")
+        ->finishString()
+        ->withRequiredString("direction")
+        ->whichIsOneOf({"TOP", "LEFT", "BOTTOM", "RIGHT"})
+        ->finishString();
+}
+
+UIFuelState* UIFuelStateFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
+{
+    UIFuelState* result = UIElementFactory::fromJson(zJson);
+    result->setReference(Game::INSTANCE->zTypeRegistry()->fromJson<UIReference>(
+        zJson->zValue("reference")));
+    result->setBackgroundImagePath(
+        zJson->zValue("backgroundImagePath")->asString()->getString());
+    result->setForegroundImagePath(
+        zJson->zValue("foregroundImagePath")->asString()->getString());
+    result->setDirection(zJson->zValue("direction")->asString()->getString());
+
+    return result;
+}
+
+Framework::JSON::JSONObject* UIFuelStateFactory::toJsonObject(
+    UIFuelState* zObject) const
+{
+    Framework::JSON::JSONObject* result
+        = UIElementFactory::toJsonObject(zObject);
+    result->addValue("reference",
+        Game::INSTANCE->zTypeRegistry()->toJson(zObject->zReference()));
+    result->addValue("backgroundImagePath",
+        new Framework::JSON::JSONString(zObject->getBackgroundImagePath()));
+    result->addValue("foregroundImagePath",
+        new Framework::JSON::JSONString(zObject->getForegroundImagePath()));
+    result->addValue(
+        "direction", new Framework::JSON::JSONString(zObject->getDirection()));
+    return result;
+}
+
+UIFuelState* UIFuelStateFactory::createElement(
+    Framework::JSON::JSONObject* zJson) const
+{
+    return new UIFuelState();
+}
+
+const char* UIFuelStateFactory::getTypeToken() const
+{
+    return "fuelState";
+}

+ 43 - 0
FactoryCraft/UIFuelState.h

@@ -0,0 +1,43 @@
+#pragma once
+
+#include "UIElement.h"
+
+class UIReference;
+
+class UIFuelState : public UIElement
+{
+private:
+    UIReference* reference;
+    Framework::Text backgroundImagePath;
+    Framework::Text foregroundImagePath;
+    Framework::Text direction;
+
+public:
+    UIFuelState();
+    ~UIFuelState();
+    void setReference(UIReference* reference);
+    UIReference* zReference() const;
+    void setBackgroundImagePath(const Framework::Text& backgroundImagePath);
+    const Framework::Text& getBackgroundImagePath() const;
+    void setForegroundImagePath(const Framework::Text& foregroundImagePath);
+    const Framework::Text& getForegroundImagePath() const;
+    void setDirection(const Framework::Text& direction);
+    const Framework::Text& getDirection() const;
+    virtual Framework::XML::Element* toUIML(
+        Framework::Either<Block*, Entity*> zTarget,
+        Entity* zActor) const override;
+};
+
+class UIFuelStateFactory : public UIElementFactory<UIFuelState>
+{
+public:
+    UIFuelStateFactory();
+    JSONObjectValidationBuilder* addToValidator(
+        JSONObjectValidationBuilder* builder) const override;
+    UIFuelState* fromJson(Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        UIFuelState* zObject) const override;
+    UIFuelState* createElement(
+        Framework::JSON::JSONObject* zJson) const override;
+    const char* getTypeToken() const override;
+};

+ 1 - 0
FactoryCraft/UIInventory.cpp

@@ -1,5 +1,6 @@
 #include "UIInventory.h"
 
+#include "UICraftingProgress.h"
 #include "UIReference.h"
 
 UIInventoryElement::UIInventoryElement()

+ 59 - 0
FactoryCraft/UIReference.cpp

@@ -29,6 +29,30 @@ Framework::Text UITargetReference::getReferenceId(
     return result;
 }
 
+UITargetComponentReference::UITargetComponentReference()
+    : UIReference(),
+      componentIndex(0)
+{}
+
+Framework::Text UITargetComponentReference::getReferenceId(
+    Framework::Either<Block*, Entity*> zTarget, Entity* zActor) const
+{
+    Framework::Text result("");
+    if (zTarget.isA())
+    {
+        result.append() << zTarget.getA()->getDimensionId() << ","
+                        << zTarget.getA()->getPos().x << ","
+                        << zTarget.getA()->getPos().y << ","
+                        << zTarget.getA()->getPos().z;
+    }
+    else
+    {
+        result.append() << zTarget.getB()->getId();
+    }
+    result.append() << ":" << componentIndex;
+    return result;
+}
+
 UITActorReference::UITActorReference()
     : UIReference()
 {}
@@ -91,4 +115,39 @@ Framework::JSON::JSONObject* UITActorReferenceFactory::toJsonObject(
 const char* UITActorReferenceFactory::getTypeToken() const
 {
     return "actor";
+}
+
+UITargetComponentReferenceFactory::UITargetComponentReferenceFactory()
+    : SubTypeFactory<UIReference, UITargetComponentReference>()
+{}
+
+JSONObjectValidationBuilder* UITargetComponentReferenceFactory::addToValidator(
+    JSONObjectValidationBuilder* builder) const
+{
+    return builder->withRequiredNumber("componentIndex")
+        ->whichIsGreaterOrEqual(0)
+        ->finishNumber();
+}
+
+UITargetComponentReference* UITargetComponentReferenceFactory::fromJson(
+    Framework::JSON::JSONObject* zJson) const
+{
+    UITargetComponentReference* result = new UITargetComponentReference();
+    result->componentIndex
+        = (int)zJson->zValue("componentIndex")->asNumber()->getNumber();
+    return result;
+}
+
+Framework::JSON::JSONObject* UITargetComponentReferenceFactory::toJsonObject(
+    UITargetComponentReference* zObject) const
+{
+    Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject();
+    result->addValue("componentIndex",
+        new Framework::JSON::JSONNumber(zObject->componentIndex));
+    return result;
+}
+
+const char* UITargetComponentReferenceFactory::getTypeToken() const
+{
+    return "targetComponent";
 }

+ 29 - 1
FactoryCraft/UIReference.h

@@ -27,6 +27,20 @@ public:
         Entity* zActor) const override;
 };
 
+class UITargetComponentReference : public UIReference
+{
+private:
+    int componentIndex;
+
+public:
+    UITargetComponentReference();
+    virtual Framework::Text getReferenceId(
+        Framework::Either<Block*, Entity*> zTarget,
+        Entity* zActor) const override;
+
+    friend class UITargetComponentReferenceFactory;
+};
+
 class UITActorReference : public UIReference
 {
 public:
@@ -62,4 +76,18 @@ public:
     Framework::JSON::JSONObject* toJsonObject(
         UITActorReference* zObject) const override;
     const char* getTypeToken() const override;
-};
+};
+
+class UITargetComponentReferenceFactory
+    : public SubTypeFactory<UIReference, UITargetComponentReference>
+{
+public:
+    UITargetComponentReferenceFactory();
+    virtual JSONObjectValidationBuilder* addToValidator(
+        JSONObjectValidationBuilder* builder) const override;
+    UITargetComponentReference* fromJson(
+        Framework::JSON::JSONObject* zJson) const override;
+    Framework::JSON::JSONObject* toJsonObject(
+        UITargetComponentReference* zObject) const override;
+    const char* getTypeToken() const override;
+};

+ 4 - 0
Windows Version/Windows Version.vcxproj

@@ -270,9 +270,11 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     </ClCompile>
     <ClCompile Include="..\FactoryCraft\UIController.cpp" />
     <ClCompile Include="..\FactoryCraft\UICraftingGrid.cpp" />
+    <ClCompile Include="..\FactoryCraft\UICraftingProgress.cpp" />
     <ClCompile Include="..\FactoryCraft\UIDialog.cpp" />
     <ClCompile Include="..\FactoryCraft\UIDialogElement.cpp" />
     <ClCompile Include="..\FactoryCraft\UIElement.cpp" />
+    <ClCompile Include="..\FactoryCraft\UIFuelState.cpp" />
     <ClCompile Include="..\FactoryCraft\UIInventory.cpp" />
     <ClCompile Include="..\FactoryCraft\UIReference.cpp" />
     <ClCompile Include="..\FactoryCraft\UIText.cpp" />
@@ -397,9 +399,11 @@ copy ..\..\..\..\..\Allgemein\Framework\x64\release\Framework.dll Framework.dll<
     <ClInclude Include="..\FactoryCraft\TypeRegistry.h" />
     <ClInclude Include="..\FactoryCraft\UIController.h" />
     <ClInclude Include="..\FactoryCraft\UICraftingGrid.h" />
+    <ClInclude Include="..\FactoryCraft\UICraftingProgress.h" />
     <ClInclude Include="..\FactoryCraft\UIDialog.h" />
     <ClInclude Include="..\FactoryCraft\UIDialogElement.h" />
     <ClInclude Include="..\FactoryCraft\UIElement.h" />
+    <ClInclude Include="..\FactoryCraft\UIFuelState.h" />
     <ClInclude Include="..\FactoryCraft\UIInventory.h" />
     <ClInclude Include="..\FactoryCraft\UIReference.h" />
     <ClInclude Include="..\FactoryCraft\UIText.h" />

+ 12 - 0
Windows Version/Windows Version.vcxproj.filters

@@ -483,6 +483,12 @@
     <ClCompile Include="..\FactoryCraft\FireBasedProcessingBlockComponent.cpp">
       <Filter>world\blocks\components</Filter>
     </ClCompile>
+    <ClCompile Include="..\FactoryCraft\UICraftingProgress.cpp">
+      <Filter>UI\UIElements</Filter>
+    </ClCompile>
+    <ClCompile Include="..\FactoryCraft\UIFuelState.cpp">
+      <Filter>UI\UIElements</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\FactoryCraft\Chunk.h">
@@ -860,5 +866,11 @@
     <ClInclude Include="..\FactoryCraft\FireBasedProcessingBlockComponent.h">
       <Filter>world\blocks\components</Filter>
     </ClInclude>
+    <ClInclude Include="..\FactoryCraft\UICraftingProgress.h">
+      <Filter>UI\UIElements</Filter>
+    </ClInclude>
+    <ClInclude Include="..\FactoryCraft\UIFuelState.h">
+      <Filter>UI\UIElements</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>

+ 233 - 3
Windows Version/data/blocks/blockTypes.json

@@ -1284,7 +1284,7 @@
     ]
   },
   {
-    "type": "lightSource",
+    "type": "basicBlock",
     "name": "Campfire",
     "itemType": "Campfire",
     "model": {
@@ -1294,8 +1294,238 @@
       ]
     },
     "mapColor": "0xFFE25822",
-    "lightColor": "0x00E25822",
-    "lightSource": true
+    "components": [
+      {
+        "type": "fireBasedProcessing",
+        "fireStartingInventorySlotName": "fireStart",
+        "fuelInventorySlotName": "fuel",
+        "inputInventorySlotName": "input",
+        "outputInventorySlotName": "output",
+        "recipieGroup": "fire",
+        "fuelItemFilter": {
+          "type": "type",
+          "itemType": "Wooden Stick"
+        },
+        "fireStartingItemFilter": {
+          "type": "type",
+          "itemType": "Tree bark"
+        },
+        "lightColor": "0x00E25822"
+      }
+    ],
+    "inventorySlots": [
+      {
+        "category": "input",
+        "allowedPullSides": [],
+        "allowedPushSides": [
+          "BOTTOM",
+          "EAST",
+          "NORTH",
+          "SOUTH",
+          "TOP",
+          "WEST"
+        ],
+        "maxSize": 50,
+        "pushPriority": 1
+      },
+      {
+        "category": "fuel",
+        "allowedPullSides": [],
+        "allowedPushSides": [
+          "BOTTOM",
+          "EAST",
+          "NORTH",
+          "SOUTH",
+          "TOP",
+          "WEST"
+        ],
+        "maxSize": 50,
+        "pushPriority": 2
+      },
+      {
+        "category": "fireStart",
+        "allowedPullSides": [],
+        "allowedPushSides": [
+          "BOTTOM",
+          "EAST",
+          "NORTH",
+          "SOUTH",
+          "TOP",
+          "WEST"
+        ],
+        "maxSize": 50,
+        "pushPriority": 3
+      },
+      {
+        "category": "output",
+        "allowedPullSides": [
+          "BOTTOM",
+          "EAST",
+          "NORTH",
+          "SOUTH",
+          "TOP",
+          "WEST"
+        ],
+        "allowedPushSides": [],
+        "maxSize": 50,
+        "pullPriority": 1
+      }
+    ],
+    "lightSource": true,
+    "interactions": [
+      {
+        "type": "OpenDialogInteractionConfig",
+        "dialogElement": {
+          "type": "dialog",
+          "title": "Camp Fire",
+          "id": "fireDialog",
+          "width": 610,
+          "height": 480,
+          "children": [
+            {
+              "type": "inventory",
+              "id": "input",
+              "marginBottom": 10,
+              "alignBottom": "fuel_state",
+              "alignLeft": "start_input",
+              "marginLeft": 10,
+              "width": 52,
+              "height": 52,
+              "rowSize": 1,
+              "numSlots": 1,
+              "slotNameFilter": "input",
+              "reference": {
+                "type": "target"
+              }
+            },
+            {
+              "type": "craftingProgress",
+              "id": "crafting_progres",
+              "marginBottom": 10,
+              "alignBottom": "fuel_state",
+              "alignLeft": "input",
+              "marginLeft": 10,
+              "width": 50,
+              "height": 50,
+              "backgroundImagePath": "data/images/gui_icons.ltdb/craftingbg.png",
+              "foregroundImagePath": "data/images/gui_icons.ltdb/crafting.png",
+              "direction": "RIGHT",
+              "reference": {
+                "type": "targetComponent",
+                "componentIndex": 0
+              }
+            },
+            {
+              "type": "inventory",
+              "id": "output",
+              "marginBottom": 10,
+              "alignBottom": "fuel_state",
+              "alignLeft": "crafting_progres",
+              "marginLeft": 10,
+              "width": 52,
+              "height": 52,
+              "rowSize": 1,
+              "numSlots": 1,
+              "slotNameFilter": "output",
+              "reference": {
+                "type": "target"
+              }
+            },
+            {
+              "type": "fuelState",
+              "id": "fuel_state",
+              "marginBottom": 10,
+              "alignBottom": "fuel",
+              "alignLeft": "start_input",
+              "marginLeft": 10,
+              "width": 50,
+              "height": 50,
+              "backgroundImagePath": "data/images/gui_icons.ltdb/flamebg.png",
+              "foregroundImagePath": "data/images/gui_icons.ltdb/flame.png",
+              "direction": "TOP",
+              "reference": {
+                "type": "targetComponent",
+                "componentIndex": 0
+              }
+            },
+            {
+              "type": "inventory",
+              "id": "start_input",
+              "marginBottom": 18,
+              "alignBottom": "player_label",
+              "alignLeft": "start",
+              "marginLeft": 9,
+              "width": 52,
+              "height": 52,
+              "rowSize": 1,
+              "numSlots": 1,
+              "slotNameFilter": "fireStart",
+              "reference": {
+                "type": "target"
+              }
+            },
+            {
+              "type": "inventory",
+              "id": "fuel_input",
+              "marginBottom": 18,
+              "alignBottom": "player_label",
+              "alignLeft": "start_input",
+              "marginLeft": 9,
+              "width": 52,
+              "height": 52,
+              "rowSize": 1,
+              "numSlots": 1,
+              "slotNameFilter": "fuel",
+              "reference": {
+                "type": "target"
+              }
+            },
+            {
+              "type": "text",
+              "id": "player_label",
+              "width": "100%",
+              "height": "auto",
+              "style": "7003",
+              "marginBottom": 9,
+              "alignBottom": "player_inventory",
+              "text": "Player Inventory"
+            },
+            {
+              "type": "inventory",
+              "id": "player_inventory",
+              "marginBottom": 18,
+              "alignBottom": "item_bar",
+              "alignLeft": "start",
+              "marginLeft": 9,
+              "width": 592,
+              "height": 172,
+              "rowSize": 10,
+              "numSlots": 30,
+              "slotNameFilter": "Inventory",
+              "reference": {
+                "type": "actor"
+              }
+            },
+            {
+              "type": "inventory",
+              "id": "item_bar",
+              "marginBottom": 9,
+              "alignBottom": "end",
+              "alignLeft": "start",
+              "marginLeft": 9,
+              "width": 592,
+              "height": 52,
+              "rowSize": 10,
+              "numSlots": 10,
+              "slotNameFilter": "ItemBar",
+              "reference": {
+                "type": "actor"
+              }
+            }
+          ]
+        }
+      }
+    ]
   },
   {
     "type": "basicBlock",

+ 18 - 0
Windows Version/data/items/itemTypes.json

@@ -257,5 +257,23 @@
       ]
     },
     "itemName": "Stone"
+  },
+  {
+    "type": "basic",
+    "name": "Glue",
+    "model": {
+      "modelPath": "cube",
+      "texturePaths": [
+        "items.ltdb/glue.png",
+        "items.ltdb/glue.png",
+        "items.ltdb/glue.png",
+        "items.ltdb/glue.png",
+        "items.ltdb/glue.png",
+        "items.ltdb/glue.png"
+      ]
+    },
+    "itemName": "Glue",
+    "hp": 1,
+    "durability": 10
   }
 ]

+ 23 - 0
Windows Version/data/recipies/fire.json

@@ -0,0 +1,23 @@
+[
+    {
+        "type": "machine",
+        "group": "fire",
+        "fuelPerTickNeeded": 1,
+        "ticksNeeded": 60,
+        "inputs": [
+            {
+                "amount": 1,
+                "filter": {
+                    "type": "type",
+                    "itemType": "Resin"
+                }
+            }
+        ],
+        "outputs": [
+            {
+                "amount": 1,
+                "itemType": "Glue"
+            }
+        ]
+    }
+]