object_properties.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <optional>
  18. #include <string>
  19. #include "irrlichttypes_bloated.h"
  20. #include <iostream>
  21. #include <map>
  22. #include <vector>
  23. #include "util/pointabilities.h"
  24. struct ObjectProperties
  25. {
  26. /* member variables ordered roughly by size */
  27. std::vector<std::string> textures;
  28. std::vector<video::SColor> colors;
  29. // Values are BS=1
  30. aabb3f collisionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
  31. // Values are BS=1
  32. aabb3f selectionbox = aabb3f(-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);
  33. std::string visual = "sprite";
  34. std::string mesh;
  35. std::string damage_texture_modifier = "^[brighten";
  36. std::string nametag;
  37. std::string infotext;
  38. // For dropped items, this contains the serialized item.
  39. std::string wield_item;
  40. v3f visual_size = v3f(1, 1, 1);
  41. video::SColor nametag_color = video::SColor(255, 255, 255, 255);
  42. std::optional<video::SColor> nametag_bgcolor;
  43. v2s16 spritediv = v2s16(1, 1);
  44. v2s16 initial_sprite_basepos;
  45. f32 stepheight = 0.0f;
  46. float automatic_rotate = 0.0f;
  47. f32 automatic_face_movement_dir_offset = 0.0f;
  48. f32 automatic_face_movement_max_rotation_per_sec = -1.0f;
  49. float eye_height = 1.625f;
  50. float zoom_fov = 0.0f;
  51. u16 hp_max = 1;
  52. u16 breath_max = 0;
  53. s8 glow = 0;
  54. PointabilityType pointable = PointabilityType::POINTABLE;
  55. // In a future protocol these could be a flag field.
  56. bool physical = false;
  57. bool collideWithObjects = true;
  58. bool rotate_selectionbox = false;
  59. bool is_visible = true;
  60. bool makes_footstep_sound = false;
  61. bool automatic_face_movement_dir = false;
  62. bool backface_culling = true;
  63. bool static_save = true;
  64. bool use_texture_alpha = false;
  65. bool shaded = true;
  66. bool show_on_minimap = false;
  67. ObjectProperties();
  68. std::string dump() const;
  69. /**
  70. * Check limits of some important properties that'd cause exceptions later on.
  71. * Errornous values are discarded after printing a warning.
  72. * @return true if a problem was found
  73. */
  74. bool validate();
  75. void serialize(std::ostream &os) const;
  76. void deSerialize(std::istream &is);
  77. };