Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @startuml
- scale 700 width
- skinparam nodesep 10
- skinparam nodesep 20
- title Game Engine
- package Types {
- class EntityID_t
- class WindowSize_t
- class Position2D_t
- class Dimension2D_t
- class Orientation2D_t
- }
- note bottom of Types
- Types ending in _t are usually
- created via 'typedef'
- or 'using'
- end note
- package EntityHandling {
- class Entity {
- void updateClient()
- void updateServer()
- void render()
- --
- shared_ptr<Entity> getSharedPtr()
- EntityID_t getId()
- Position2D_t getPosition()
- Orientation2D_t getOrientation()
- --
- -weak_ptr<Entity> sharedPtrSource
- -EntityID_t id
- -Position2D_t position
- -Orientation2D_t orientation
- }
- class GameWorld {
- void updateServer()
- void updateClient()
- void render()
- --
- vector_it begin()
- vector_it end()
- --
- - vector<shared_ptr<Entity>> entities
- }
- GameWorld-->Entity
- }
- package MainGame {
- class Game {
- void initialize()
- void quit()
- --
- void updateServer()
- void updateClient()
- void render()
- --
- Renderer* getGraphicsContext()
- --
- -unique_ptr<GraphicsContext> graphicsContext;
- -NetworkManager networkManager
- }
- Game-->GameWorld
- }
- package Graphics {
- package Context {
- class GraphicsContext {
- GraphicsContext(title, width/height)
- ~GraphicsContext()
- --
- SDL_Window* getWindow()
- SDL_Renderer* getRenderer()
- WindowSize_t getWidth()
- WindowSize_t getHeight()
- string getTitle()
- TextureManager& getTextureManager()
- Camera& getCamera()
- --
- -SDL_Window *window
- -SDL_Renderer* renderer
- -WindowSize_t width
- -WindowSize_t height
- -string title
- -TextureManager textureManager
- }
- Game-->GraphicsContext
- class SDLInstance {
- SDLInstance()
- ~SDLInstance()
- Renderer createGraphicsContext(string title, WindowSize_t width/height);
- }
- }
- package Textures {
- class TextureManager {
- shared_ptr<TextureReference>& getTexture(string fileName)
- --
- -map<string, shared_ptr<TextureReference>> loadedTextures;
- }
- note bottom of TextureManager
- If the requested Texture isn't in the map,
- getTexture() loads the Texture.
- end note
- class TextureReference {
- TextureReference(texture)
- ~TextureReference()
- --
- SDL_Texture* getTexture();
- int getWidth()
- int getHeight()
- --
- -SDL_Texture* texture;
- -int width
- -int height
- }
- TextureManager-->TextureReference
- }
- package Rendering {
- class Camera {
- Position2D_t& getPosition()
- void setPosition(Position2D_t)
- --
- -Position2D_t position
- }
- class RectRenderer {
- RectRenderer(GraphicsContext gc, SDL_Rect& pRect)
- RectRenderer(GraphicsContext gc, int x, y, w, h)
- --
- void render()
- SDL_Rect& getRect()
- --
- -SDL_Rect rect
- -SDL_Renderer* renderer
- -Camera* camera
- }
- class TextureRenderer {
- TextureRenderer(GraphicsContext gc, shared_ptr<TextureReference> texture)
- --
- void render()
- void setPosition(Position2d_t)
- Position2D_t getPosition()
- void setSourceDimension(Dimension2D_t)
- Dimension2D_t getSourceDimension()
- void setDestinationDimension(Dimension2D_t)
- Dimension2D_t getDestinationDimension()
- void setOrientation(Orientation2D_t)
- Orientation2D_t getOrientation()
- --
- -Position2D_t position
- -Orientation2D_t orientation
- }
- }
- }
- package EventSystem {
- class Event {
- EventType type
- }
- class EventBus {
- void sendEvent(Event*)
- --
- -list<Listeners> listeners
- }
- EventBus-->Event
- class EventBusManager {
- EventBus& getEventBus()
- --
- -map<string, EventBus> eventBusMap
- }
- EventBusManager-->EventBus
- note right of EventBusManager
- If the requested EventBus isn't in the map, it will be created
- end note
- package Events {
- package InputEvents {
- class KeyEvent
- class MouseClickEvent
- }
- package NetworkEvents {
- class ClientConnectEvent
- class ClientDisconnectEvent
- class ServerDisconnectEvent
- class NetworkMessageEvent
- }
- }
- }
- package Networking {
- class ServerConnectInfo {
- ServerConnectInfo(ip, port)
- --
- const IPAddress_t ip
- const Port_t port
- }
- class ClientConnectionInfo {
- ClientConnectionInfo(id, nickname, other_info)
- --
- const string nickname
- TODO: Other info
- }
- class ServerInfo {
- void setName(string)
- void setNumberOfPlayers(unsigned int)
- string getName()
- --
- string name
- unsigned int numberOfPlayers
- }
- class NetworkState {
- CLIENT_SOLO
- CLIENT_CONNECTED
- SERVER
- }
- class NetworkManager {
- Shared methods
- NetworkState getState()
- bool isClient()
- bool isConnectedToServer()
- bool isServer()
- --
- Client methods
- void connectToServer(ServerConnectInfo& sci)
- void disconnectFromServer()
- --
- Server methods
- array<ClientConnectionInfo, MAX_CLIENTS> getClients()
- void kickClient(ClientConnectionInfo cci)
- --
- Shared state
- -NetworkState state
- --
- Client state
- -ClientInfo clientInfo
- -ServerInfo connectedServerInfo
- --
- Server state
- -ServerInfo localServerInfo
- -array<ClientConnectionInfo, MAX_CLIENTS> clients
- -unsigned int numberOfPlayers
- }
- Game-->NetworkManager
- note right of NetworkManager
- clientInfo=nullptr if server is running
- clientInfo=something if client is running
- localServerInfo=info about this server instance
- connectedServerInfo=info about the server client is connected to
- end note
- }
- MainGame-[hidden]down-|>EntityHandling
- Graphics-[hidden]down-|>Types
- @enduml
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement