#pragma once #include "Block.h" #include "TickQueue.h" class FluidBlockType; class FluidContainerItem; class FluidBlock : public Block { private: char flowOptions; char distanceToSource; int nextFlow; Framework::Vec3 lightWeights; bool neighborChanged; unsigned char maxFlowDistance; protected: virtual bool onTick( TickQueue* zQueue, int numTicks, bool& blocked) override; virtual void onPostTick() override; void doFlow(); public: FluidBlock(int typeId, Framework::Vec3 pos, int dimensionId, Framework::Vec3 lightWeights); virtual ~FluidBlock(); virtual void setNeighbourType(Direction dir, int type) override; virtual void sendModelInfo(NetworkMessage* zMessage) override; virtual bool isInteractable(const Item* zItem) const override; virtual void filterPassingLight(unsigned char rgb[3]) const override; virtual TickSourceType isTickSource() const override; virtual bool needsTick() const override; char getDistanceToSource() const; char getFlowOptions() const; friend FluidBlockType; }; class FluidBlockType : public BlockType { private: Framework::Vec3 lightWeights; int ticktsToFlow; unsigned char flowDistance; float hungerRecoveryPerL; float thirstRecoveryPerL; float heat; public: FluidBlockType(); protected: virtual void loadSuperBlock(Block* zBlock, Framework::StreamReader* zReader, int dimensionId) const override; virtual void saveSuperBlock( Block* zBlock, Framework::StreamWriter* zWriter) const override; virtual Item* createItem() const override; virtual Block* createBlock( Framework::Vec3 position, int dimesionId) const override; public: bool isFluid() const override; virtual ItemType* createItemType() const override; void setTicktsToFlow(int ticksToFlow); int getTicktsToFlow() const; void setFlowDistance(unsigned char flowDistance); unsigned char getFlowDistance() const override; void setLightWeights(Framework::Vec3 lightWeights); Framework::Vec3 getLightWeights() const; void setHungerRecoveryPerL(float hungerRecoveryPerL); float getHungerRecoveryPerL() const; void setThirstRecoveryPerL(float thirstRecoveryPerL); float getThirstRecoveryPerL() const; void setHeat(float heat); float getHeat() const; }; class FluidBlockTypeFactory : public BlockTypeFactoryBase { 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; JSONObjectValidationBuilder* addToValidator( JSONObjectValidationBuilder* builder) const override; Framework::Text getTypeToken() const override; };