NetworkMessage.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include <Punkt.h>
  3. #include <ReferenceCounter.h>
  4. #include <Vec3.h>
  5. #include <Writer.h>
  6. class Chunk;
  7. class Block;
  8. class Entity;
  9. class Dimension;
  10. class ChatMessage;
  11. class ChatObserver;
  12. class ChunkMap;
  13. class NetworkMessage : public virtual Framework::ReferenceCounter
  14. {
  15. private:
  16. char* address;
  17. char addressLength;
  18. bool broadcast;
  19. char* message;
  20. int msgLength;
  21. bool useBackground;
  22. std::function<void()> onAfterSend;
  23. public:
  24. NetworkMessage();
  25. virtual ~NetworkMessage();
  26. void setOnAfterSend(std::function<void()> onAfterSend);
  27. void addressChunck(const Chunk* zChunk);
  28. void addressEntity(const Entity* zEntity);
  29. void addressBlock(const Block* zBlock);
  30. void addressDimension(const Dimension* zDim);
  31. void openDialog(Framework::Text dialogName, Framework::Text uiml);
  32. void updateDialog(Framework::Text dialogName, Framework::Text uiml);
  33. void addressUIElement(Framework::Text elementId);
  34. void setMessage(char* msg, int length);
  35. void sendChatMessage(ChatMessage* zMsg);
  36. void sendChatOptions(ChatObserver* zOptions);
  37. void sendMap(ChunkMap* zMap);
  38. void sendPlayerPositions(char* msg, int length);
  39. void setUseBackground();
  40. void sendToAll();
  41. void animateBlockBone(int dimensionId,
  42. Framework::Punkt chunkCenter,
  43. int index,
  44. int boneId,
  45. double time,
  46. Framework::Vec3<float> pos,
  47. Framework::Vec3<float> rotation);
  48. void syncTime(double time,
  49. double nightLength,
  50. double transitionLength,
  51. double dayLength);
  52. void writeTo(Framework::StreamWriter* zWriter) const;
  53. bool isBroadcast() const;
  54. bool isEmpty() const;
  55. bool isUseBackground() const;
  56. NetworkMessage* clone() const;
  57. };