123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #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;
- 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<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;
- };
|