|
|
|
@@ -1,160 +1,160 @@
|
|
|
|
|
// TODO: remove the robot.mmi and robot.cell variables and completely rely on the robot component system
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/var/name
|
|
|
|
|
/datum/robot_component/var/installed = 0
|
|
|
|
|
/datum/robot_component/var/powered = 0
|
|
|
|
|
/datum/robot_component/var/toggled = 1
|
|
|
|
|
/datum/robot_component/var/brute_damage = 0
|
|
|
|
|
/datum/robot_component/var/electronics_damage = 0
|
|
|
|
|
/datum/robot_component/var/energy_consumption = 0
|
|
|
|
|
/datum/robot_component/var/max_damage = 30
|
|
|
|
|
/datum/robot_component/var/mob/living/silicon/robot/owner
|
|
|
|
|
|
|
|
|
|
// The actual device object that has to be installed for this.
|
|
|
|
|
/datum/robot_component/var/external_type = null
|
|
|
|
|
|
|
|
|
|
// The wrapped device(e.g. radio), only set if external_type isn't null
|
|
|
|
|
/datum/robot_component/var/obj/item/wrapped = null
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/New(mob/living/silicon/robot/R)
|
|
|
|
|
src.owner = R
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/install()
|
|
|
|
|
/datum/robot_component/proc/uninstall()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/destroy()
|
|
|
|
|
if(wrapped)
|
|
|
|
|
del wrapped
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapped = new/obj/item/broken_device
|
|
|
|
|
|
|
|
|
|
// The thing itself isn't there anymore, but some fried remains are.
|
|
|
|
|
installed = -1
|
|
|
|
|
uninstall()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/take_damage(brute, electronics, sharp)
|
|
|
|
|
if(installed != 1) return
|
|
|
|
|
|
|
|
|
|
brute_damage += brute
|
|
|
|
|
electronics_damage += electronics
|
|
|
|
|
|
|
|
|
|
if(brute_damage + electronics_damage >= max_damage) destroy()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/heal_damage(brute, electronics)
|
|
|
|
|
if(installed != 1)
|
|
|
|
|
// If it's not installed, can't repair it.
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
brute_damage = max(0, brute_damage - brute)
|
|
|
|
|
electronics_damage = max(0, electronics_damage - electronics)
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/is_powered()
|
|
|
|
|
return (installed == 1) && (brute_damage + electronics_damage < max_damage) && (!energy_consumption || powered)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/consume_power()
|
|
|
|
|
if(toggled == 0)
|
|
|
|
|
powered = 0
|
|
|
|
|
return
|
|
|
|
|
if(owner.cell.charge >= energy_consumption)
|
|
|
|
|
owner.cell.use(energy_consumption)
|
|
|
|
|
powered = 1
|
|
|
|
|
else
|
|
|
|
|
powered = 0
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/armour
|
|
|
|
|
name = "armour plating"
|
|
|
|
|
energy_consumption = 0
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/armour
|
|
|
|
|
max_damage = 60
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/actuator
|
|
|
|
|
name = "actuator"
|
|
|
|
|
energy_consumption = 2
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/actuator
|
|
|
|
|
max_damage = 50
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/cell
|
|
|
|
|
name = "power cell"
|
|
|
|
|
max_damage = 50
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/cell/destroy()
|
|
|
|
|
..()
|
|
|
|
|
owner.cell = null
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/radio
|
|
|
|
|
name = "radio"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/radio
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
max_damage = 40
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/binary_communication
|
|
|
|
|
name = "binary communication device"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/binary_communication_device
|
|
|
|
|
energy_consumption = 0
|
|
|
|
|
max_damage = 30
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/camera
|
|
|
|
|
name = "camera"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/camera
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
max_damage = 40
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/diagnosis_unit
|
|
|
|
|
name = "self-diagnosis unit"
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/diagnosis_unit
|
|
|
|
|
max_damage = 30
|
|
|
|
|
|
|
|
|
|
/mob/living/silicon/robot/proc/initialize_components()
|
|
|
|
|
// This only initializes the components, it doesn't set them to installed.
|
|
|
|
|
|
|
|
|
|
components["actuator"] = new/datum/robot_component/actuator(src)
|
|
|
|
|
components["radio"] = new/datum/robot_component/radio(src)
|
|
|
|
|
components["power cell"] = new/datum/robot_component/cell(src)
|
|
|
|
|
components["diagnosis unit"] = new/datum/robot_component/diagnosis_unit(src)
|
|
|
|
|
components["camera"] = new/datum/robot_component/camera(src)
|
|
|
|
|
components["comms"] = new/datum/robot_component/binary_communication(src)
|
|
|
|
|
components["armour"] = new/datum/robot_component/armour(src)
|
|
|
|
|
|
|
|
|
|
/mob/living/silicon/robot/proc/is_component_functioning(module_name)
|
|
|
|
|
var/datum/robot_component/C = components[module_name]
|
|
|
|
|
return C && C.installed == 1 && C.toggled && C.is_powered()
|
|
|
|
|
|
|
|
|
|
/obj/item/broken_device
|
|
|
|
|
name = "broken component"
|
|
|
|
|
icon = 'icons/obj/robot_component.dmi'
|
|
|
|
|
icon_state = "broken"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component
|
|
|
|
|
icon = 'icons/obj/robot_component.dmi'
|
|
|
|
|
icon_state = "working"
|
|
|
|
|
construction_time = 200
|
|
|
|
|
construction_cost = list("metal"=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/binary_communication_device
|
|
|
|
|
name = "binary communication device"
|
|
|
|
|
icon_state = "binary_translator"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/actuator
|
|
|
|
|
name = "actuator"
|
|
|
|
|
icon_state = "actuator"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/armour
|
|
|
|
|
name = "armour plating"
|
|
|
|
|
icon_state = "armor_plating"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/camera
|
|
|
|
|
name = "camera"
|
|
|
|
|
icon_state = "camera"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/diagnosis_unit
|
|
|
|
|
name = "diagnosis unit"
|
|
|
|
|
icon_state = "diagnosis_unit"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/radio
|
|
|
|
|
name = "radio"
|
|
|
|
|
icon_state = "radio"
|
|
|
|
|
// TODO: remove the robot.mmi and robot.cell variables and completely rely on the robot component system
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/var/name
|
|
|
|
|
/datum/robot_component/var/installed = 0
|
|
|
|
|
/datum/robot_component/var/powered = 0
|
|
|
|
|
/datum/robot_component/var/toggled = 1
|
|
|
|
|
/datum/robot_component/var/brute_damage = 0
|
|
|
|
|
/datum/robot_component/var/electronics_damage = 0
|
|
|
|
|
/datum/robot_component/var/energy_consumption = 0
|
|
|
|
|
/datum/robot_component/var/max_damage = 30
|
|
|
|
|
/datum/robot_component/var/mob/living/silicon/robot/owner
|
|
|
|
|
|
|
|
|
|
// The actual device object that has to be installed for this.
|
|
|
|
|
/datum/robot_component/var/external_type = null
|
|
|
|
|
|
|
|
|
|
// The wrapped device(e.g. radio), only set if external_type isn't null
|
|
|
|
|
/datum/robot_component/var/obj/item/wrapped = null
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/New(mob/living/silicon/robot/R)
|
|
|
|
|
src.owner = R
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/install()
|
|
|
|
|
/datum/robot_component/proc/uninstall()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/destroy()
|
|
|
|
|
if(wrapped)
|
|
|
|
|
del wrapped
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapped = new/obj/item/broken_device
|
|
|
|
|
|
|
|
|
|
// The thing itself isn't there anymore, but some fried remains are.
|
|
|
|
|
installed = -1
|
|
|
|
|
uninstall()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/take_damage(brute, electronics, sharp)
|
|
|
|
|
if(installed != 1) return
|
|
|
|
|
|
|
|
|
|
brute_damage += brute
|
|
|
|
|
electronics_damage += electronics
|
|
|
|
|
|
|
|
|
|
if(brute_damage + electronics_damage >= max_damage) destroy()
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/heal_damage(brute, electronics)
|
|
|
|
|
if(installed != 1)
|
|
|
|
|
// If it's not installed, can't repair it.
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
brute_damage = max(0, brute_damage - brute)
|
|
|
|
|
electronics_damage = max(0, electronics_damage - electronics)
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/is_powered()
|
|
|
|
|
return (installed == 1) && (brute_damage + electronics_damage < max_damage) && (!energy_consumption || powered)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/proc/consume_power()
|
|
|
|
|
if(toggled == 0)
|
|
|
|
|
powered = 0
|
|
|
|
|
return
|
|
|
|
|
if(owner.cell.charge >= energy_consumption)
|
|
|
|
|
owner.cell.use(energy_consumption)
|
|
|
|
|
powered = 1
|
|
|
|
|
else
|
|
|
|
|
powered = 0
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/armour
|
|
|
|
|
name = "armour plating"
|
|
|
|
|
energy_consumption = 0
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/armour
|
|
|
|
|
max_damage = 60
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/actuator
|
|
|
|
|
name = "actuator"
|
|
|
|
|
energy_consumption = 2
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/actuator
|
|
|
|
|
max_damage = 50
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/cell
|
|
|
|
|
name = "power cell"
|
|
|
|
|
max_damage = 50
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/cell/destroy()
|
|
|
|
|
..()
|
|
|
|
|
owner.cell = null
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/radio
|
|
|
|
|
name = "radio"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/radio
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
max_damage = 40
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/binary_communication
|
|
|
|
|
name = "binary communication device"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/binary_communication_device
|
|
|
|
|
energy_consumption = 0
|
|
|
|
|
max_damage = 30
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/camera
|
|
|
|
|
name = "camera"
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/camera
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
max_damage = 40
|
|
|
|
|
|
|
|
|
|
/datum/robot_component/diagnosis_unit
|
|
|
|
|
name = "self-diagnosis unit"
|
|
|
|
|
energy_consumption = 1
|
|
|
|
|
external_type = /obj/item/robot_parts/robot_component/diagnosis_unit
|
|
|
|
|
max_damage = 30
|
|
|
|
|
|
|
|
|
|
/mob/living/silicon/robot/proc/initialize_components()
|
|
|
|
|
// This only initializes the components, it doesn't set them to installed.
|
|
|
|
|
|
|
|
|
|
components["actuator"] = new/datum/robot_component/actuator(src)
|
|
|
|
|
components["radio"] = new/datum/robot_component/radio(src)
|
|
|
|
|
components["power cell"] = new/datum/robot_component/cell(src)
|
|
|
|
|
components["diagnosis unit"] = new/datum/robot_component/diagnosis_unit(src)
|
|
|
|
|
components["camera"] = new/datum/robot_component/camera(src)
|
|
|
|
|
components["comms"] = new/datum/robot_component/binary_communication(src)
|
|
|
|
|
components["armour"] = new/datum/robot_component/armour(src)
|
|
|
|
|
|
|
|
|
|
/mob/living/silicon/robot/proc/is_component_functioning(module_name)
|
|
|
|
|
var/datum/robot_component/C = components[module_name]
|
|
|
|
|
return C && C.installed == 1 && C.toggled && C.is_powered()
|
|
|
|
|
|
|
|
|
|
/obj/item/broken_device
|
|
|
|
|
name = "broken component"
|
|
|
|
|
icon = 'icons/obj/robot_component.dmi'
|
|
|
|
|
icon_state = "broken"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component
|
|
|
|
|
icon = 'icons/obj/robot_component.dmi'
|
|
|
|
|
icon_state = "working"
|
|
|
|
|
construction_time = 200
|
|
|
|
|
construction_cost = list("metal"=5000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/binary_communication_device
|
|
|
|
|
name = "binary communication device"
|
|
|
|
|
icon_state = "binary_translator"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/actuator
|
|
|
|
|
name = "actuator"
|
|
|
|
|
icon_state = "actuator"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/armour
|
|
|
|
|
name = "armour plating"
|
|
|
|
|
icon_state = "armor_plating"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/camera
|
|
|
|
|
name = "camera"
|
|
|
|
|
icon_state = "camera"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/diagnosis_unit
|
|
|
|
|
name = "diagnosis unit"
|
|
|
|
|
icon_state = "diagnosis_unit"
|
|
|
|
|
|
|
|
|
|
/obj/item/robot_parts/robot_component/radio
|
|
|
|
|
name = "radio"
|
|
|
|
|
icon_state = "radio"
|
|
|
|
|