123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- #pragma once
- #include <Vec3.h>
- #include "BlockFilter.h"
- #include "Item.h"
- #include "ItemSkill.h"
- class FluidContainerItemType;
- class FluidContainerItem : public Item
- {
- private:
- int fluidTypeId;
- int fluidAmount;
- public:
- FluidContainerItem(int itemTypeId, Framework::Text name);
- virtual const BlockType* zPlacedBlockType() const override;
- virtual bool canBeStackedWith(const Item* zItem) const override;
- virtual bool canBePlacedAt(
- int dimensionId, Framework::Vec3<int> worldPos) const override;
- virtual void onPlaced();
- virtual Framework::Text getTooltipUIML() const override;
- virtual bool applyFoodEffects(Entity* zTarget) override;
- virtual bool canApplyFoodEffectsFully(Entity* zTarget) const override;
- int getAmount() const;
- void setAmount(int amount);
- int getFluidTypeId() const;
- void setFluidTypeId(int fluidTypeId);
- friend FluidContainerItemType;
- };
- class FluidContainerItemSkillConfig : public Framework::ReferenceCounter
- {
- private:
- BlockFilter* targetFilter;
- float staminaCost;
- float staminaCostDevider;
- float staminaCostDeviderPerLevel;
- int cooldownTicks;
- float xpGain;
- public:
- FluidContainerItemSkillConfig();
- ~FluidContainerItemSkillConfig();
- void setTargetFilter(BlockFilter* targetFilter);
- BlockFilter* zTargetFilter() const;
- void setStaminaCost(float staminaCost);
- float getStaminaCost() const;
- void setStaminaCostDevider(float staminaCostDevider);
- float getStaminaCostDevider() const;
- void setStaminaCostDeviderPerLevel(float staminaCostDeviderPerLevel);
- float getStaminaCostDeviderPerLevel() const;
- void setCooldownTicks(int cooldownTicks);
- int getCooldownTicks() const;
- void setXpGain(float xpGain);
- float getXpGain() const;
- };
- class FluidContainerItemSkillConfigFactory
- : public TypeFactory<FluidContainerItemSkillConfig>
- {
- public:
- FluidContainerItemSkillConfigFactory();
- FluidContainerItemSkillConfig* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(FluidContainerItemSkillConfig* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(FluidContainerItemSkillConfig* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- };
- class FluidContainerItemSkill : public ItemSkill
- {
- private:
- int cooldownTicks;
- FluidContainerItemSkillConfig* invalidUseConfig;
- Framework::RCArray<FluidContainerItemSkillConfig> configs;
- public:
- FluidContainerItemSkill();
- ~FluidContainerItemSkill();
- virtual bool use(Entity* zActor, Item* zUsedItem, Block* zTarget) override;
- virtual bool use(Entity* zActor, Item* zUsedItem, Entity* zTarget) override;
- void setInvalidUseConfig(FluidContainerItemSkillConfig* invalidUseConfig);
- FluidContainerItemSkillConfig* zInvalidUseConfig() const;
- void addConfig(FluidContainerItemSkillConfig* config);
- const Framework::RCArray<FluidContainerItemSkillConfig>& zConfigs() const;
- };
- class FluidContainerItemSkillFactory
- : public ItemSkillFactoryBase<FluidContainerItemSkill>
- {
- public:
- FluidContainerItemSkillFactory();
- FluidContainerItemSkill* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(FluidContainerItemSkill* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(FluidContainerItemSkill* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
- class FluidContainerItemType : public ItemType
- {
- private:
- int maxFluidAmount;
- Framework::JSON::JSONObject* itemSkillConfig;
- ItemSkillLevelUpRule* levelUpRule;
- public:
- FluidContainerItemType();
- ~FluidContainerItemType();
- protected:
- virtual void loadSuperItem(
- Item* zItem, Framework::StreamReader* zReader) const override;
- virtual void saveSuperItem(
- const Item* zItem, Framework::StreamWriter* zWriter) const override;
- public:
- virtual Item* createItem() const override;
- virtual ItemSkill* createDefaultItemSkill() const override;
- virtual void levelUpItemSkill(ItemSkill* zSkill) const override;
- virtual void setItemAttribute(Item* zItem,
- Framework::Text name,
- Framework::JSON::JSONValue* zValue) const override;
- virtual void addItemAttributes(
- Item* zItem, Framework::JSON::JSONObject* zItemObjet) const override;
- void setItemSkillConfig(Framework::JSON::JSONObject* itemSkillConfig);
- Framework::JSON::JSONObject* zItemSkillConfig() const;
- void setLevelUpRule(ItemSkillLevelUpRule* levelUpRule);
- ItemSkillLevelUpRule* zLevelUpRule() const;
- void setMaxFluidAmount(int maxFluidAmount);
- int getMaxFluidAmount() const;
- };
- class FluidContainerItemTypeFactory
- : public ItemTypeFactoryBase<FluidContainerItemType>
- {
- public:
- FluidContainerItemTypeFactory();
- FluidContainerItemType* createValue(
- Framework::JSON::JSONObject* zJson) const override;
- void fromJson(FluidContainerItemType* zResult,
- Framework::JSON::JSONObject* zJson) const override;
- void toJson(FluidContainerItemType* zObject,
- Framework::JSON::JSONObject* zResult) const override;
- JSONObjectValidationBuilder* addToValidator(
- JSONObjectValidationBuilder* builder) const override;
- Framework::Text getTypeToken() const override;
- };
|