parameters: (converter_group, line, container_obj_ref, diff=None)
return_statement: return patches
docstring: Creates a patch for the Despawn ability of a line.
  
          :param converter_group: Group that gets the patch.
          :type converter_group: ...dataformat.converter_object.ConverterObjectGroup
          :param line: Unit/Building line that has the ability.
          :type line: ...dataformat.converter_object.ConverterObjectGroup
          :param container_obj_ref: Reference of the raw API object the patch is nested in.
          :type container_obj_ref: str
          :param diff: A diff between two ConvertObject instances.
          :type diff: ...dataformat.converter_object.ConverterObject
          :returns: The forward references for the generated patches.
          :rtype: list
docstring_summary: Creates a patch for the Despawn ability of a line.
docstring_tokens: Creates a patch for the Despawn ability of a line .
function: def despawn_ability(converter_group, line, container_obj_ref, diff=None):
          """
          Creates a patch for the Despawn ability of a line.
  
          :param converter_group: Group that gets the patch.
          :type converter_group: ...dataformat.converter_object.ConverterObjectGroup
          :param line: Unit/Building line that has the ability.
          :type line: ...dataformat.converter_object.ConverterObjectGroup
          :param container_obj_ref: Reference of the raw API object the patch is nested in.
          :type container_obj_ref: str
          :param diff: A diff between two ConvertObject instances.
          :type diff: ...dataformat.converter_object.ConverterObject
          :returns: The forward references for the generated patches.
          :rtype: list
          """
          head_unit_id = line.get_head_unit_id()
          tech_id = converter_group.get_id()
          dataset = line.data
  
          patches = []
  
          name_lookup_dict = internal_name_lookups.get_entity_lookups(dataset.game_version)
          tech_lookup_dict = internal_name_lookups.get_tech_lookups(dataset.game_version)
  
          game_entity_name = name_lookup_dict[head_unit_id][0]
  
          if diff:
              diff_dead_unit = diff["dead_unit_id"]
              if isinstance(diff_dead_unit, NoDiffMember):
                  return patches
  
              diff_animation_id = dataset.genie_units[diff_dead_unit.get_value()]["idle_graphic0"].get_value()
  
          else:
              return patches
  
          patch_target_ref = f"{game_entity_name}.Despawn"
          patch_target_forward_ref = ForwardRef(line, patch_target_ref)
  
          # Wrapper
          wrapper_name = f"Change{game_entity_name}DespawnAnimationWrapper"
          wrapper_ref = f"{container_obj_ref}.{wrapper_name}"
          wrapper_raw_api_object = RawAPIObject(wrapper_ref,
                                                wrapper_name,
                                                dataset.nyan_api_objects)
          wrapper_raw_api_object.add_raw_parent("engine.util.patch.Patch")
  
          if isinstance(line, GenieBuildingLineGroup):
              # Store building upgrades next to their game entity definition,
              # not in the Age up techs.
              wrapper_raw_api_object.set_location("data/game_entity/generic/%s/"
                                                  % (name_lookup_dict[head_unit_id][1]))
              wrapper_raw_api_object.set_filename(f"{tech_lookup_dict[tech_id][1]}_upgrade")
  
          else:
              wrapper_raw_api_object.set_location(ForwardRef(converter_group, container_obj_ref))
  
          # Nyan patch
          nyan_patch_name = f"Change{game_entity_name}DespawnAnimation"
          nyan_patch_ref = f"{container_obj_ref}.{wrapper_name}.{nyan_patch_name}"
          nyan_patch_location = ForwardRef(converter_group, wrapper_ref)
          nyan_patch_raw_api_object = RawAPIObject(nyan_patch_ref,
                                                   nyan_patch_name,
                                                   dataset.nyan_api_objects,
                                                   nyan_patch_location)
          nyan_patch_raw_api_object.add_raw_parent("engine.util.patch.NyanPatch")
          nyan_patch_raw_api_object.set_patch_target(patch_target_forward_ref)
  
          animations_set = []
          if diff_animation_id > -1:
              # Patch the new animation in
              animation_forward_ref = AoCUpgradeAbilitySubprocessor.create_animation(converter_group,
                                                                                     line,
                                                                                     diff_animation_id,
                                                                                     nyan_patch_ref,
                                                                                     "Despawn",
                                                                                     "despawn_")
              animations_set.append(animation_forward_ref)
  
          nyan_patch_raw_api_object.add_raw_patch_member("animations",
                                                         animations_set,
                                                         "engine.ability.property.type.Animated",
                                                         MemberOperator.ASSIGN)
  
          patch_forward_ref = ForwardRef(converter_group, nyan_patch_ref)
          wrapper_raw_api_object.add_raw_member("patch",
                                                patch_forward_ref,
                                                "engine.util.patch.Patch")
  
          converter_group.add_raw_api_object(wrapper_raw_api_object)
          converter_group.add_raw_api_object(nyan_patch_raw_api_object)
  
          wrapper_forward_ref = ForwardRef(converter_group, wrapper_ref)
          patches.append(wrapper_forward_ref)
  
          return patches
function_tokens: def despawn_ability ( converter_group , line , container_obj_ref , diff = None ) : head_unit_id = line . get_head_unit_id ( ) tech_id = converter_group . get_id ( ) dataset = line . data patches = [ ] name_lookup_dict = internal_name_lookups . get_entity_lookups ( dataset . game_version ) tech_lookup_dict = internal_name_lookups . get_tech_lookups ( dataset . game_version ) game_entity_name = name_lookup_dict [ head_unit_id ] [ 0 ] if diff : diff_dead_unit = diff [ "dead_unit_id" ] if isinstance ( diff_dead_unit , NoDiffMember ) : return patches diff_animation_id = dataset . genie_units [ diff_dead_unit . get_value ( ) ] [ "idle_graphic0" ] . get_value ( ) else : return patches patch_target_ref = f"{game_entity_name}.Despawn" patch_target_forward_ref = ForwardRef ( line , patch_target_ref ) # Wrapper wrapper_name = f"Change{game_entity_name}DespawnAnimationWrapper" wrapper_ref = f"{container_obj_ref}.{wrapper_name}" wrapper_raw_api_object = RawAPIObject ( wrapper_ref , wrapper_name , dataset . nyan_api_objects ) wrapper_raw_api_object . add_raw_parent ( "engine.util.patch.Patch" ) if isinstance ( line , GenieBuildingLineGroup ) : # Store building upgrades next to their game entity definition, # not in the Age up techs. wrapper_raw_api_object . set_location ( "data/game_entity/generic/%s/" % ( name_lookup_dict [ head_unit_id ] [ 1 ] ) ) wrapper_raw_api_object . set_filename ( f"{tech_lookup_dict[tech_id][1]}_upgrade" ) else : wrapper_raw_api_object . set_location ( ForwardRef ( converter_group , container_obj_ref ) ) # Nyan patch nyan_patch_name = f"Change{game_entity_name}DespawnAnimation" nyan_patch_ref = f"{container_obj_ref}.{wrapper_name}.{nyan_patch_name}" nyan_patch_location = ForwardRef ( converter_group , wrapper_ref ) nyan_patch_raw_api_object = RawAPIObject ( nyan_patch_ref , nyan_patch_name , dataset . nyan_api_objects , nyan_patch_location ) nyan_patch_raw_api_object . add_raw_parent ( "engine.util.patch.NyanPatch" ) nyan_patch_raw_api_object . set_patch_target ( patch_target_forward_ref ) animations_set = [ ] if diff_animation_id > - 1 : # Patch the new animation in animation_forward_ref = AoCUpgradeAbilitySubprocessor . create_animation ( converter_group , line , diff_animation_id , nyan_patch_ref , "Despawn" , "despawn_" ) animations_set . append ( animation_forward_ref ) nyan_patch_raw_api_object . add_raw_patch_member ( "animations" , animations_set , "engine.ability.property.type.Animated" , MemberOperator . ASSIGN ) patch_forward_ref = ForwardRef ( converter_group , nyan_patch_ref ) wrapper_raw_api_object . add_raw_member ( "patch" , patch_forward_ref , "engine.util.patch.Patch" ) converter_group . add_raw_api_object ( wrapper_raw_api_object ) converter_group . add_raw_api_object ( nyan_patch_raw_api_object ) wrapper_forward_ref = ForwardRef ( converter_group , wrapper_ref ) patches . append ( wrapper_forward_ref ) return patches