123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #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<GrowthState> states;
- int blockTypeAfterGrowth;
- bool plantSpawned;
- int lastSendState;
- public:
- GrowingPlantBlock(int typeId,
- Framework::Vec3<int> 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<GrowthState> 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<int> position, int dimensionId) const override;
- public:
- virtual ItemType* createItemType() const override;
- GrowingPlantBlockType* addGrowthState(
- float growthPercentage, ModelInfo* model);
- const Framework::RCArray<GrowthState>& 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<GrowingPlantBlockType>
- {
- 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;
- };
|