123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #pragma once
- #include "BasicBlocks.h"
- #include "Block.h"
- #include "BlockType.h"
- class BasicLightSourceBlockType;
- class LightSourceItemType;
- class LightSourceItem : public BasicBlockItem
- {
- protected:
- int color;
- public:
- LightSourceItem(int itemType, int blockType, Framework::Text name);
- virtual bool canBeStackedWith(const Item* zItem) const override;
- friend LightSourceItemType;
- friend BasicLightSourceBlockType;
- };
- class LightSourceItemType : public BasicBlockItemType
- {
- private:
- int color;
- public:
- LightSourceItemType(Framework::Text name,
- ModelInfo* model,
- Framework::Text blockTypeName,
- int maxStackSize,
- Framework::RCArray<Framework::Text> groups);
- protected:
- virtual void loadSuperItem(
- Item* zItem, Framework::StreamReader* zReader) const override;
- virtual void saveSuperItem(
- const Item* zItem, Framework::StreamWriter* zWriter) const override;
- virtual Item* createItem() const override;
- public:
- LightSourceItemType* setColor(int color);
- };
- class BasicLightSource : public Block
- {
- public:
- BasicLightSource(int typeId, Framework::Vec3<int> pos, int dimensionId);
- protected:
- void setLight(int light);
- public:
- virtual bool onTick(
- TickQueue* zQueue, int numTicks, bool& blocked) override;
- virtual void onPostTick() override;
- friend BasicLightSourceBlockType;
- };
- class BasicLightSourceBlockType : public BlockType
- {
- private:
- Framework::Text itemTypeName;
- int itemTypeId;
- bool transparent;
- bool passable;
- bool interactable;
- int lightColor;
- public:
- BasicLightSourceBlockType();
- protected:
- virtual void createSuperBlock(Block* zBlock, Item* zItem) const override;
- virtual void loadSuperBlock(Block* zBlock,
- Framework::StreamReader* zReader,
- int dimensionId) const override;
- virtual void saveSuperBlock(
- Block* zBlock, Framework::StreamWriter* zWriter) const override;
- public:
- virtual bool initialize(Game* zGame) override;
- virtual Block* createBlock(
- Framework::Vec3<int> position, int dimensionId) const override;
- virtual Item* createItem() const override;
- virtual ItemType* createItemType() const override;
- void setItemTypeName(Framework::Text itemTypeName);
- Framework::Text getItemTypeName() const;
- void setTransparent(bool transparent);
- bool isTransparent() const;
- void setPassable(bool passable);
- bool isPassable() const;
- void setInteractable(bool interactable);
- bool isInteractable() const;
- void setLightColor(int lightColor);
- int getLightColor() const;
- };
- class BasicLightSourceBlockTypeFactory
- : public BlockTypeFactoryBase<BasicLightSourceBlockType>
- {
- public:
- BasicLightSourceBlockTypeFactory();
- BasicLightSourceBlockType* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(BasicLightSourceBlockType* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(BasicLightSourceBlockType* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|