-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathdummy.dm
141 lines (119 loc) · 5.19 KB
/
dummy.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/mob/living/carbon/human/dummy
real_name = "Test Dummy"
status_flags = GODMODE|CANPUSH
mouse_drag_pointer = MOUSE_INACTIVE_POINTER
visual_only_organs = TRUE
var/in_use = FALSE
INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy)
/mob/living/carbon/human/dummy/Destroy()
in_use = FALSE
return ..()
/mob/living/carbon/human/dummy/Life(seconds_per_tick = SSMOBS_DT, times_fired)
return
/mob/living/carbon/human/dummy/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE)
harvest_organs()
return ..()
///Let's extract our dummies organs and limbs for storage, to reduce the cache missed that spamming a dummy cause
/mob/living/carbon/human/dummy/proc/harvest_organs()
for(var/slot in list(ORGAN_SLOT_BRAIN, ORGAN_SLOT_HEART, ORGAN_SLOT_LUNGS, ORGAN_SLOT_APPENDIX, \
ORGAN_SLOT_EYES, ORGAN_SLOT_EARS, ORGAN_SLOT_TONGUE, ORGAN_SLOT_LIVER, ORGAN_SLOT_STOMACH))
var/obj/item/organ/current_organ = getorganslot(slot) //Time to cache it lads
if(current_organ)
current_organ.Remove(src, special = TRUE) //Please don't somehow kill our dummy
SSwardrobe.stash_object(current_organ)
var/datum/species/current_species = dna.species
for(var/organ_path in current_species.mutant_organs)
var/obj/item/organ/current_organ = getorgan(organ_path)
if(current_organ)
current_organ.Remove(src, special = TRUE) //Please don't somehow kill our dummy
SSwardrobe.stash_object(current_organ)
//Instead of just deleting our equipment, we save what we can and reinsert it into SSwardrobe's store
//Hopefully this makes preference reloading not the worst thing ever
/mob/living/carbon/human/dummy/delete_equipment()
var/list/items_to_check = get_all_slots() + held_items
var/list/to_nuke = list() //List of items queued for deletion, can't qdel them before iterating their contents in case they hold something
///Travel to the bottom of the contents chain, expanding it out
for(var/i = 1; i <= length(items_to_check); i++) //Needs to be a c style loop since it can expand
var/obj/item/checking = items_to_check[i]
if(!checking) //Nulls in the list, depressing
continue
if(!isitem(checking)) //What the fuck are you on
to_nuke += checking
continue
var/list/contents = checking.contents
if(length(contents))
items_to_check |= contents //Please don't make an infinite loop somehow thx
to_nuke += checking //Goodbye
continue
//I'm making the bet that if you're empty of other items you're not going to OOM if reapplied. I assume you're here because I was wrong
if(ismob(checking.loc))
var/mob/checkings_owner = checking.loc
checkings_owner.temporarilyRemoveItemFromInventory(checking, TRUE) //Clear out of there yeah?
SSwardrobe.stash_object(checking)
for(var/obj/item/delete as anything in to_nuke)
qdel(delete)
/mob/living/carbon/human/dummy/proc/wipe_state()
delete_equipment()
cut_overlays(TRUE)
/mob/living/carbon/human/dummy/setup_human_dna()
create_dna()
randomize_human(src)
dna.initialize_dna(skip_index = TRUE) //Skip stuff that requires full round init.
/proc/create_consistent_human_dna(mob/living/carbon/human/target)
target.dna.initialize_dna(skip_index = TRUE)
target.dna.features["body_markings"] = "None"
target.dna.features["ears"] = "None"
target.dna.features["frills"] = "None"
target.dna.features["horns"] = "None"
target.dna.features["mcolor"] = COLOR_VIBRANT_LIME
target.dna.features["mcolor_secondary"] = COLOR_RED
target.dna.features["moth_antennae"] = "Plain"
target.dna.features["moth_markings"] = "None"
target.dna.features["moth_wings"] = "Plain"
target.dna.features["snout"] = "Round"
target.dna.features["spines"] = "None"
target.dna.features["tail_cat"] = "None"
target.dna.features["tail_lizard"] = "Smooth"
target.dna.features["pod_hair"] = "Ivy"
target.dna.features["vox_quills"] = "None"
target.dna.features["vox_facial_quills"] = "None"
target.dna.features["vox_skin_tone"] = "lime"
target.dna.features["vox_tail_markings"] = "None"
target.dna.features["vox_body_markings"] = "None"
/// Provides a dummy that is consistently bald, white, naked, etc.
/mob/living/carbon/human/dummy/consistent
/mob/living/carbon/human/dummy/consistent/setup_human_dna()
create_dna()
create_consistent_human_dna(src)
/// Provides a dummy for unit_tests that functions like a normal human, but with a standardized appearance
/// Copies the stock dna setup from the dummy/consistent type
/mob/living/carbon/human/consistent
/mob/living/carbon/human/consistent/setup_human_dna()
create_dna()
create_consistent_human_dna(src)
/mob/living/carbon/human/consistent/update_body(is_creating)
..()
if(is_creating)
fully_replace_character_name(real_name, "John Doe")
//Inefficient pooling/caching way.
GLOBAL_LIST_EMPTY(human_dummy_list)
GLOBAL_LIST_EMPTY(dummy_mob_list)
/proc/generate_or_wait_for_human_dummy(slotkey)
if(!slotkey)
return new /mob/living/carbon/human/dummy
var/mob/living/carbon/human/dummy/D = GLOB.human_dummy_list[slotkey]
if(istype(D))
UNTIL(!D.in_use)
if(QDELETED(D))
D = new
GLOB.human_dummy_list[slotkey] = D
GLOB.dummy_mob_list += D
D.in_use = TRUE
return D
/proc/unset_busy_human_dummy(slotnumber)
if(!slotnumber)
return
var/mob/living/carbon/human/dummy/D = GLOB.human_dummy_list[slotnumber]
if(istype(D))
D.wipe_state()
D.in_use = FALSE