mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 12:07:27 +01:00
Fixes Garbage Collection issues with Xenobiology (#20190)
* xenobio gc fixes * requested changes * requested changes
This commit is contained in:
@@ -3,27 +3,38 @@
|
||||
visible_icon = 1
|
||||
icon = 'icons/obj/abductor.dmi'
|
||||
icon_state = "camera_target"
|
||||
var/allowed_area = null
|
||||
// The Xenobio Console does not trigger the AI Detector
|
||||
ai_detector_visible = FALSE
|
||||
/// Area that the xenobio camera eye is allowed to travel
|
||||
var/allowed_area = null
|
||||
|
||||
/mob/camera/aiEye/remote/xenobio/New(loc)
|
||||
/mob/camera/aiEye/remote/xenobio/Initialize(mapload)
|
||||
. = ..()
|
||||
var/area/A = get_area(loc)
|
||||
allowed_area = A.name
|
||||
..()
|
||||
|
||||
/mob/camera/aiEye/remote/xenobio/setLoc(t)
|
||||
var/area/new_area = get_area(t)
|
||||
if(new_area && new_area.name == allowed_area || new_area && new_area.xenobiology_compatible)
|
||||
return ..()
|
||||
else
|
||||
if(!new_area)
|
||||
return
|
||||
if(new_area.name != allowed_area && !new_area.xenobiology_compatible)
|
||||
return
|
||||
return ..()
|
||||
|
||||
/*
|
||||
* # Slime Management Console
|
||||
*
|
||||
* Camera overview console for xenobiology, handles slime management and xenobio actions
|
||||
*/
|
||||
/obj/machinery/computer/camera_advanced/xenobio
|
||||
name = "slime management console"
|
||||
desc = "A computer used for remotely handling slimes."
|
||||
icon_screen = "slime_comp"
|
||||
icon_keyboard = "rd_key"
|
||||
networks = list("SS13")
|
||||
circuit = /obj/item/circuitboard/xenobiology
|
||||
|
||||
|
||||
var/datum/action/innate/slime_place/slime_place_action = new
|
||||
var/datum/action/innate/slime_pick_up/slime_up_action = new
|
||||
var/datum/action/innate/feed_slime/feed_slime_action = new
|
||||
@@ -38,19 +49,17 @@
|
||||
var/obj/item/slimepotion/slime/current_potion
|
||||
var/obj/machinery/monkey_recycler/connected_recycler
|
||||
|
||||
icon_screen = "slime_comp"
|
||||
icon_keyboard = "rd_key"
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/Initialize(mapload)
|
||||
..()
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
. = ..()
|
||||
if(!connected_recycler)
|
||||
locate_recycler()
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/LateInitialize()
|
||||
..()
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/locate_recycler()
|
||||
for(var/obj/machinery/monkey_recycler/recycler in GLOB.monkey_recyclers)
|
||||
if(get_area(recycler.loc) == get_area(loc))
|
||||
if(get_area(recycler) == get_area(loc))
|
||||
connected_recycler = recycler
|
||||
connected_recycler.connected += src
|
||||
connected_recycler.connected |= src
|
||||
break
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/Destroy()
|
||||
QDEL_NULL(current_potion)
|
||||
@@ -73,7 +82,7 @@
|
||||
/obj/machinery/computer/camera_advanced/xenobio/CreateEye()
|
||||
eyeobj = new /mob/camera/aiEye/remote/xenobio(get_turf(src))
|
||||
eyeobj.origin = src
|
||||
eyeobj.visible_icon = 1
|
||||
eyeobj.visible_icon = TRUE
|
||||
eyeobj.acceleration = FALSE
|
||||
eyeobj.icon = 'icons/obj/abductor.dmi'
|
||||
eyeobj.icon_state = "camera_target"
|
||||
@@ -124,10 +133,7 @@
|
||||
RegisterSignal(user, COMSIG_XENO_MONKEY_CLICK_CTRL, PROC_REF(XenoMonkeyClickCtrl))
|
||||
|
||||
if(!connected_recycler)
|
||||
for(var/obj/machinery/monkey_recycler/recycler in GLOB.monkey_recyclers)
|
||||
if(get_area(recycler.loc) == get_area(loc))
|
||||
connected_recycler = recycler
|
||||
connected_recycler.connected += src
|
||||
locate_recycler()
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/remove_eye_control(mob/living/user)
|
||||
UnregisterSignal(user, COMSIG_XENO_SLIME_CLICK_CTRL)
|
||||
@@ -138,6 +144,33 @@
|
||||
UnregisterSignal(user, COMSIG_XENO_MONKEY_CLICK_CTRL)
|
||||
..()
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/insert_potion(obj/item/slimepotion/slime/potion)
|
||||
clear_potion()
|
||||
potion.forceMove(src)
|
||||
current_potion = potion
|
||||
RegisterSignal(current_potion, COMSIG_PARENT_QDELETING, PROC_REF(clear_potion))
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/clear_potion()
|
||||
if(!QDELETED(current_potion))
|
||||
current_potion.forceMove(drop_location())
|
||||
UnregisterSignal(current_potion, COMSIG_PARENT_QDELETING)
|
||||
current_potion = null
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/capture_slime(mob/living/simple_animal/slime/slime)
|
||||
slime.visible_message("<span class='notice'>[slime] vanishes in a flash of light!</span>")
|
||||
slime.forceMove(src)
|
||||
stored_slimes += slime
|
||||
RegisterSignal(slime, COMSIG_PARENT_QDELETING, PROC_REF(clear_slime))
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/release_slime(mob/living/simple_animal/slime/slime, release_spot)
|
||||
slime.visible_message("<span class='notice'>[slime] warps in!</span>")
|
||||
clear_slime(slime)
|
||||
slime.forceMove(release_spot)
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/clear_slime(mob/living/simple_animal/slime/slime)
|
||||
UnregisterSignal(slime, COMSIG_PARENT_QDELETING)
|
||||
stored_slimes -= slime
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/attack_hand(mob/user)
|
||||
if(!ishuman(user)) //AIs using it might be weird
|
||||
return
|
||||
@@ -151,13 +184,10 @@
|
||||
qdel(O)
|
||||
return
|
||||
else if(istype(O, /obj/item/slimepotion/slime))
|
||||
var/replaced = FALSE
|
||||
if(user.drop_item())
|
||||
if(!QDELETED(current_potion))
|
||||
current_potion.forceMove(drop_location())
|
||||
replaced = TRUE
|
||||
current_potion = O
|
||||
to_chat(user, "<span class='notice'>You load [O] in the console's potion slot[replaced ? ", replacing the one that was there before" : ""].</span>")
|
||||
if(!user.drop_item())
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You load [O] in the console's potion slot[current_potion ? ", replacing the one that was there before" : ""].</span>")
|
||||
insert_potion(O, user)
|
||||
return
|
||||
else if(istype(O, /obj/item/storage/bag) || istype(O, /obj/item/storage/box))
|
||||
var/obj/item/storage/P = O
|
||||
@@ -184,6 +214,7 @@
|
||||
connected_recycler.connected += src
|
||||
to_chat(user, "<span class='notice'>You link [src] to the recycler stored in [M]'s buffer.</span>")
|
||||
|
||||
// === SLIME ACTION DATUMS ====
|
||||
/datum/action/innate/slime_place
|
||||
name = "Place Slimes"
|
||||
button_icon_state = "slime_down"
|
||||
@@ -200,9 +231,7 @@
|
||||
return
|
||||
else if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
|
||||
for(var/mob/living/simple_animal/slime/S in X.stored_slimes)
|
||||
S.forceMove(remote_eye.loc)
|
||||
S.visible_message("[S] warps in!")
|
||||
X.stored_slimes -= S
|
||||
X.release_slime(S, remote_eye.loc)
|
||||
else
|
||||
to_chat(owner, "<span class='notice'>Target is not near a camera. Cannot proceed.</span>")
|
||||
|
||||
@@ -219,14 +248,12 @@
|
||||
|
||||
if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
|
||||
for(var/mob/living/simple_animal/slime/S in remote_eye.loc)
|
||||
if(X.stored_slimes.len >= X.max_slimes)
|
||||
if(length(X.stored_slimes) >= X.max_slimes)
|
||||
break
|
||||
if(!S.ckey)
|
||||
if(S.buckled)
|
||||
S.Feedstop(silent = TRUE)
|
||||
S.visible_message("<span class='notice'>[S] vanishes in a flash of light!</span>")
|
||||
S.forceMove(X)
|
||||
X.stored_slimes += S
|
||||
X.capture_slime(S)
|
||||
else
|
||||
to_chat(owner, "<span class='notice'>Target is not near a camera. Cannot proceed.</span>")
|
||||
|
||||
@@ -280,7 +307,7 @@
|
||||
if(issmall(M) && M.stat)
|
||||
M.visible_message("[M] vanishes as [M.p_theyre()] reclaimed for recycling!")
|
||||
recycler.use_power(500)
|
||||
X.monkeys = round(X.monkeys + recycler.cube_production/recycler.required_grind, 0.1)
|
||||
X.monkeys = round(X.monkeys + recycler.cube_production / recycler.required_grind, 0.1)
|
||||
qdel(M)
|
||||
else
|
||||
to_chat(owner, "<span class='notice'>Target is not near a camera. Cannot proceed.</span>")
|
||||
@@ -331,12 +358,12 @@
|
||||
/datum/action/innate/hotkey_help/Activate()
|
||||
if(!target || !isliving(owner))
|
||||
return
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = owner.machine
|
||||
to_chat(owner, "<b>Click shortcuts:</b>")
|
||||
to_chat(owner, "Shift-click a slime to pick it up, or the floor to drop all held slimes.")
|
||||
to_chat(owner, "Ctrl-click a slime to scan it.")
|
||||
to_chat(owner, "Alt-click a slime to feed it a potion.")
|
||||
to_chat(owner, "Ctrl-click or a dead monkey to recycle it, or the floor to place a new monkey.")
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = owner.machine
|
||||
to_chat(owner, "[X] now has [X.monkeys] monkeys left.")
|
||||
|
||||
//
|
||||
@@ -393,7 +420,7 @@
|
||||
var/mob/camera/aiEye/remote/xenobio/E = C.remote_control
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = E.origin
|
||||
var/area/mobarea = get_area(S.loc)
|
||||
if(QDELETED(X.current_potion))
|
||||
if(!X.current_potion)
|
||||
to_chat(C, "<span class='warning'>No potion loaded.</span>")
|
||||
return
|
||||
if(mobarea.name == E.allowed_area || mobarea.xenobiology_compatible)
|
||||
@@ -409,7 +436,7 @@
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = E.origin
|
||||
var/area/mobarea = get_area(S.loc)
|
||||
if(mobarea.name == E.allowed_area || mobarea.xenobiology_compatible)
|
||||
if(X.stored_slimes.len >= X.max_slimes)
|
||||
if(length(X.stored_slimes) >= X.max_slimes)
|
||||
to_chat(C, "<span class='warning'>Slime storage is full.</span>")
|
||||
return
|
||||
if(S.ckey)
|
||||
@@ -417,9 +444,8 @@
|
||||
return
|
||||
if(S.buckled)
|
||||
S.Feedstop(silent = TRUE)
|
||||
S.visible_message("<span class='notice'>[S] vanishes in a flash of light!</span>")
|
||||
S.forceMove(X)
|
||||
X.stored_slimes += S
|
||||
|
||||
X.capture_slime(S)
|
||||
|
||||
//Place slimes
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/XenoTurfClickShift(mob/living/user, turf/T)
|
||||
@@ -435,9 +461,7 @@
|
||||
return
|
||||
else if(turfarea.name == E.allowed_area || turfarea.xenobiology_compatible)
|
||||
for(var/mob/living/simple_animal/slime/S in X.stored_slimes)
|
||||
S.forceMove(T)
|
||||
S.visible_message("<span class='notice'>[S] warps in!</span>")
|
||||
X.stored_slimes -= S
|
||||
X.release_slime(S, T)
|
||||
|
||||
//Place monkey
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/XenoTurfClickCtrl(mob/living/user, turf/T)
|
||||
@@ -455,7 +479,7 @@
|
||||
if(X.monkeys >= 1)
|
||||
var/mob/living/carbon/human/monkey/food = new /mob/living/carbon/human/monkey(T)
|
||||
food.LAssailant = C
|
||||
X.monkeys --
|
||||
X.monkeys--
|
||||
X.monkeys = round(X.monkeys, 0.1)
|
||||
to_chat(user, "[X] now has [X.monkeys] monkeys left.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user