From 02c83dcd8a06c65cf430fc27f160829a52a82fa5 Mon Sep 17 00:00:00 2001
From: SkyratBot <59378654+SkyratBot@users.noreply.github.com>
Date: Wed, 6 Jan 2021 02:26:01 +0100
Subject: [PATCH] [MIRROR] Allows you to tuck the nuclear authentication disk
(and plushes) into bed. (#2515)
* Allows you to tuck the nuclear authentication disk (and plushes) into bed. (#55940)
Adds an element, the tuckable element. Objects with this element can be tucked into bed by hitting a bed with it.
You can now make beds by hitting them with a blanket.
You can now tuck plushes into bed.
You can now tuck the disk into bed, too.
* Allows you to tuck the nuclear authentication disk (and plushes) into bed.
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
---
code/datums/elements/bed_tucking.dm | 60 +++++++++++++++++++
code/game/objects/items/plushes.dm | 1 +
code/game/objects/structures/bedsheet_bin.dm | 1 +
.../nukeop/equipment/nuclearbomb.dm | 13 ++++
tgstation.dme | 1 +
5 files changed, 76 insertions(+)
create mode 100644 code/datums/elements/bed_tucking.dm
diff --git a/code/datums/elements/bed_tucking.dm b/code/datums/elements/bed_tucking.dm
new file mode 100644
index 00000000000..10135871a7a
--- /dev/null
+++ b/code/datums/elements/bed_tucking.dm
@@ -0,0 +1,60 @@
+/// Tucking element, for things that can be tucked into bed.
+/datum/element/bed_tuckable
+ element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
+ id_arg_index = 2
+ /// our pixel_x offset - how much the item moves x when in bed (+x is closer to the pillow)
+ var/x_offset = 0
+ /// our pixel_y offset - how much the item move y when in bed (-y is closer to the middle)
+ var/y_offset = 0
+ /// our rotation degree - how much the item turns when in bed (+degrees turns it more parallel)
+ var/rotation_degree = 0
+
+/datum/element/bed_tuckable/Attach(obj/target, x = 0, y = 0, rotation = 0)
+ . = ..()
+ if(!isitem(target))
+ return ELEMENT_INCOMPATIBLE
+
+ x_offset = x
+ y_offset = y
+ rotation_degree = rotation
+ RegisterSignal(target, COMSIG_ITEM_ATTACK_OBJ, .proc/tuck_into_bed)
+
+/datum/element/bed_tuckable/Detach(obj/target)
+ . = ..()
+ UnregisterSignal(target, list(COMSIG_ITEM_ATTACK_OBJ, COMSIG_ITEM_PICKUP))
+
+/**
+ * Tuck our object into bed.
+ *
+ * tucked - the object being tucked
+ * target_bed - the bed we're tucking them into
+ * tucker - the guy doing the tucking
+ */
+/datum/element/bed_tuckable/proc/tuck_into_bed(obj/item/tucked, obj/structure/bed/target_bed, mob/living/tucker)
+ SIGNAL_HANDLER
+
+ if(!istype(target_bed))
+ return
+
+ if(!tucker.transferItemToLoc(tucked, target_bed.drop_location()))
+ return
+
+ to_chat(tucker, "You lay [tucked] out on [target_bed].")
+ tucked.pixel_x = x_offset
+ tucked.pixel_y = y_offset
+ if(rotation_degree)
+ tucked.transform = turn(tucked.transform, rotation_degree)
+ RegisterSignal(tucked, COMSIG_ITEM_PICKUP, .proc/untuck)
+
+ return COMPONENT_NO_AFTERATTACK
+
+/**
+ * If we rotate our object, then we need to un-rotate it when it's picked up
+ *
+ * tucked - the object that is tucked
+ */
+/datum/element/bed_tuckable/proc/untuck(obj/item/tucked)
+ SIGNAL_HANDLER
+
+ tucked.transform = turn(tucked.transform, -rotation_degree)
+ UnregisterSignal(tucked, COMSIG_ITEM_PICKUP)
diff --git a/code/game/objects/items/plushes.dm b/code/game/objects/items/plushes.dm
index a56ad2644ac..20109c001a6 100644
--- a/code/game/objects/items/plushes.dm
+++ b/code/game/objects/items/plushes.dm
@@ -37,6 +37,7 @@
/obj/item/toy/plush/Initialize()
. = ..()
AddComponent(/datum/component/squeak, squeak_override)
+ AddElement(/datum/element/bed_tuckable, 6, -5, 90)
//have we decided if Pinocchio goes in the blue or pink aisle yet?
if(gender == NEUTER)
diff --git a/code/game/objects/structures/bedsheet_bin.dm b/code/game/objects/structures/bedsheet_bin.dm
index 5780b728f5d..d5ea41adc9f 100644
--- a/code/game/objects/structures/bedsheet_bin.dm
+++ b/code/game/objects/structures/bedsheet_bin.dm
@@ -27,6 +27,7 @@ LINEN BINS
/obj/item/bedsheet/Initialize(mapload)
. = ..()
AddComponent(/datum/component/surgery_initiator, null)
+ AddElement(/datum/element/bed_tuckable, 0, 0, 0)
/obj/item/bedsheet/attack_self(mob/user)
if(!user.CanReach(src)) //No telekenetic grabbing.
diff --git a/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm b/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm
index b7d07548a29..321a093148e 100644
--- a/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm
+++ b/code/modules/antagonists/nukeop/equipment/nuclearbomb.dm
@@ -634,6 +634,8 @@ This is here to make the tiles around the station mininuke change when it's arme
/obj/item/disk/nuclear/Initialize()
. = ..()
+ AddElement(/datum/element/bed_tuckable, 6, -6, 0)
+
if(!fake)
AddElement(/datum/element/point_of_interest)
last_disk_move = world.time
@@ -648,12 +650,23 @@ This is here to make the tiles around the station mininuke change when it's arme
STOP_PROCESSING(SSobj, src)
CRASH("A fake nuke disk tried to call process(). Who the fuck and how the fuck")
var/turf/newturf = get_turf(src)
+
if(newturf && lastlocation == newturf)
+ /// How comfy is our disk?
+ var/disk_comfort_level = 0
+
+ //Go through and check for items that make disk comfy
+ for(var/obj/comfort_item in loc)
+ if(istype(comfort_item, /obj/item/bedsheet) || istype(comfort_item, /obj/structure/bed))
+ disk_comfort_level++
+
if(last_disk_move < world.time - 5000 && prob((world.time - 5000 - last_disk_move)*0.0001))
var/datum/round_event_control/operative/loneop = locate(/datum/round_event_control/operative) in SSevents.control
if(istype(loneop) && loneop.occurrences < loneop.max_occurrences)
loneop.weight += 1
if(loneop.weight % 5 == 0 && SSticker.totalPlayers > 1)
+ if(disk_comfort_level >= 2)
+ visible_message("[src] sleeps soundly. Sleep tight, disky.")
message_admins("[src] is stationary in [ADMIN_VERBOSEJMP(newturf)]. The weight of Lone Operative is now [loneop.weight].")
log_game("[src] is stationary for too long in [loc_name(newturf)], and has increased the weight of the Lone Operative event to [loneop.weight].")
diff --git a/tgstation.dme b/tgstation.dme
index d08a2af1696..68f402732c9 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -603,6 +603,7 @@
#include "code\datums\diseases\advance\symptoms\youth.dm"
#include "code\datums\elements\_element.dm"
#include "code\datums\elements\art.dm"
+#include "code\datums\elements\bed_tucking.dm"
#include "code\datums\elements\bsa_blocker.dm"
#include "code\datums\elements\cleaning.dm"
#include "code\datums\elements\decal.dm"