12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #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<float> 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<int> pos,
- int dimensionId,
- Framework::Vec3<float> 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;
- char getDistanceToSource() const;
- char getFlowOptions() const;
- friend FluidBlockType;
- };
- class FluidBlockType : public BlockType
- {
- private:
- Framework::Vec3<float> 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<int> 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<float> lightWeights);
- Framework::Vec3<float> 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<FluidBlockType>
- {
- 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;
- };
|