mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-23 03:56:27 +01:00
@@ -0,0 +1,127 @@
|
||||
/obj/machinery/feeder
|
||||
name = "\improper Feeder"
|
||||
icon = 'icons/obj/feeder.dmi'
|
||||
anchored = 0
|
||||
density = 0
|
||||
|
||||
|
||||
/obj/machinery/feeder/var/mob/living/carbon/human/attached = null
|
||||
/obj/machinery/feeder/var/obj/item/weapon/reagent_containers/beaker = null
|
||||
|
||||
/obj/machinery/feeder/update_icon()
|
||||
if(attached)
|
||||
icon_state = "feeding"
|
||||
else
|
||||
icon_state = ""
|
||||
|
||||
overlays = null
|
||||
|
||||
if(beaker)
|
||||
var/datum/reagents/reagents = beaker.reagents
|
||||
if(reagents.total_volume)
|
||||
var/image/filling = image('icons/obj/feeder.dmi', src, "reagent")
|
||||
|
||||
var/percent = round((reagents.total_volume / beaker.volume) * 100)
|
||||
switch(percent)
|
||||
if(0 to 9) filling.icon_state = "reagent0"
|
||||
if(10 to 19) filling.icon_state = "reagent10"
|
||||
if(20 to 44) filling.icon_state = "reagent20"
|
||||
if(45 to 59) filling.icon_state = "reagent45"
|
||||
if(60 to 74) filling.icon_state = "reagent60"
|
||||
if(75 to 89) filling.icon_state = "reagent75"
|
||||
if(90 to 94) filling.icon_state = "reagent90"
|
||||
if(95 to INFINITY) filling.icon_state = "reagent100"
|
||||
|
||||
filling.icon += reagents.get_color()
|
||||
overlays += filling
|
||||
|
||||
/obj/machinery/feeder/MouseDrop(over_object, src_location, over_location)
|
||||
..()
|
||||
if(!isliving(usr))
|
||||
return
|
||||
|
||||
if(attached)
|
||||
visible_message("The feeding tube is pulled out of [attached]")
|
||||
attached = null
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(in_range(src, usr) && ishuman(over_object) && get_dist(over_object, src) <= 1)
|
||||
visible_message("[usr] inserts the feeding tube into \the [over_object].")
|
||||
attached = over_object
|
||||
update_icon()
|
||||
|
||||
|
||||
/obj/machinery/feeder/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
if(istype(W, /obj/item/weapon/reagent_containers))
|
||||
if(!isnull(beaker))
|
||||
user << "There is already a reagent container inserted!"
|
||||
return
|
||||
|
||||
user.drop_item()
|
||||
W.loc = src
|
||||
beaker = W
|
||||
user << "You insert \the [W] into \the [src]."
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/weapon/screwdriver))
|
||||
playsound(src, W.usesound, 50, 1)
|
||||
user << "<span class='notice'>You start to dismantle the feeder.</span>"
|
||||
if(do_after(user, 15))
|
||||
user << "<span class='notice'>You dismantle the feeder.</span>"
|
||||
var/obj/item/stack/material/plastic/A = new /obj/item/stack/material/plastic(src.loc)
|
||||
A.amount = 4
|
||||
if(beaker)
|
||||
beaker.loc = get_turf(src)
|
||||
beaker = null
|
||||
qdel(src)
|
||||
return
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/machinery/feeder/process()
|
||||
set background = 1
|
||||
|
||||
if(attached)
|
||||
|
||||
if(!(get_dist(src, attached) <= 1 && isturf(attached.loc)))
|
||||
visible_message("The tube is pulled out of [attached]")
|
||||
attached = null
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(attached && beaker)
|
||||
// Give food
|
||||
if(beaker.volume > 0)
|
||||
var/transfer_amount = 2
|
||||
beaker.reagents.trans_to_mob(attached, transfer_amount, CHEM_INGEST)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/feeder/attack_hand(mob/user as mob)
|
||||
if(beaker)
|
||||
beaker.loc = get_turf(src)
|
||||
beaker = null
|
||||
update_icon()
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/feeder/examine(mob/user)
|
||||
..(user)
|
||||
if(!(user in view(2)) && user != src.loc) return
|
||||
|
||||
if(beaker)
|
||||
if(beaker.reagents && beaker.reagents.reagent_list.len)
|
||||
usr << "<span class='notice'>Inserted is \a [beaker] with [beaker.reagents.total_volume] units of liquid.</span>"
|
||||
else
|
||||
usr << "<span class='notice'>Inserted is an empty [beaker].</span>"
|
||||
else
|
||||
usr << "<span class='notice'>No container is inserted.</span>"
|
||||
|
||||
usr << "<span class='notice'>[attached ? attached : "No one"] is being feed by it.</span>"
|
||||
|
||||
/obj/machinery/feeder/CanPass(atom/movable/mover, turf/target, height = 0, air_group = 0)
|
||||
if(height && istype(mover) && mover.checkpass(PASSTABLE)) //allow bullets, beams, thrown objects, mice, drones, and the like through.
|
||||
return 1
|
||||
return ..()
|
||||
Reference in New Issue
Block a user