[MODULARIZING] Partial Refactoring of Organic Interface Code (#16019)

This took a long time to review, but at long last, it's done.

* HUD clutter, good bye, you will not be missed.

* Oh my god so much pain

* No commented code. Bad.

* Uwaaaa

* Add a couple of warning messages for common scenarios, use defines

* AAAAA

* AAAAAAAAAAA

* UWAAAA

* UUUUWAAAA, DOCUMENTED SNOWFLAKE CODE

* FUCK

* Apply suggestions!

* Apply suggestions part one!

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>

* Apply suggestions part two!

* Static list

I think this is how it works, it compiles, sooo

* Split the giga monolith that's known as technical_stuff_for_lewd into two parts, human_helpers, and whatever else isn't a human helper. Also add a helper proc for mass update_inv on organic interface slots.

* I can't believe you did this

* Did you know that organic interface code didn't clean up it's defines? Neither did I!

* Less ifs

* Apply last suggestion that I know how to

* That was a lie

* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I HAVEN'T EVEN TOUCHED THE WORST CODE

* Oops

* Pain

* No copypaste

* Proc is 🦀

* No, bad, no commenting code.

* List prittification for chems, reduces the sheer amount of update_body calls

* Allow non-lewd empath users to not have to suffer raunchy inspect messages

* Oop

* DEEEEEEEEEEEEFINES

* Oh yea, that review. Definitely remembered.

* Formatting

* Breast defines

* MUCH cleaner and MUCH MUCH EASIER to expand incubus draft code

* Credit myself if I'm gonna spend days of my time combing through this

* Oops

* Chems cleanup

* Whyyyyyyy

* Climax rework, suffering.

* Wtf is this name

* Oh yea, arousal clamping.

* Haha, oops

* Bad, this is stupid easy to modularize

* Why is body_size in here

* List formatting, grammar stuff, and also breast size is now letters

* This took too long for me to figure out and I'm not proud

* Even I can make shitcode!

* Oops, typo

* You know, this makes more sense.

* Mhhh, this shouldn't be named like this

* Wrong file

* Rename `adjustPain`

* Dead code go yeet

* Y U NO READ DOCS

* Doc proc, minor optimisation

* Reviews part 1

* Whoever made this should read good coding practices. For any language.

* DEEEEFINNNEEEEESSSS

* SUFFER

* No more fluids

* EEEEEEEEEEE

* AAAAAAAAAAAAAAA

* MOB IS 🦀

* AAAAAAAAAAAAAAAAAA

* AAAAAA

* UWA

* And also solve tastfish's reviews!

* Partial revert, cause DM hates that

* I am very smart

* EEE

* AAAAAA

* Haha keyboard go click clack

* CODE

* FUCK

* FUUUUUCK

* PERFORMANCE

* Reset horny to 0 if erp disabled

* Arousal minimum is now 0, cause negatives are dumb and I hate them

Also cuts out some code that isn't needed as far as I can tell.

* Apply suggestions!

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>

* AAAAA

* AAAAAAAAAA I CAN'T CODE

* Aaaaa

* WHY GIT

* I am very smart part... uh, four?

* Minor formatting changes

* Oops, fix potential cause of multiple climax attempts

* WAIT, WHY AREN'T YOU USING THE DEFINE?!

* Magic number slightly less magicky, sorta.

Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
RimiNosha
2022-10-04 11:06:12 -04:00
committed by GitHub
co-authored by GoldenAlpharex
parent 4ece9155a6
commit f58cf51ae4
98 changed files with 2982 additions and 3540 deletions
@@ -61,7 +61,6 @@
return TRUE
/// UI Control
/datum/component/interactable/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
@@ -95,8 +94,39 @@
data["self"] = self.name
data["block_interact"] = interact_next >= world.time
data["interactions"] = categories
var/list/parts = list()
if(ishuman(user) && can_lewd_strip(user, self))
if(self.client?.prefs?.read_preference(/datum/preference/toggle/erp/sex_toy))
if(self.has_vagina())
parts += list(generate_strip_entry(ORGAN_SLOT_VAGINA, self, user, self.vagina))
if(self.has_penis())
parts += list(generate_strip_entry(ORGAN_SLOT_PENIS, self, user, self.penis))
if(self.has_anus())
parts += list(generate_strip_entry(ORGAN_SLOT_ANUS, self, user, self.anus))
parts += list(generate_strip_entry(ORGAN_SLOT_NIPPLES, self, user, self.nipples))
data["lewd_slots"] = parts
return data
/**
* Takes the organ slot name, along with a target and source, along with the item on the target that the source can potentially interact with.
* If the source can't interact with said slot, or there is no item in the first place, it'll set the icon to null to indicate that TGUI should put a placeholder sprite.
*
* Arguments:
* * name - The name of slot to check and return inside the generated list.
* * target - The mob that's being interacted with.
* * source - The mob that's interacting.
* * item - The item that's currently inside said slot. Can be null.
*/
/datum/component/interactable/proc/generate_strip_entry(name, mob/living/carbon/human/target, mob/living/carbon/human/source, obj/item/clothing/sextoy/item)
return list(
"name" = name,
"img" = (item && can_lewd_strip(source, target, name)) ? icon2base64(icon(item.icon, item.icon_state, SOUTH, 1)) : null
)
/datum/component/interactable/ui_act(action, list/params)
. = ..()
if(.)
@@ -113,4 +143,85 @@
interact_next = interaction_component.interact_last + INTERACTION_COOLDOWN
interaction_component.interact_next = interact_next
return TRUE
if(params["item_slot"])
// This code should be easy enough to follow... I hope.
var/item_index = params["item_slot"]
var/mob/living/carbon/human/source = locate(params["userref"])
var/mob/living/carbon/human/target = locate(params["selfref"])
var/obj/item/new_item = source.get_active_held_item()
var/obj/item/existing_item = target.vars[item_index]
if(!existing_item && !new_item)
source.show_message(span_warning("No item to insert or remove!"))
return
if(!existing_item && !istype(new_item, /obj/item/clothing/sextoy))
source.show_message(span_warning("The item you're holding is not a toy!"))
return
if(can_lewd_strip(source, target, item_index) && is_toy_compatible(new_item, item_index))
var/internal = (item_index in list(ORGAN_SLOT_VAGINA, ORGAN_SLOT_ANUS))
var/insert_or_attach = internal ? "insert" : "attach"
var/into_or_onto = internal ? "into" : "onto"
if(existing_item)
source.visible_message(span_purple("[source.name] starts trying to remove something from [target.name]'s [item_index]."), span_purple("You start to remove [existing_item.name] from [target.name]'s [item_index]."), span_purple("You hear someone trying to remove something from someone nearby."), vision_distance = 1, ignored_mobs = list(target))
else if (new_item)
source.visible_message(span_purple("[source.name] starts trying to [insert_or_attach] the [new_item.name] [into_or_onto] [target.name]'s [item_index]."), span_purple("You start to [insert_or_attach] the [new_item.name] [into_or_onto] [target.name]'s [item_index]."), span_purple("You hear someone trying to [insert_or_attach] something [into_or_onto] someone nearby."), vision_distance = 1, ignored_mobs = list(target))
if (source != target)
target.show_message(span_warning("[source.name] is trying to [existing_item ? "remove the [existing_item.name] [internal ? "in" : "on"]" : new_item ? "is trying to [insert_or_attach] the [new_item.name] [into_or_onto]" : span_alert("What the fuck, impossible condition? interaction_component.dm!")] your [item_index]!"))
if(do_after(
source,
5 SECONDS,
target,
interaction_key = "interation_[item_index]"
) && can_lewd_strip(source, target, item_index))
if(existing_item)
source.visible_message(span_purple("[source.name] removes [existing_item.name] from [target.name]'s [item_index]."), span_purple("You remove [existing_item.name] from [target.name]'s [item_index]."), span_purple("You hear someone remove something from someone nearby."), vision_distance = 1)
target.dropItemToGround(existing_item, force = TRUE) // Force is true, cause nodrop shouldn't affect lewd items.
target.vars[item_index] = null
else if (new_item)
source.visible_message(span_purple("[source.name] [internal ? "inserts" : "attaches"] the [new_item.name] [into_or_onto] [target.name]'s [item_index]."), span_purple("You [insert_or_attach] the [new_item.name] [into_or_onto] [target.name]'s [item_index]."), span_purple("You hear someone [insert_or_attach] something [into_or_onto] someone nearby."), vision_distance = 1)
target.vars[item_index] = new_item
new_item.forceMove(target)
target.update_inv_lewd()
else
source.show_message(span_warning("Failed to adjust [target.name]'s toys!"))
return TRUE
message_admins("Unhandled interaction '[params["interaction"]]'. Inform coders.")
/// Checks if the target has ERP toys enabled, and can be logially reached by the user.
/datum/component/interactable/proc/can_lewd_strip(mob/living/carbon/human/source, mob/living/carbon/human/target, slot_index)
if(!target.client?.prefs?.read_preference(/datum/preference/toggle/erp/sex_toy))
return FALSE
if(!(source.loc == target.loc || source.Adjacent(target)))
return FALSE
if(!source.has_arms())
return FALSE
if(!slot_index) // This condition is for the UI to decide if the button is shown at all. Slot index should never be null otherwise.
return TRUE
if(slot_index == ORGAN_SLOT_NIPPLES && !target.is_topless())
return FALSE
return target.is_bottomless()
/// Decides if a player should be able to insert or remove an item from a provided lewd slot_index.
/datum/component/interactable/proc/is_toy_compatible(obj/item/clothing/sextoy/item, slot_index)
if(!item) // Used for UI code, should never be actually null during actual logic code.
return TRUE
switch(slot_index)
if(ORGAN_SLOT_VAGINA)
return item.lewd_slot_flags & LEWD_SLOT_VAGINA
if(ORGAN_SLOT_PENIS)
return item.lewd_slot_flags & LEWD_SLOT_PENIS
if(ORGAN_SLOT_ANUS)
return item.lewd_slot_flags & LEWD_SLOT_ANUS
if(ORGAN_SLOT_NIPPLES)
return item.lewd_slot_flags & LEWD_SLOT_NIPPLES
else
return FALSE