Parcourir la source

Added listen(), unlisten(), and emit() to gbe.nodes.Node. These are wrappers around the gbe.events.Events object.

master
Bryan Miller il y a 6 ans
Parent
révision
b7ad19d490
1 fichiers modifiés avec 17 ajouts et 0 suppressions
  1. +17
    -0
      game/gbe/nodes.py

+ 17
- 0
game/gbe/nodes.py Voir le fichier

@@ -187,6 +187,23 @@ class Node:
return c
return None

def listen(self, signal, callback_fn):
try:
Events.listen(signal, callback_fn)
except Exception as e:
raise e

def unlisten(self, signal, callback_fn):
Events.unlisten(signal, callback_fn)

def emit(self, signal, data={}):
# NOTE: I'm currently forcing the existance of this "NODE" key in the dictionary given. Not sure if I'll keep this.
data["NODE"] = {
"name":self.name
"n":self
}
Events.emit(signal, data)

def _init(self):
if hasattr(self, "on_init"):
self.on_init()

Chargement…
Annuler
Enregistrer