# Path: compositecore.py
# class Leaf(Component):
#     """
#     Abstract leaf class of composite design pattern.
# 
#     Component classes of leaf type should inherit from this class.
#     """
# 
#     def __init__(self):
#         super(Leaf, self).__init__()
# 
#     def get_relative_of_type(self, component_type):
#         return self.parent.get_child_or_ancestor(component_type)
# 
#     def has_relative_of_type(self, component_type):
#         return self.parent.has_child_or_ancestor(component_type)
# 
# class CompositeMessage(object):
#     """
#     Enumerator defining class. Defines all messages that may be sent.
#     """
#     DUNGEON_LEVEL_CHANGED = 0
#     POSITION_CHANGED = 1
# 
#     def __init__(self):
#         """
#         Should not be initiated.
#         """
#         raise


from compositecore import Leaf, CompositeMessage

    @property
    def value(self):
        """
        Gets the dungeon_level the entity is currently in.
        """
        return self._value

    @value.setter
    def value(self, new_dungeon_level):
        """
        Sets current dungeon_level of the entity.
        Also updates the visibility/solidity of the dungeon_level tiles.
        """
        if not self._value is new_dungeon_level:
            old_dungeon_level = self._value
            self._value = new_dungeon_level
            self._signal_dungeon_level_changed()
            if(not old_dungeon_level is None and
               self.has_sibling("actor")):
                old_dungeon_level.remove_actor_if_present(self.parent)
                self.last_dungeon_level = old_dungeon_level
        if self.last_dungeon_level is None:
            self.last_dungeon_level = new_dungeon_level

    def _signal_dungeon_level_changed(self):
        """
        Is called when dungeon level has changed.
        """
        if self.has_parent() and not self.value is None:

# Path: compositecore.py
# class Leaf(Component):
#     """
#     Abstract leaf class of composite design pattern.
# 
#     Component classes of leaf type should inherit from this class.
#     """
# 
#     def __init__(self):
#         super(Leaf, self).__init__()
# 
#     def get_relative_of_type(self, component_type):
#         return self.parent.get_child_or_ancestor(component_type)
# 
#     def has_relative_of_type(self, component_type):
#         return self.parent.has_child_or_ancestor(component_type)
# 
# class CompositeMessage(object):
#     """
#     Enumerator defining class. Defines all messages that may be sent.
#     """
#     DUNGEON_LEVEL_CHANGED = 0
#     POSITION_CHANGED = 1
# 
#     def __init__(self):
#         """
#         Should not be initiated.
#         """
#         raise


# Path: position.py
from compositecore import Leaf, CompositeMessage


    @property
    def value(self):
        """
        Gets the dungeon_level the entity is currently in.
        """
        return self._value

    @value.setter
    def value(self, new_dungeon_level):
        """
        Sets current dungeon_level of the entity.
        Also updates the visibility/solidity of the dungeon_level tiles.
        """
        if not self._value is new_dungeon_level:
            old_dungeon_level = self._value
            self._value = new_dungeon_level
            self._signal_dungeon_level_changed()
            if(not old_dungeon_level is None and
               self.has_sibling("actor")):
                old_dungeon_level.remove_actor_if_present(self.parent)
                self.last_dungeon_level = old_dungeon_level
        if self.last_dungeon_level is None:
            self.last_dungeon_level = new_dungeon_level

    def _signal_dungeon_level_changed(self):
        """
        Is called when dungeon level has changed.
        """
        if self.has_parent() and not self.value is None:

            self.parent.send_message(CompositeMessage.DUNGEON_LEVEL_CHANGED)