mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 07:08:00 +01:00
Komponemts
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/// Container item, an item which can be stored by specialized containers.
|
||||
/datum/component/container_item
|
||||
|
||||
/datum/component/container_item/Initialize()
|
||||
. = ..()
|
||||
RegisterSignal(parent, COMSIG_CONTAINER_TRY_ATTACH, .proc/try_attach)
|
||||
|
||||
/// Called when parent is added to the container.
|
||||
/datum/component/container_item/proc/try_attach(datum/source, atom/container, mob/user)
|
||||
return FALSE
|
||||
@@ -0,0 +1,31 @@
|
||||
/// Tank holder item - Added to an object which can be added to a tank holder.
|
||||
/datum/component/container_item/tank_holder
|
||||
var/tank_holder_icon_state
|
||||
var/make_density
|
||||
|
||||
/datum/component/container_item/tank_holder/Initialize(state, density = TRUE)
|
||||
if(!isitem(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
|
||||
tank_holder_icon_state = state
|
||||
make_density = density
|
||||
return ..()
|
||||
|
||||
/datum/component/container_item/tank_holder/try_attach(datum/source, obj/structure/tank_holder/container, mob/user)
|
||||
if(!container || !istype(container))
|
||||
return FALSE
|
||||
var/obj/item/I = parent
|
||||
if(container.contents.len)
|
||||
if(user)
|
||||
to_chat(user, "<span class='warning'>There's already something in [container].</span>")
|
||||
return TRUE
|
||||
if(user)
|
||||
if(!user.transferItemToLoc(I, container))
|
||||
return TRUE
|
||||
to_chat(user, "<span class='notice'>You put [I] into [container].</span>")
|
||||
else
|
||||
I.forceMove(container)
|
||||
container.tank = I
|
||||
container.density = make_density
|
||||
container.icon_state = tank_holder_icon_state
|
||||
return TRUE
|
||||
Reference in New Issue
Block a user