tf_econ_dynamic.inc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * An InjectedAttribute is an abstraction over the KeyValues representation of an attribute
  3. * definition.
  4. */
  5. methodmap EconInjectedAttribute < Handle {
  6. /**
  7. * Creates a new, empty EconInjectedAttribute handle.
  8. *
  9. * The attribute is not injected into the schema until EconInjectedAttribute.Register() is
  10. * called.
  11. *
  12. * This handle should be freed by the calling plugin.
  13. */
  14. public native EconInjectedAttribute();
  15. /**
  16. * Sets the attribute class. All values under the same attribute class are combined.
  17. * This is required.
  18. */
  19. public native void SetClass(const char[] attrClass);
  20. /**
  21. * Sets the attribute name. Only one instance of this per game entity can be active.
  22. * If this is empty or NULL_STRING, it will be set to the attribute class on registration.
  23. */
  24. public native void SetName(const char[] attrName);
  25. /**
  26. * Sets the description format. This determines how multiple values with the same attribute
  27. * class are combined.
  28. *
  29. * Generally, "value_is_additive" and "value_is_percentage" are the main ones that matter,
  30. * but being precise is ideal in case you want to use the description format when displaying
  31. * values to players as with actual schema attributes.
  32. */
  33. public native void SetDescriptionFormat(const char[] attrDescFmt);
  34. /**
  35. * Sets a custom key / value pair.
  36. *
  37. * Note that "injected" is a key reserved by the plugin that is set to 1 when registered,
  38. * overriding any other values set.
  39. *
  40. * The game has set other keys in the schema in the past, and it may use new ones in the
  41. * future.
  42. */
  43. public native void SetCustom(const char[] key, const char[] value);
  44. /**
  45. * Sets the attribute's definition index.
  46. *
  47. * By default, the extension will automatically allocate a previously unused index. As the
  48. * schema may be reloaded between maps, there is no guarantee that an attribute will
  49. * continue to exist at a specific index. If an index is manually specified and a
  50. * attribute now exists at the index, the injection of the attribute will fail.
  51. *
  52. * Plugins are expected to either perform a lookup by attribute name, or preferably, use the
  53. * hook-style natives with the attribute class.
  54. *
  55. * This native is solely provided for backwards compatibility with schema formats that
  56. * manually specify indices.
  57. */
  58. public native void SetDefIndex(int attrdef);
  59. /**
  60. * Clears the attribute's specified definition index.
  61. */
  62. public native void ClearDefIndex();
  63. /**
  64. * Stores a copy of the attribute properties in the core plugin to be injected.
  65. *
  66. * This operation does not clear existing values on the EconInjectedAttribute, so you can
  67. * create multiple attributes by repeatedly calling EconInjectedAttribute.SetName() and
  68. * EconInjectedAttribute.Register().
  69. *
  70. * If an attribute with the same name already exists and is not an injected attribute
  71. * managed by the core plugin, this will fail.
  72. *
  73. * The attribute definition index may be reallocated if a new copy of the schema is loaded
  74. * in and the index is occupied by a non-injected attribute.
  75. */
  76. public native bool Register();
  77. /**
  78. * Imports the properties of an attribute by name to the EconInjectedAttribute handle,
  79. * replacing all values currently set.
  80. *
  81. * @return True if the attribute exists, otherwise false.
  82. */
  83. // TODO this isn't implemented yet
  84. // public native bool Import(const char[] name);
  85. /**
  86. * Resets the container to its initial state.
  87. */
  88. public native void Clear();
  89. }