mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Merge pull request #2562 from Neerti/9/29/2016_circuits
More Circuit Ports by Psi
This commit is contained in:
@@ -42,10 +42,10 @@
|
||||
..()
|
||||
|
||||
/obj/item/integrated_circuit/proc/setup_io(var/list/io_list, var/io_type)
|
||||
var/list/names = io_list.Copy()
|
||||
var/list/io_list_copy = io_list.Copy()
|
||||
io_list.Cut()
|
||||
for(var/name in names)
|
||||
io_list.Add(new io_type(src, name))
|
||||
for(var/io_entry in io_list_copy)
|
||||
io_list.Add(new io_type(src, io_entry, io_list_copy[io_entry]))
|
||||
|
||||
/obj/item/integrated_circuit/proc/on_data_written() //Override this for special behaviour when new data gets pushed to the circuit.
|
||||
return
|
||||
@@ -238,13 +238,14 @@
|
||||
/datum/integrated_io
|
||||
var/name = "input/output"
|
||||
var/obj/item/integrated_circuit/holder = null
|
||||
var/data = null
|
||||
var/weakref/data = null // This is a weakref, to reduce typecasts. Note that oftentimes numbers and text may also occupy this.
|
||||
var/list/linked = list()
|
||||
var/io_type = DATA_CHANNEL
|
||||
|
||||
/datum/integrated_io/New(var/newloc, var/name)
|
||||
/datum/integrated_io/New(var/newloc, var/name, var/data)
|
||||
..()
|
||||
src.name = name
|
||||
src.data = data
|
||||
holder = newloc
|
||||
if(!istype(holder))
|
||||
message_admins("ERROR: An integrated_io ([src.name]) spawned without a valid holder! This is a bug.")
|
||||
|
||||
@@ -168,8 +168,9 @@
|
||||
|
||||
if(!isweakref(I.data))
|
||||
return
|
||||
var/weakref/w = I.data
|
||||
var/atom/A = w.resolve()
|
||||
var/atom/A = I.data.resolve()
|
||||
if(!A)
|
||||
return
|
||||
var/desired_type = A.type
|
||||
|
||||
var/list/nearby_things = range(1, get_turf(src))
|
||||
@@ -216,7 +217,7 @@
|
||||
/obj/item/integrated_circuit/input/signaler/on_data_written()
|
||||
var/datum/integrated_io/new_freq = inputs[1]
|
||||
var/datum/integrated_io/new_code = inputs[2]
|
||||
if(isnum(new_freq.data))
|
||||
if(isnum(new_freq.data) && new_freq.data > 0)
|
||||
set_frequency(new_freq.data)
|
||||
if(isnum(new_code.data))
|
||||
code = new_code.data
|
||||
|
||||
@@ -120,53 +120,42 @@
|
||||
flags = OPENCONTAINER
|
||||
complexity = 20
|
||||
cooldown_per_use = 6 SECONDS
|
||||
inputs = list("target ref", "injection amount")
|
||||
inputs = list("target ref", "injection amount" = 5)
|
||||
outputs = list()
|
||||
activators = list("inject")
|
||||
var/inject_amount = 5
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/injector/New()
|
||||
..()
|
||||
create_reagents(30)
|
||||
var/datum/integrated_io/amount = inputs[2]
|
||||
amount.data = inject_amount
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/injector/on_data_written()
|
||||
/obj/item/integrated_circuit/manipulation/injector/proc/inject_amount()
|
||||
var/datum/integrated_io/amount = inputs[2]
|
||||
if(isnum(amount.data))
|
||||
amount.data = Clamp(amount.data, 0, 30)
|
||||
inject_amount = amount.data
|
||||
return Clamp(amount.data, 0, 30)
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/injector/do_work()
|
||||
set waitfor = 0 // Don't sleep in a proc that is called by a processor without this set, otherwise it'll delay the entire thing
|
||||
|
||||
var/datum/integrated_io/target = inputs[1]
|
||||
var/atom/movable/AM = target.data_as_type(/atom/movable)
|
||||
if(!istype(AM)) //Invalid input
|
||||
return
|
||||
if(!reagents.total_volume) // Empty
|
||||
return
|
||||
if(AM.Adjacent(get_turf(src)))
|
||||
if(!AM.reagents)
|
||||
return
|
||||
if(!AM.is_open_container() && !ismob(AM) )
|
||||
return
|
||||
if(!AM.reagents.get_free_space())
|
||||
return
|
||||
|
||||
if(AM.can_be_injected_by(src))
|
||||
if(isliving(AM))
|
||||
var/mob/living/L = AM
|
||||
if(!L.can_inject(null, 0, BP_TORSO))
|
||||
return
|
||||
loc.visible_message("<span class='warning'>[src] is trying to inject [AM]!</span>")
|
||||
var/turf/T = get_turf(AM)
|
||||
T.visible_message("<span class='warning'>[src] is trying to inject [AM]!</span>")
|
||||
sleep(3 SECONDS)
|
||||
if(!AM.Adjacent(get_turf(src)))
|
||||
if(!AM.can_be_injected_by(src))
|
||||
return
|
||||
var/contained = reagents.get_reagents()
|
||||
var/trans = reagents.trans_to_mob(target, inject_amount, CHEM_BLOOD)
|
||||
message_admins("[src] injected \the [AM] with [trans]u of [english_list(contained)].")
|
||||
var/trans = reagents.trans_to_mob(target, inject_amount(), CHEM_BLOOD)
|
||||
message_admins("[src] injected \the [AM] with [trans]u of [contained].")
|
||||
to_chat(AM, "<span class='notice'>You feel a tiny prick!</span>")
|
||||
visible_message("<span class='warning'>[src] injects [AM]!</span>")
|
||||
else
|
||||
reagents.trans_to(AM, inject_amount)
|
||||
reagents.trans_to(AM, inject_amount())
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/reagent_pump
|
||||
name = "reagent pump"
|
||||
@@ -177,16 +166,11 @@
|
||||
outside the machine if it is next to the machine. Note that this cannot be used on entities."
|
||||
flags = OPENCONTAINER
|
||||
complexity = 8
|
||||
inputs = list("source ref", "target ref", "injection amount")
|
||||
inputs = list("source ref", "target ref", "injection amount" = 10)
|
||||
outputs = list()
|
||||
activators = list("transfer reagents")
|
||||
var/transfer_amount = 10
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/reagent_pump/New()
|
||||
..()
|
||||
var/datum/integrated_io/amount = inputs[3]
|
||||
amount.data = transfer_amount
|
||||
|
||||
/obj/item/integrated_circuit/manipulation/reagent_pump/on_data_written()
|
||||
var/datum/integrated_io/amount = inputs[3]
|
||||
if(isnum(amount.data))
|
||||
@@ -269,11 +253,11 @@
|
||||
/obj/item/integrated_circuit/manipulation/locomotion/do_work()
|
||||
..()
|
||||
var/turf/T = get_turf(src)
|
||||
if(istype(loc, /obj/item/device/electronic_assembly))
|
||||
if(T && istype(loc, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/machine = loc
|
||||
if(machine.anchored || machine.w_class >= ITEMSIZE_LARGE)
|
||||
return
|
||||
if(machine.loc && machine.loc == T) // Check if we're held by someone. If the loc is the floor, we're not held.
|
||||
if(machine.loc == T) // Check if we're held by someone. If the loc is the floor, we're not held.
|
||||
var/datum/integrated_io/wanted_dir = inputs[1]
|
||||
if(isnum(wanted_dir.data))
|
||||
step(machine, wanted_dir.data)
|
||||
14
code/modules/reagents/Chemistry-Reagents-Helpers.dm
Normal file
14
code/modules/reagents/Chemistry-Reagents-Helpers.dm
Normal file
@@ -0,0 +1,14 @@
|
||||
/atom/movable/proc/can_be_injected_by(var/atom/injector)
|
||||
if(!Adjacent(get_turf(injector)))
|
||||
return FALSE
|
||||
if(!reagents)
|
||||
return FALSE
|
||||
if(!reagents.get_free_space())
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/can_be_injected_by(var/atom/injector)
|
||||
return is_open_container() && ..()
|
||||
|
||||
/mob/living/can_be_injected_by(var/atom/injector)
|
||||
return ..() && (can_inject(null, 0, BP_TORSO) || can_inject(null, 0, BP_GROIN))
|
||||
@@ -1844,6 +1844,7 @@
|
||||
#include "code\modules\reagents\Chemistry-Machinery.dm"
|
||||
#include "code\modules\reagents\Chemistry-Metabolism.dm"
|
||||
#include "code\modules\reagents\Chemistry-Readme.dm"
|
||||
#include "code\modules\reagents\Chemistry-Reagents-Helpers.dm"
|
||||
#include "code\modules\reagents\Chemistry-Reagents.dm"
|
||||
#include "code\modules\reagents\Chemistry-Recipes.dm"
|
||||
#include "code\modules\reagents\reagent_containers.dm"
|
||||
|
||||
Reference in New Issue
Block a user