Fixes ai restoration button

Adds an eject button to the restorer UI
This commit is contained in:
Shadowlight213
2016-11-22 13:01:02 -08:00
parent 740c8aef56
commit dddcb116af
4 changed files with 67 additions and 30 deletions
@@ -12,15 +12,22 @@
available_on_ntnet = 1
var/restoring = FALSE
/datum/computer_file/program/aidiag/proc/get_ai()
/datum/computer_file/program/aidiag/proc/get_ai(cardcheck)
var/obj/item/weapon/computer_hardware/ai_slot/ai_slot
if(computer)
ai_slot = computer.all_components[MC_AI]
if(computer && ai_slot && ai_slot.check_functionality() && ai_slot.enabled && ai_slot.stored_card && ai_slot.stored_card.AI)
return ai_slot.stored_card.AI
if(computer && ai_slot && ai_slot.check_functionality())
if(cardcheck == 1)
return ai_slot
if(ai_slot.enabled && ai_slot.stored_card)
if(cardcheck == 2)
return ai_slot.stored_card
if(ai_slot.stored_card.AI)
return ai_slot.stored_card.AI
return null
/datum/computer_file/program/aidiag/ui_act(action, params)
@@ -30,27 +37,40 @@
var/mob/living/silicon/ai/A = get_ai()
if(!A)
restoring = FALSE
return FALSE
switch("action")
switch(action)
if("PRG_beginReconstruction")
if(A.health < 100)
if(A && A.health < 100)
restoring = TRUE
return TRUE
if("PRG_eject")
if(computer.all_components[MC_AI])
var/obj/item/weapon/computer_hardware/ai_slot/ai_slot = computer.all_components[MC_AI]
if(ai_slot && ai_slot.stored_card)
ai_slot.try_eject(0,usr)
return TRUE
/datum/computer_file/program/aidiag/process_tick()
..()
if(!restoring) //Put the check here so we don't check for an ai all the time
return
var/obj/item/device/aicard/cardhold = get_ai(2)
var/obj/item/weapon/computer_hardware/ai_slot/ai_slot = get_ai(1)
var/mob/living/silicon/ai/A = get_ai()
if(!A)
if(!A || !cardhold)
restoring = FALSE // If the AI was removed, stop the restoration sequence.
if(ai_slot)
ai_slot.locked = FALSE
return
var/obj/item/device/aicard/cardhold = A.loc
if(cardhold.flush)
ai_slot.locked = FALSE
restoring = FALSE
return
ai_slot.locked =TRUE
A.adjustOxyLoss(-1, 0)
A.adjustFireLoss(-1, 0)
A.adjustToxLoss(-1, 0)
@@ -60,6 +80,7 @@
A.revive()
// Finished restoring
if(A.health >= 100)
ai_slot.locked = FALSE
restoring = FALSE
return TRUE
@@ -71,19 +92,25 @@
// A shortcut for getting the AI stored inside the computer. The program already does necessary checks.
AI = get_ai()
if(!AI)
data["error"] = "No AI located"
var/obj/item/device/aicard/aicard = get_ai(2)
if(!aicard)
data["nocard"] = TRUE
data["error"] = "Please insert an intelliCard."
else
var/obj/item/device/aicard/cardhold = AI.loc
if(cardhold.flush)
data["error"] = "Flush in progress"
if(!AI)
data["error"] = "No AI located"
else
data["name"] = AI.name
data["restoring"] = restoring
data["laws"] = AI.laws.get_law_list(include_zeroth = 1)
data["health"] = (AI.health + 100) / 2
data["isDead"] = AI.stat == DEAD
data["ai_laws"] = AI.laws.get_law_list(include_zeroth = 1)
var/obj/item/device/aicard/cardhold = AI.loc
if(cardhold.flush)
data["error"] = "Flush in progress"
else
data["name"] = AI.name
data["restoring"] = restoring
data["laws"] = AI.laws.get_law_list(include_zeroth = 1)
data["health"] = (AI.health + 100) / 2
data["isDead"] = AI.stat == DEAD
data["ai_laws"] = AI.laws.get_law_list(include_zeroth = 1)
return data