コード例 #1
0
ファイル: world.py プロジェクト: 2HDFloppyDisk/fife-rpg
    def create_entity_dictionary(cls, entity, remove_default=True):
        """Creates a dictionary containing the values of the Entity

        Args:
            entity: The Entity instance

            remove_default: Skips fields whose value is the same as the
            default value.

        Returns:
            The created dictionary
        """
        entity_dict = {}
        components_data = entity_dict["Components"] = {}
        components = ComponentManager.get_components()
        for name, component in components.items():
            component_values = getattr(entity, name)
            if component_values:
                component_data = None
                for field in component.saveable_fields:
                    fields = component.fields
                    if not component_data:
                        component_data = components_data[name] = {}
                    value = getattr(component_values, field)
                    if remove_default and value == fields[field].default():
                        continue
                    component_data[field] = value
        return entity_dict
コード例 #2
0
 def configure(self):
     """Configure the worlds components and systems"""
     World.configure(self)
     components = ComponentManager.get_components()
     for name, component in components.iteritems():
         setattr(self.components, name, component)
     systems = SystemManager.get_systems()
     for name, system in systems.iteritems():
         setattr(self.systems, name, system)
     if not General.registered_as:
         General.register()
コード例 #3
0
ファイル: world.py プロジェクト: 2HDFloppyDisk/fife-rpg
 def configure(self):
     """Configure the worlds components and systems"""
     World.configure(self)
     components = ComponentManager.get_components()
     for name, component in components.items():
         setattr(self.components, name, component)
     systems = SystemManager.get_systems()
     for name, system in systems.items():
         setattr(self.systems, name, system)
     if not General.registered_as:
         General.register()
コード例 #4
0
    def create_entity_dictionary(cls, entity):
        """Creates a dictionary containing the values of the Entity

        Args:
            entity: The Entity instance

        Returns:
            The created dictionary
        """
        entity_dict = {}
        components_data = entity_dict["components"] = {}
        components = ComponentManager.get_components()
        for name, component in components.iteritems():
            component_values = getattr(entity, name)
            if component_values:
                component_data = None
                for field in component.saveable_fields:
                    if not component_data:
                        component_data = components_data[name] = {}
                    component_data[field] = getattr(component_values, field)
        return entity_dict