NetworkMessage.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 addEntityMessage(const Entity* zEntity);
  53. void removeEntityMessage(const Entity* zEntity);
  54. void writeTo(Framework::StreamWriter* zWriter) const;
  55. bool isBroadcast() const;
  56. bool isEmpty() const;
  57. bool isUseBackground() const;
  58. NetworkMessage* clone() const;
  59. };