Shuvit game master repo. http://shuvit.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GameObjectReference.py 639B

123456789101112131415161718192021222324
  1. import bge
  2. __all__ = ['GameObjectReference']
  3. class GameObjectReference(object):
  4. '''This object should keep track of a KX_GameObject, this until the death
  5. of the refered instance.'''
  6. def __init__(self, object):
  7. self._reference = object
  8. object[id(self)] = True
  9. @property
  10. def object(self):
  11. if not self._reference.invalid:
  12. return self._reference
  13. for scene in bge.logic.getSceneList():
  14. for object in scene.objects:
  15. if object.get(id(self), False):
  16. self._reference = object
  17. return object
  18. return None