staticShape.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _STATICSHAPE_H_
  23. #define _STATICSHAPE_H_
  24. #ifndef _SHAPEBASE_H_
  25. #include "T3D/shapeBase.h"
  26. #endif
  27. //----------------------------------------------------------------------------
  28. struct StaticShapeData: public ShapeBaseData {
  29. typedef ShapeBaseData Parent;
  30. public:
  31. StaticShapeData();
  32. bool noIndividualDamage;
  33. S32 dynamicTypeField;
  34. bool isShielded;
  35. F32 energyPerDamagePoint;
  36. //
  37. DECLARE_CONOBJECT(StaticShapeData);
  38. static void initPersistFields();
  39. virtual void packData(BitStream* stream);
  40. virtual void unpackData(BitStream* stream);
  41. };
  42. //----------------------------------------------------------------------------
  43. class StaticShape: public ShapeBase
  44. {
  45. typedef ShapeBase Parent;
  46. StaticShapeData* mDataBlock;
  47. bool mPowered;
  48. void onUnmount(ShapeBase* obj,S32 node);
  49. protected:
  50. enum MaskBits {
  51. PositionMask = Parent::NextFreeMask,
  52. NextFreeMask = Parent::NextFreeMask << 1
  53. };
  54. public:
  55. DECLARE_CONOBJECT(StaticShape);
  56. StaticShape();
  57. ~StaticShape();
  58. bool onAdd();
  59. void onRemove();
  60. bool onNewDataBlock(GameBaseData *dptr, bool reload);
  61. void processTick(const Move *move);
  62. void interpolateTick(F32 delta);
  63. void setTransform(const MatrixF &mat);
  64. U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
  65. void unpackUpdate(NetConnection *conn, BitStream *stream);
  66. // power
  67. void setPowered(bool power) {mPowered = power;}
  68. bool isPowered() {return(mPowered);}
  69. static void initPersistFields();
  70. };
  71. #endif