Xenoarch Core Sampler fixes (#25962)

Cleaned up the code to be less awful.
Fixed "can't re-insert bags into core sampler"
Fixed examine text always listing it as empty.
Fixed the bags sprite not correctly clearing when you empty them.
Made a subtype of evidence bag for the core sampler.
Fixed a while bunch of formatting problems too probably.

Fixes #25631 fixes #25629 fixes #24973 fixes #22579 fixes #20515
This commit is contained in:
Pieter-Jan Briers
2020-03-09 10:40:03 +01:00
committed by GitHub
parent 78bbfa0ff7
commit 018be1cff0

View File

@@ -1,3 +1,4 @@
#define MAX_STORED_BAGS 10
//device to take core samples from mineral turfs - used for various types of analysis
/obj/item/weapon/storage/box/samplebags
@@ -6,11 +7,8 @@
/obj/item/weapon/storage/box/samplebags/New()
for(var/i=0, i<7, i++)
var/obj/item/weapon/storage/evidencebag/S = new(src)
S.name = "sample bag"
S.desc = "a bag for holding research samples."
new/obj/item/weapon/storage/evidencebag/sample(src)
..()
return
//////////////////////////////////////////////////////////////////
@@ -23,29 +21,33 @@
w_class = W_CLASS_TINY
flags = FPRINT
//slot_flags = SLOT_BELT
var/sampled_turf = ""
var/num_stored_bags = 10
var/obj/item/weapon/storage/evidencebag/filled_bag
var/num_stored_bags = MAX_STORED_BAGS
var/obj/item/weapon/storage/evidencebag/sample/filled_bag
/obj/item/device/core_sampler/examine(mob/user)
..()
if(get_dist(src, user) < 2)
to_chat(user, "<span class='info'>This one is [sampled_turf ? "full" : "empty"], and has [num_stored_bags] bag[num_stored_bags != 1 ? "s" : ""] remaining.</span>")
to_chat(user, "<span class='info'>This one is [filled_bag ? "full" : "empty"], and has [num_stored_bags] bag[num_stored_bags != 1 ? "s" : ""] remaining.</span>")
/obj/item/device/core_sampler/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W,/obj/item/weapon/storage/evidencebag))
if(num_stored_bags < 10)
to_chat(user, "<span class='notice'>You insert the [W] into the core sampler.</span>")
qdel(W)
W = null
num_stored_bags += 1
return 1
else
to_chat(user, "<span class='warning'>The core sampler can not fit any more bags!</span>")
/obj/item/device/core_sampler/attackby(obj/item/weapon/W, mob/user)
if(istype(W,/obj/item/weapon/storage/evidencebag/sample))
insert_bag_maybe(W, user)
return TRUE
else
return ..()
/obj/item/device/core_sampler/proc/sample_item(var/item_to_sample, var/mob/user as mob)
/obj/item/device/core_sampler/proc/insert_bag_maybe(obj/item/weapon/storage/evidencebag/sample/W, mob/user)
if(num_stored_bags >= MAX_STORED_BAGS)
to_chat(user, "<span class='warning'>\The [src] can not fit any more bags!</span>")
else if (W.contents.len > 0)
to_chat(user, "<span class='warning'>Empty the bag first!</span>")
else
to_chat(user, "<span class='notice'>You insert \the [W] into \the [src].</span>")
qdel(W)
num_stored_bags += 1
/obj/item/device/core_sampler/proc/sample_item(var/item_to_sample, var/mob/user)
var/datum/geosample/geo_data
if(istype(item_to_sample, /turf/unsimulated/mineral))
var/turf/unsimulated/mineral/T = item_to_sample
@@ -57,14 +59,12 @@
if(geo_data)
if(filled_bag)
to_chat(user, "<span class='warning'>The core sampler is full!</span>")
to_chat(user, "<span class='warning'>\The [src] is full!</span>")
else if(num_stored_bags < 1)
to_chat(user, "<span class='warning'>The core sampler is out of sample bags!</span>")
to_chat(user, "<span class='warning'>\The [src] is out of sample bags!</span>")
else
//create a new sample bag which we'll fill with rock samples
filled_bag = new /obj/item/weapon/storage/evidencebag(src)
filled_bag.name = "sample bag"
filled_bag.desc = "a bag for holding research samples."
filled_bag = new /obj/item/weapon/storage/evidencebag/sample(src)
icon_state = "sampler1"
num_stored_bags--
@@ -74,20 +74,15 @@
R.geological_data = geo_data
R.forceMove(filled_bag)
//update the sample bag
filled_bag.icon_state = "evidence"
var/image/I = image("icon"=R, "layer"=FLOAT_LAYER)
I.plane = FLOAT_PLANE
filled_bag.underlays += I
filled_bag.w_class = W_CLASS_TINY
filled_bag.update_icon()
to_chat(user, "<span class='notice'>You take a core sample of the [item_to_sample].</span>")
to_chat(user, "<span class='notice'>You take a core sample of \the [item_to_sample].</span>")
else
to_chat(user, "<span class='warning'>You are unable to take a sample of [item_to_sample].</span>")
/obj/item/device/core_sampler/attack_self()
/obj/item/device/core_sampler/attack_self(mob/user)
if(filled_bag)
to_chat(usr, "<span class='notice'>You eject the full sample bag.</span>")
to_chat(user, "<span class='notice'>You eject the full sample bag.</span>")
var/success = 0
if(istype(src.loc, /mob))
var/mob/M = src.loc
@@ -97,4 +92,20 @@
filled_bag = null
icon_state = "sampler0"
else
to_chat(usr, "<span class='warning'>The core sampler is empty.</span>")
to_chat(user, "<span class='warning'>The core sampler is empty.</span>")
/obj/item/weapon/storage/evidencebag/sample
name = "sample bag"
desc = "A bag for holding research samples."
use_to_pickup = FALSE
/obj/item/weapon/storage/evidencebag/sample/attackby(obj/item/W, mob/user)
if (istype(W, /obj/item/device/core_sampler))
var/obj/item/device/core_sampler/sampler = W
sampler.insert_bag_maybe(src, user)
return TRUE
return ..()
#undef MAX_STORED_BAGS