Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

Object.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include "Object.h"
  19. #include "Camera.h"
  20. #include "Core.h"
  21. #include "LandcellManager.h"
  22. #include "Log.h"
  23. #include "ObjectManager.h"
  24. Object::Object(ObjectId id) : id_(id)
  25. {}
  26. void Object::setProperty(BoolProperty property, bool value)
  27. {
  28. //LOG(Misc, Debug) << " bool " << getBoolPropertyName(property) << " = " << (value ? "true" : "false") << "\n";
  29. boolProperties_[property] = value;
  30. }
  31. void Object::setProperty(StringProperty property, string value)
  32. {
  33. //LOG(Misc, Debug) << " string " << getStringPropertyName(property) << " = " << value << "\n";
  34. stringProperties_[property] = value;
  35. }
  36. void Object::setProperty(IntProperty property, uint32_t value)
  37. {
  38. //LOG(Misc, Debug) << " int " << getIntPropertyName(property) << " = " << value << "\n";
  39. intProperties_[property] = value;
  40. }
  41. void Object::setProperty(Int64Property property, uint64_t value)
  42. {
  43. //LOG(Misc, Debug) << " int64 " << getInt64PropertyName(property) << " = " << value << "\n";
  44. int64Properties_[property] = value;
  45. }
  46. void Object::setProperty(FloatProperty property, double value)
  47. {
  48. //LOG(Misc, Debug) << " float " << getFloatPropertyName(property) << " = " << value << "\n";
  49. floatProperties_[property] = value;
  50. }
  51. void Object::setProperty(PositionProperty property, Position value)
  52. {
  53. //LOG(Misc, Debug) << " location " << getPositionPropertyName(property) << "\n";
  54. positionProperties_[property] = value;
  55. }
  56. void Object::setProperty(IIDProperty property, uint32_t value)
  57. {
  58. //LOG(Misc, Debug) << " IID " << getIIDPropertyName(property) << " = " << hexn(value) << "\n";
  59. iidProperties_[property] = value;
  60. }
  61. void Object::setProperty(DIDProperty property, uint32_t value)
  62. {
  63. //LOG(Misc, Debug) << " DID " << getDIDPropertyName(property) << " = " << hexn(value) << "\n";
  64. didProperties_[property] = value;
  65. }
  66. void Object::setModel(ResourcePtr model)
  67. {
  68. model_ = model;
  69. }
  70. void Object::setLandcellId(const LandcellId& landcellId)
  71. {
  72. if(id_ == Core::get().objectManager().playerId())
  73. {
  74. Core::get().landcellManager().setCenter(landcellId);
  75. }
  76. landcellId_ = landcellId;
  77. }
  78. void Object::setLocation(const Location& location)
  79. {
  80. if(id_ == Core::get().objectManager().playerId())
  81. {
  82. Core::get().camera().setPosition(location.position);
  83. }
  84. location_ = location;
  85. }
  86. ObjectId Object::id() const
  87. {
  88. return id_;
  89. }
  90. const ResourcePtr& Object::model() const
  91. {
  92. return model_;
  93. }
  94. const LandcellId& Object::landcellId() const
  95. {
  96. return landcellId_;
  97. }
  98. const Location& Object::location() const
  99. {
  100. return location_;
  101. }