Advertisement
Guest User

SceneManager

a guest
Sep 30th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. from HarambobEngine.Scene import Scene
  2.  
  3. class SceneManager:
  4.     '''
  5.    The SceneManager class manages all scenes that exist within the game
  6.    It holds the current scene, acts as a storage units for scenes currently not in use
  7.    and is able to interact directly with scenes.
  8.    '''
  9.  
  10.     instance = None
  11.     currentScene = None
  12.  
  13.     scenes = []
  14.  
  15.     def AddScene (self, scene: Scene):
  16.         '''
  17.        Adds a scene to the SceneManager.scenes list
  18.        :param scene:
  19.        :return:
  20.        '''
  21.  
  22.         self.scenes.append (scene)
  23.  
  24.     def SetCurrentScene (self, sceneName: str):
  25.  
  26.         for scene in self.scenes:
  27.  
  28.             if scene.name == sceneName:
  29.  
  30.                 self.currentScene = scene
  31.  
  32.  
  33.     @classmethod
  34.     def GetInstance (cls) -> instance:
  35.         '''
  36.        Public static factory method, keeps it's instance in SceneManager.instance
  37.        :return:
  38.        '''
  39.  
  40.         if isinstance (SceneManager.instance, SceneManager):
  41.  
  42.             return SceneManager.instance
  43.  
  44.         SceneManager.instance = SceneManager ()
  45.         return SceneManager.instance
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement