Skip to content

Commit

Permalink
Off button update
Browse files Browse the repository at this point in the history
  • Loading branch information
BogCreature committed Dec 9, 2023
1 parent 81eaffc commit be05c97
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
10 changes: 9 additions & 1 deletion code/datums/components/spawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
var/wave_downtime //Average time until spawning starts again
var/wave_timer
var/downtime_timer
var/current_timerid


/datum/component/spawner/Initialize(_mob_types, _spawn_time, _faction, _spawn_text, _max_mobs, _spawn_sound, _spawn_distance_min, _spawn_distance_max, _wave_length, _wave_downtime)
Expand Down Expand Up @@ -50,11 +51,18 @@
SIGNAL_HANDLER

STOP_PROCESSING(SSprocessing, src)
deltimer(current_timerid)
for(var/mob/living/simple_animal/L in spawned_mobs)
if(L.nest == src)
L.nest = null
spawned_mobs = null

//Different from stop_spawning() as it doesn't untether all mobs from it and is meant for temporarily stopping spawning
/datum/component/spawner/proc/pause_spawning()
STOP_PROCESSING(SSprocessing, src)
deltimer(current_timerid) //Otherwise if spawning is paused while the wave timer is loose it'll just unpause on its own
COOLDOWN_RESET(src, wave_timer)

/datum/component/spawner/proc/unpause_spawning()
START_PROCESSING(SSprocessing, src)

Expand All @@ -69,7 +77,7 @@
if(wave_timer && COOLDOWN_FINISHED(src, wave_timer))
COOLDOWN_RESET(src, wave_timer)
STOP_PROCESSING(SSprocessing, src)
addtimer(CALLBACK(src, PROC_REF(unpause_spawning)), wave_downtime)
current_timerid = addtimer(CALLBACK(src, PROC_REF(unpause_spawning)), wave_downtime, TIMER_STOPPABLE)
return
////////////////////////////////
if(length(spawned_mobs) >= max_mobs)
Expand Down
30 changes: 28 additions & 2 deletions code/modules/mining/drill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
var/power_cost = 100
var/metal_attached
var/missing_part //I hate this but it's better than most the ideas I've had
var/current_timerid

/obj/machinery/drill/examine(mob/user)
. = ..()
Expand All @@ -56,6 +57,7 @@
. += "<span class='notice'>Replacement plating has been secured to [src], but still needs to be <b>welded</b> into place.</span>"
if(machine_stat & BROKEN && !metal_attached)
. += "<span class='notice'>[src]'s structure has been totaled, the <b>plasteel</b> plating needs to be replaced."
. += "<span class='notice'>The manual shutoff switch can be pulled with <b>Alt Click</b>.</span>"

/obj/machinery/drill/Initialize()
. = ..()
Expand Down Expand Up @@ -143,6 +145,9 @@
to_chat(user, "<span class='notice'>You unsecure the [src] from the ore vein.</span>")
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
anchored = FALSE
if(mining.spawner)
STOP_PROCESSING(SSprocessing, mining.spawner)
mining.spawning_started = FALSE
mining = null
update_icon_state()
return
Expand Down Expand Up @@ -210,6 +215,24 @@
return
return ..()

/obj/machinery/drill/AltClick(mob/user)
if(active)
to_chat(user, "<span class='notice'>You begin the manual shutoff process.</span>")
if(do_after(user,10))
active = FALSE
soundloop.stop()
deltimer(current_timerid)
//STOP_PROCESSING(SSprocessing, mining.spawner)
mining.spawner.pause_spawning()
mining.spawning_started = FALSE
playsound(src, 'sound/machines/switch2.ogg', 50, TRUE)
say("Manual shutoff engaged, ceasing mining operations.")
update_icon_state()
update_overlays()
else
to_chat(user, "<span class='notice'>You cancel the manual shutoff process.</span>")
return

//Can we even turn the damn thing on?
/obj/machinery/drill/interact(mob/user, special_state)
. = ..()
Expand Down Expand Up @@ -283,14 +306,17 @@
var/mine_time
active = TRUE
soundloop.start()
if(!mining.spawning_started)
if(!mining.spawner)
mining.begin_spawning()
mining.spawning_started = TRUE
else if(!mining.spawning_started)
START_PROCESSING(SSprocessing, mining.spawner)
mining.spawning_started = TRUE
for(var/obj/item/stock_parts/micro_laser/laser in component_parts)
mine_time = round((300/sqrt(laser.rating))*mining.mine_time_multiplier)
eta = mine_time*mining.mining_charges
cell.use(power_use)
addtimer(CALLBACK(src, PROC_REF(mine)), mine_time)
current_timerid = addtimer(CALLBACK(src, PROC_REF(mine)), mine_time, TIMER_STOPPABLE)
say("Estimated time until vein depletion: [time2text(eta,"mm:ss")].")
update_icon_state()
update_overlays()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mining/ore_veins.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GLOBAL_LIST_EMPTY(ore_veins)
var/faction = list("hostile","mining")
var/spawn_sound = list('sound/effects/break_stone.ogg')
var/spawner_type = /datum/component/spawner
var/spawner
var/datum/component/spawner/spawner
var/spawn_distance_min = 4
var/spawn_distance_max = 6
var/wave_length = 2 MINUTES
Expand Down

0 comments on commit be05c97

Please sign in to comment.