#pragma once #include "Block.h" class GrowingPlantBlockType; struct GrowthState : public Framework::ReferenceCounter { private: float percentage; ModelInfo* model; public: GrowthState(float percentage, ModelInfo* model); ~GrowthState(); float getPercentage() const; ModelInfo* zModel() const; }; class GrowingPlantBlock : public Block { private: float seblingTicks; int seblingTicksMax; Framework::Text name; Framework::RCArray states; int blockTypeAfterGrowth; bool plantSpawned; int lastSendState; public: GrowingPlantBlock(int typeId, Framework::Vec3 pos, int dimensionId, int maxTicks, Framework::Text name, int blockTypeAfterGrowth); virtual bool onTick( TickQueue* zQueue, int numTicks, bool& blocked) override; virtual void onPostTick() override; virtual void sendModelInfo(NetworkMessage* zMessage) override; virtual Framework::Text getTargetUIML(); GrowingPlantBlock* addGrowthState(GrowthState* state); friend GrowingPlantBlockType; }; class GrowingPlantBlockType : public BlockType { private: bool transparent; bool passable; float speedModifier; bool interactable; Framework::RCArray states; int blockTypeIdAfterGrowth; Framework::Text blockTypeNameAfterGrowth; const char* readableName; int ticksNeeded; public: GrowingPlantBlockType(); protected: virtual void loadSuperBlock(Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const override; void createSuperBlock(Block* zBlock, Item* zItem) const override; virtual void saveSuperBlock( Block* zBlock, Framework::StreamWriter* zWriter) const override; virtual Item* createItem() const override; virtual Block* createBlock( Framework::Vec3 position, int dimensionId) const override; public: virtual ItemType* createItemType() const override; GrowingPlantBlockType* addGrowthState( float growthPercentage, ModelInfo* model); const Framework::RCArray& getStates() const; void setBlockTypeNameAfterGrowth(Framework::Text blockTypeIdAfterGrowth); Framework::Text getBlockTypeNameAfterGrowth() const; void setReadableName(const char* readableName); const char* getReadableName() const; void setTicksNeeded(int ticksNeeded); int getTicksNeeded() const; void setTransparent(bool transparent); bool isTransparent() const; void setPassable(bool passable); bool isPassable() const; void setSpeedModifier(float speedModifier); float getSpeedModifier() const; void setInteractable(bool interactable); bool isInteractable() const; }; class GrowingPlantBlockTypeFactory : public BlockTypeFactoryBase { public: GrowingPlantBlockTypeFactory(); GrowingPlantBlockType* createValue( Framework::JSON::JSONObject* zJson) const override; void fromJson(GrowingPlantBlockType* zResult, Framework::JSON::JSONObject* zJson) const override; void toJson(GrowingPlantBlockType* zObject, Framework::JSON::JSONObject* zResult) const override; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; Framework::Text getTypeToken() const override; };