123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #pragma once
- #include "Block.h"
- #include "BlockType.h"
- #include "Item.h"
- #include "TypeRegistry.h"
- class BlockType;
- class ItemType;
- class BasicBlockType;
- class BasicBlock : public Block
- {
- public:
- BasicBlock(int typeId, Framework::Vec3<int> pos, int dimensionId);
- BasicBlock(int typeId,
- Framework::Vec3<int> pos,
- int dimensionId,
- bool hasInventory);
- virtual bool onTick(
- TickQueue* zQueue, int numTicks, bool& blocked) override;
- virtual void onPostTick() override;
- friend BasicBlockType;
- };
- struct SpawnConfig
- {
- int min;
- int max;
- double chance;
- Framework::Text itemTypeName;
- int typeId;
- };
- class BasicBlockType : public BlockType
- {
- private:
- Framework::Text itemTypeName;
- int itemTypeId;
- bool transparent;
- bool passable;
- float speedModifier;
- bool interactable;
- protected:
- virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
- public:
- BasicBlockType();
- virtual bool initialize(Game* zGame) override;
- virtual Block* createBlock(
- Framework::Vec3<int> position, int dimensionId) const override;
- virtual Item* createItem() const override;
- Framework::Text getItemTypeName() const;
- virtual ItemType* createItemType() const override;
- void setItemTypeName(Framework::Text itemTypeName);
- int getItemTypeId() 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 BasicBlockTypeFactory : public BlockTypeFactoryBase<BasicBlockType>
- {
- public:
- BasicBlockTypeFactory();
- BasicBlockType* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(BasicBlockType* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(BasicBlockType* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class AdditionalItemSpawningBlock : public BasicBlock
- {
- private:
- Framework::Array<SpawnConfig> spawns;
- public:
- AdditionalItemSpawningBlock(
- int typeId, Framework::Vec3<int> pos, int dimensionId);
- void addSpawn(SpawnConfig config);
- virtual void onDestroy() override;
- };
- class AdditionalItemSpawningBlockType : public BasicBlockType
- {
- private:
- Framework::Array<SpawnConfig> spawns;
- public:
- AdditionalItemSpawningBlockType();
- protected:
- virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
- public:
- virtual bool initialize(Game* zGame) override;
- virtual Block* createBlock(
- Framework::Vec3<int> position, int dimensionId) const override;
- void addSpawn(SpawnConfig config);
- const Framework::Array<SpawnConfig>& getSpawns() const;
- };
- class AdditionalItemSpawningBlockTypeFactory
- : public BlockTypeFactoryBase<AdditionalItemSpawningBlockType>
- {
- private:
- BasicBlockTypeFactory super;
- public:
- AdditionalItemSpawningBlockTypeFactory();
- AdditionalItemSpawningBlockType* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(AdditionalItemSpawningBlockType* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(AdditionalItemSpawningBlockType* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|