<commit_before>var/global/datum/crafting_controller/crafting_master

/datum/crafting_recipe
	var/name = ""
	var/reqs[] = list()
	var/result_path
	var/tools[] = list()
	var/time = 0
	var/parts[] = list()
	var/chem_catalists[] = list()
	var/can_be_deconstructed = 0

/datum/crafting_recipe/New()
	crafting_master.all_crafting_recipes[name] = src

/datum/crafting_recipe/table/New()
	..()
	crafting_master.add_recipe_to_family("table", src)


/datum/crafting_controller
	var/list/families = list()
	var/list/all_crafting_points = list()
	var/list/all_crafting_recipes = list()

/hook/startup/proc/setupCraftingMaster()
	crafting_master = new /datum/crafting_controller()
	return 1

/datum/crafting_controller/New()
	crafting_master = src
	add_family("table")
	add_family("forge")
	for(var/A in typesof(/datum/crafting_recipe))
		if(A == /datum/crafting_recipe)
			continue
		var/datum/crafting_recipe/CR = new A()
		all_crafting_recipes[CR.name] = CR

/datum/crafting_controller/proc/add_global_recipe(datum/crafting_recipe/CR)
	all_crafting_recipes[CR.name] = CR

/datum/crafting_controller/proc/remove_global_recipe(datum/crafting_recipe/CR)
	all_crafting_recipes[CR.name] = null
	all_crafting_recipes.Remove(CR.name)

/datum/crafting_controller/proc/add_family(name, list/members, list/recipes)
	var/datum/crafting_family/family = new(name, members, recipes)
	families[name] = family

/datum/crafting_controller/proc/get_family_by_name(name)
	return families[name]

/datum/crafting_controller/proc/add_member_to_family(family_name, member)
	var/datum/crafting_family/family = families[family_name]
	family.add_member(member)

/datum/crafting_controller/proc/add_recipe_to_family(family_name, datum/crafting_recipe/recipe)
	var/datum/crafting_family/family = families[family_name]
	family.add_recipe(recipe)

/datum/crafting_controller/proc/remove_recipe_from_family(family_name, datum/crafting_recipe/recipe)
	var/datum/crafting_family/family = families[family_name]
	family.remove_recipe(recipe)

/datum/crafting_controller/proc/remove_member(family_name, member)
	var/datum/crafting_family/family = families[family_name]
	family.remove_member(member)

/datum/crafting_controller/proc/remove_family(family_name)
	var/datum/crafting_family/family = families[family_name]
	del(family)

/datum/crafting_family
	var/name
	var/list/recipes
	var/list/members

/datum/crafting_family/New(new_name, list/new_members = list(), list/new_recipes = list())
	name = new_name
	recipes = new_recipes
	members = new_members

/datum/crafting_family/proc/add_member(datum/crafting_holder/member)
	members |= member
	member.family = src

/datum/crafting_family/proc/remove_member(datum/crafting_holder/member)
	members -= member
	member.family = null

/datum/crafting_family/proc/add_recipe(datum/crafting_recipe/recipe)
	recipes[recipe.name] = recipe

/datum/crafting_family/proc/remove_recipe(datum/crafting_recipe/recipe)
	recipes[recipe.name] = null
	recipes.Remove(recipe.name)


/datum/crafting_holder
	var/name
	var/atom/holder
	var/recipes
	var/busy
	var/datum/crafting_family/family

/datum/crafting_holder/New(atom/location, family_name)
	location.craft_holder = src
	holder = location
	spawn(10)
		crafting_master.all_crafting_points |= src
		if(family_name)
			family = crafting_master.get_family_by_name(family_name)
		if(family)
			recipes = family.recipes

/datum/crafting_holder/proc/add_recipe(recipe)
	recipes |= recipe<commit_msg>Fix serverstart crafting controller runtimes.<commit_after>var/global/datum/crafting_controller/crafting_master

/datum/crafting_recipe
	var/name = ""
	var/reqs[] = list()
	var/result_path
	var/tools[] = list()
	var/time = 0
	var/parts[] = list()
	var/chem_catalists[] = list()
	var/can_be_deconstructed = 0

/datum/crafting_recipe/New()
	crafting_master.all_crafting_recipes[name] = src

/datum/crafting_recipe/table/New()
	..()
	crafting_master.add_recipe_to_family("table", src)


/datum/crafting_controller
	var/list/families = list()
	var/list/all_crafting_points = list()
	var/list/all_crafting_recipes = list()

/hook/startup/proc/setupCraftingMaster()
	crafting_master = new /datum/crafting_controller()
	return 1

/datum/crafting_controller/New()
	crafting_master = src
	add_family("table")
	add_family("forge")
	for(var/A in typesof(/datum/crafting_recipe))
		if(A == /datum/crafting_recipe)
			continue
		var/datum/crafting_recipe/CR = new A()
		all_crafting_recipes[CR.name] = CR

/datum/crafting_controller/proc/add_global_recipe(datum/crafting_recipe/CR)
	all_crafting_recipes[CR.name] = CR

/datum/crafting_controller/proc/remove_global_recipe(datum/crafting_recipe/CR)
	all_crafting_recipes[CR.name] = null
	all_crafting_recipes.Remove(CR.name)

/datum/crafting_controller/proc/add_family(name, list/members, list/recipes)
	var/datum/crafting_family/family = new(name, members, recipes)
	families[name] = family

/datum/crafting_controller/proc/get_family_by_name(name)
	return families[name]

/datum/crafting_controller/proc/add_member_to_family(family_name, member)
	var/datum/crafting_family/family = families[family_name]
	family.add_member(member)

/datum/crafting_controller/proc/add_recipe_to_family(family_name, datum/crafting_recipe/recipe)
	var/datum/crafting_family/family = families[family_name]
	family.add_recipe(recipe)

/datum/crafting_controller/proc/remove_recipe_from_family(family_name, datum/crafting_recipe/recipe)
	var/datum/crafting_family/family = families[family_name]
	family.remove_recipe(recipe)

/datum/crafting_controller/proc/remove_member(family_name, member)
	var/datum/crafting_family/family = families[family_name]
	family.remove_member(member)

/datum/crafting_controller/proc/remove_family(family_name)
	var/datum/crafting_family/family = families[family_name]
	del(family)

/datum/crafting_family
	var/name
	var/list/recipes
	var/list/members

/datum/crafting_family/New(new_name, list/new_members = list(), list/new_recipes = list())
	name = new_name
	recipes = new_recipes
	members = new_members

/datum/crafting_family/proc/add_member(datum/crafting_holder/member)
	members |= member
	member.family = src

/datum/crafting_family/proc/remove_member(datum/crafting_holder/member)
	members -= member
	member.family = null

/datum/crafting_family/proc/add_recipe(datum/crafting_recipe/recipe)
	recipes[recipe.name] = recipe

/datum/crafting_family/proc/remove_recipe(datum/crafting_recipe/recipe)
	recipes[recipe.name] = null
	recipes.Remove(recipe.name)


/datum/crafting_holder
	var/name
	var/atom/holder
	var/recipes
	var/busy
	var/datum/crafting_family/family

/datum/crafting_holder/New(atom/location, family_name)
	location.craft_holder = src
	holder = location
	spawn(50)
		crafting_master.all_crafting_points |= src
		if(family_name)
			family = crafting_master.get_family_by_name(family_name)
		if(family)
			recipes = family.recipes

/datum/crafting_holder/proc/add_recipe(recipe)
	recipes |= recipe
{'fraction_non_alphanumeric': 0.11357702349869452, 'fraction_numerical': 0.001450536698578474, 'mean_word_length': 6.050102249488752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4205921', 'n_tokens_mistral': 2678, 'n_tokens_neox': 2626, 'n_words': 303}