Component.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Component.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. VCMI_LIB_NAMESPACE_BEGIN
  12. class CStackBasicDescriptor;
  13. struct Component
  14. {
  15. enum class EComponentType : uint8_t
  16. {
  17. PRIM_SKILL,
  18. SEC_SKILL,
  19. RESOURCE,
  20. CREATURE,
  21. ARTIFACT,
  22. EXPERIENCE,
  23. SPELL,
  24. MORALE,
  25. LUCK,
  26. BUILDING,
  27. HERO_PORTRAIT,
  28. FLAG,
  29. INVALID //should be last
  30. };
  31. EComponentType id = EComponentType::INVALID;
  32. ui16 subtype = 0; //id==EXPPERIENCE subtype==0 means exp points and subtype==1 levels
  33. si32 val = 0; // + give; - take
  34. si16 when = 0; // 0 - now; +x - within x days; -x - per x days
  35. template <typename Handler> void serialize(Handler &h, const int version)
  36. {
  37. h & id;
  38. h & subtype;
  39. h & val;
  40. h & when;
  41. }
  42. Component() = default;
  43. DLL_LINKAGE explicit Component(const CStackBasicDescriptor &stack);
  44. Component(Component::EComponentType Type, ui16 Subtype, si32 Val, si16 When)
  45. :id(Type),subtype(Subtype),val(Val),when(When)
  46. {
  47. }
  48. };
  49. VCMI_LIB_NAMESPACE_END