Advertisement
Patasuss

ge

Aug 27th, 2017
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. @startuml
  2. scale 700 width
  3. skinparam nodesep 10
  4. skinparam nodesep 20
  5. title Game Engine
  6.  
  7. package Types {
  8. class EntityID_t
  9. class WindowSize_t
  10. class Position2D_t
  11. class Dimension2D_t
  12. class Orientation2D_t
  13. }
  14.  
  15. note bottom of Types
  16. Types ending in _t are usually
  17. created via 'typedef'
  18. or 'using'
  19. end note
  20.  
  21. package EntityHandling {
  22. class Entity {
  23. void updateClient()
  24. void updateServer()
  25. void render()
  26. --
  27. shared_ptr<Entity> getSharedPtr()
  28. EntityID_t getId()
  29. Position2D_t getPosition()
  30. Orientation2D_t getOrientation()
  31. --
  32. -weak_ptr<Entity> sharedPtrSource
  33. -EntityID_t id
  34. -Position2D_t position
  35. -Orientation2D_t orientation
  36. }
  37.  
  38. class GameWorld {
  39. void updateServer()
  40. void updateClient()
  41. void render()
  42. --
  43. vector_it begin()
  44. vector_it end()
  45. --
  46. - vector<shared_ptr<Entity>> entities
  47. }
  48.  
  49. GameWorld-->Entity
  50. }
  51.  
  52. package MainGame {
  53. class Game {
  54. void initialize()
  55. void quit()
  56. --
  57. void updateServer()
  58. void updateClient()
  59. void render()
  60. --
  61. Renderer* getGraphicsContext()
  62. --
  63. -unique_ptr<GraphicsContext> graphicsContext;
  64. -NetworkManager networkManager
  65. }
  66. Game-->GameWorld
  67. }
  68.  
  69. package Graphics {
  70. package Context {
  71. class GraphicsContext {
  72. GraphicsContext(title, width/height)
  73. ~GraphicsContext()
  74. --
  75. SDL_Window* getWindow()
  76. SDL_Renderer* getRenderer()
  77. WindowSize_t getWidth()
  78. WindowSize_t getHeight()
  79. string getTitle()
  80. TextureManager& getTextureManager()
  81. Camera& getCamera()
  82. --
  83. -SDL_Window *window
  84. -SDL_Renderer* renderer
  85. -WindowSize_t width
  86. -WindowSize_t height
  87. -string title
  88. -TextureManager textureManager
  89. }
  90. Game-->GraphicsContext
  91.  
  92. class SDLInstance {
  93. SDLInstance()
  94. ~SDLInstance()
  95. Renderer createGraphicsContext(string title, WindowSize_t width/height);
  96. }
  97. }
  98.  
  99. package Textures {
  100. class TextureManager {
  101. shared_ptr<TextureReference>& getTexture(string fileName)
  102. --
  103. -map<string, shared_ptr<TextureReference>> loadedTextures;
  104. }
  105.  
  106. note bottom of TextureManager
  107. If the requested Texture isn't in the map,
  108. getTexture() loads the Texture.
  109. end note
  110.  
  111. class TextureReference {
  112. TextureReference(texture)
  113. ~TextureReference()
  114. --
  115. SDL_Texture* getTexture();
  116. int getWidth()
  117. int getHeight()
  118. --
  119. -SDL_Texture* texture;
  120. -int width
  121. -int height
  122. }
  123.  
  124. TextureManager-->TextureReference
  125. }
  126.  
  127. package Rendering {
  128. class Camera {
  129. Position2D_t& getPosition()
  130. void setPosition(Position2D_t)
  131. --
  132. -Position2D_t position
  133. }
  134.  
  135. class RectRenderer {
  136. RectRenderer(GraphicsContext gc, SDL_Rect& pRect)
  137. RectRenderer(GraphicsContext gc, int x, y, w, h)
  138. --
  139. void render()
  140. SDL_Rect& getRect()
  141. --
  142. -SDL_Rect rect
  143. -SDL_Renderer* renderer
  144. -Camera* camera
  145. }
  146.  
  147. class TextureRenderer {
  148. TextureRenderer(GraphicsContext gc, shared_ptr<TextureReference> texture)
  149. --
  150. void render()
  151. void setPosition(Position2d_t)
  152. Position2D_t getPosition()
  153. void setSourceDimension(Dimension2D_t)
  154. Dimension2D_t getSourceDimension()
  155. void setDestinationDimension(Dimension2D_t)
  156. Dimension2D_t getDestinationDimension()
  157. void setOrientation(Orientation2D_t)
  158. Orientation2D_t getOrientation()
  159. --
  160. -Position2D_t position
  161. -Orientation2D_t orientation
  162. }
  163. }
  164. }
  165.  
  166. package EventSystem {
  167. class Event {
  168. EventType type
  169. }
  170.  
  171. class EventBus {
  172. void sendEvent(Event*)
  173. --
  174. -list<Listeners> listeners
  175. }
  176. EventBus-->Event
  177.  
  178. class EventBusManager {
  179. EventBus& getEventBus()
  180. --
  181. -map<string, EventBus> eventBusMap
  182. }
  183. EventBusManager-->EventBus
  184.  
  185. note right of EventBusManager
  186. If the requested EventBus isn't in the map, it will be created
  187. end note
  188.  
  189. package Events {
  190. package InputEvents {
  191. class KeyEvent
  192. class MouseClickEvent
  193. }
  194. package NetworkEvents {
  195. class ClientConnectEvent
  196. class ClientDisconnectEvent
  197. class ServerDisconnectEvent
  198. class NetworkMessageEvent
  199. }
  200. }
  201. }
  202.  
  203. package Networking {
  204. class ServerConnectInfo {
  205. ServerConnectInfo(ip, port)
  206. --
  207. const IPAddress_t ip
  208. const Port_t port
  209. }
  210.  
  211. class ClientConnectionInfo {
  212. ClientConnectionInfo(id, nickname, other_info)
  213. --
  214. const string nickname
  215. TODO: Other info
  216. }
  217.  
  218. class ServerInfo {
  219. void setName(string)
  220. void setNumberOfPlayers(unsigned int)
  221. string getName()
  222. --
  223. string name
  224. unsigned int numberOfPlayers
  225. }
  226.  
  227. class NetworkState {
  228. CLIENT_SOLO
  229. CLIENT_CONNECTED
  230. SERVER
  231. }
  232.  
  233. class NetworkManager {
  234. Shared methods
  235. NetworkState getState()
  236. bool isClient()
  237. bool isConnectedToServer()
  238. bool isServer()
  239. --
  240. Client methods
  241. void connectToServer(ServerConnectInfo& sci)
  242. void disconnectFromServer()
  243. --
  244. Server methods
  245. array<ClientConnectionInfo, MAX_CLIENTS> getClients()
  246. void kickClient(ClientConnectionInfo cci)
  247. --
  248. Shared state
  249. -NetworkState state
  250. --
  251. Client state
  252. -ClientInfo clientInfo
  253. -ServerInfo connectedServerInfo
  254. --
  255. Server state
  256. -ServerInfo localServerInfo
  257. -array<ClientConnectionInfo, MAX_CLIENTS> clients
  258. -unsigned int numberOfPlayers
  259. }
  260. Game-->NetworkManager
  261.  
  262. note right of NetworkManager
  263. clientInfo=nullptr if server is running
  264. clientInfo=something if client is running
  265. localServerInfo=info about this server instance
  266. connectedServerInfo=info about the server client is connected to
  267. end note
  268. }
  269.  
  270. MainGame-[hidden]down-|>EntityHandling
  271. Graphics-[hidden]down-|>Types
  272. @enduml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement