def post(self, event):
     # Check if it is an event or a subclass thereof, otherwise, don't post it
     if isinstance(event, Event):
         for listener in self.listeners.keys():
             listener.notify(event)
     else:
         GlobalServices.getLogger().log("Can't post this object: %s" % event)
def get(methodname):
    try:
        return getattr(storage, methodname)
    except AttributeError as e:
        # If the method could not be found, inform the
        # logger to print it out and return a dummy method
        GlobalServices.getLogger().log(e)
        return dummymethod
 def __init__(self):
     # Dictionary containing sfx objects with unique keys
     self._sounds = {}
     # Current music to be played back
     self._music = None
     # Playing status of the music track
     self._musicPlaying = False
     # Logger
     from src.controller import GlobalServices
     self._logger = GlobalServices.getLogger()
     # List of sounds that are consistently playing
     self._soundlist = []
     # List of sound extensions
     self._soundexts = [".wav", ".ogg", ".mp3"]
 def render(self, screen):
     from src.controller import GlobalServices
     GlobalServices.getLogger().log("no render() implementation for object %s!" % self)
 def notify(self, event):
     from src.controller import GlobalServices
     GlobalServices.getLogger().log("no notify() implementation for object %s!" % self)
        source.addOverlay(fadeout)
        self._wait(dur)
        source.rendering_enabled = False
        GlobalServices.getEventManager().post(MapChangeRequestEvent((target, destination)))
        
        set_property(PLAYER_MOVEMENT_ENABLED, True)
        source.removeOverlay(fadeout)
        
        self.teleport_in_progress = False
        self._halt()
    
# Global instance to store all script-callback methods
storage = ScriptsStorage()
# Dummy method handle for every script whose
# Tiled method handle parameter does not exist in the ScriptsStorage
dummymethod = lambda x,y: GlobalServices.getLogger().log(\
                             "This is not implemented in ScriptEngine.py")
cooldown = False

# Shutdown method sent by the Game object in case of a QuitEvent.
# It orders executing script threads to kill.
def shutdown():
    storage.interrupted = True
    storage.running = False
        
# Retrieves the storage object's method handle using a string name of the desired method.
# This is called by the Script class constructor upon initializing a Script object.
# Parameter:
#   methodname  :   The string method name to be retrieved
# Returns:
#   The method handle for that method, or the dummy method if it doesn't exist
def get(methodname):
            source.rendering_enabled = False
            GlobalServices.getEventManager().post(MapChangeRequestEvent((target, destination)))
            
            source.removeOverlay(fadeout)
            source.flushOverlayQueue()
            set_property(PLAYER_MOVEMENT_ENABLED, True)
            self.teleport_in_progress = False
            
        self._halt()
        
# Global instance to store all script-callback methods
storage = ObjectStorage()
# Dummy method. When (by accident) an interaction is not implemented,
# the application doesn't crash, but instead uses this method that
# does nothing but notify the logger that a method is missing.
dummymethod = lambda x,y,z=0,w=0: GlobalServices.getLogger().log(\
                                  "This is not implemented in ObjectEngine.py")
        
# Shutdown method sent by game object in case of QuitEvent
def shutdown():
    storage.interrupted = True
    storage.running = False
        
# Returns the method handle to the script name's callback,
# or causes the logger to print out a warning message.
# Parameter:
#    methodname    :    String name of the method to retrieve
#                       (according to the object's "func" parameter in the TMX map)
# Returns:
#    Method handle to this method in the ObjectStorage object
def get(methodname):
    try: