//Tinkerer's cache: Stores components for later use.
/obj/structure/destructible/clockwork/cache
name = "tinkerer's cache"
desc = "A large brass spire with a flaming hole in its center."
clockwork_desc = "A brass container capable of storing a large amount of components.\n\
Shares components with all other caches and will gradually generate components if near a Clockwork Wall."
icon_state = "tinkerers_cache"
unanchored_icon = "tinkerers_cache_unwrenched"
construction_value = 10
break_message = "The cache's fire winks out before it falls in on itself!"
max_integrity = 80
obj_integrity = 80
light_color = "#C2852F"
var/wall_generation_cooldown
var/turf/closed/wall/clockwork/linkedwall //if we've got a linked wall and are producing
var/static/linked_caches = 0 //how many caches are linked to walls; affects how fast components are produced
/obj/structure/destructible/clockwork/cache/Initialize()
. = ..()
START_PROCESSING(SSobj, src)
GLOB.clockwork_caches++
update_slab_info()
set_light(2, 0.7)
/obj/structure/destructible/clockwork/cache/Destroy()
GLOB.clockwork_caches--
update_slab_info()
STOP_PROCESSING(SSobj, src)
if(linkedwall)
linked_caches--
linkedwall.linkedcache = null
linkedwall = null
return ..()
/obj/structure/destructible/clockwork/cache/process()
if(!anchored)
if(linkedwall)
linked_caches--
linkedwall.linkedcache = null
linkedwall = null
return
for(var/turf/closed/wall/clockwork/C in range(4, src))
if(!C.linkedcache && !linkedwall)
linked_caches++
C.linkedcache = src
linkedwall = C
wall_generation_cooldown = world.time + get_production_time()
visible_message("[src] starts to whirr in the presence of [C]...")
break
if(linkedwall && wall_generation_cooldown <= world.time)
wall_generation_cooldown = world.time + get_production_time()
var/component_id = generate_cache_component(null, src)
playsound(linkedwall, 'sound/magic/clockwork/fellowship_armory.ogg', rand(15, 20), 1, -3, 1, 1)
visible_message("Something cl[pick("ank", "ink", "unk", "ang")]s around inside of [src]...")
/obj/structure/destructible/clockwork/cache/attackby(obj/item/I, mob/living/user, params)
if(!is_servant_of_ratvar(user))
return ..()
if(istype(I, /obj/item/clockwork/component))
var/obj/item/clockwork/component/C = I
if(!anchored)
to_chat(user, "[src] needs to be secured to place [C] into it!")
else
GLOB.clockwork_component_cache[C.component_id]++
update_slab_info()
to_chat(user, "You add [C] to [src].")
user.drop_item()
qdel(C)
return 1
else if(istype(I, /obj/item/clockwork/slab))
var/obj/item/clockwork/slab/S = I
if(!anchored)
to_chat(user, "[src] needs to be secured to offload your slab's components into it!")
else
for(var/i in S.stored_components)
GLOB.clockwork_component_cache[i] += S.stored_components[i]
S.stored_components[i] = 0
update_slab_info()
user.visible_message("[user] empties [S] into [src].", "You offload your slab's components into [src].")
return 1
else
return ..()
/obj/structure/destructible/clockwork/cache/update_anchored(mob/user, do_damage)
..()
if(anchored)
set_light(2, 0.7)
else
set_light(0)
/obj/structure/destructible/clockwork/cache/attack_hand(mob/living/user)
..()
if(is_servant_of_ratvar(user))
if(linkedwall)
if(wall_generation_cooldown > world.time)
var/temp_time = (wall_generation_cooldown - world.time) * 0.1
to_chat(user, "[src] will produce a component in [temp_time] second[temp_time == 1 ? "":"s"].")
else
to_chat(user, "[src] is about to produce a component!")
else if(anchored)
to_chat(user, "[src] is unlinked! Construct a Clockwork Wall nearby to generate components!")
else
to_chat(user, "[src] needs to be secured to generate components!")
/obj/structure/destructible/clockwork/cache/examine(mob/user)
..()
if(is_servant_of_ratvar(user) || isobserver(user))
if(linkedwall)
to_chat(user, "It is linked to a Clockwork Wall and will generate a component every [round(get_production_time() * 0.1, 0.1)] seconds!")
else
to_chat(user, "It is unlinked! Construct a Clockwork Wall nearby to generate components!")
to_chat(user, "Stored components:")
for(var/i in GLOB.clockwork_component_cache)
to_chat(user, "[get_component_name(i)][i != REPLICANT_ALLOY ? "s":""]: [GLOB.clockwork_component_cache[i]]")
/obj/structure/destructible/clockwork/cache/proc/get_production_time()
return (CACHE_PRODUCTION_TIME + (ACTIVE_CACHE_SLOWDOWN * linked_caches)) * get_efficiency_mod(TRUE)