1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #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;
- FluidBlockType* fromJson(Framework::JSON::JSONObject* zJson) const override;
- Framework::JSON::JSONObject* toJsonObject(
- FluidBlockType* zObject) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- const char* getTypeToken() const override;
- };
|