diff --git a/code/game/objects/items/stacks/medical_packs.dm b/code/game/objects/items/stacks/medical_packs.dm index 01d1bb1586b..73a973ef781 100644 --- a/code/game/objects/items/stacks/medical_packs.dm +++ b/code/game/objects/items/stacks/medical_packs.dm @@ -192,11 +192,11 @@ dynamic_icon_state = FALSE /obj/item/stack/medical/bruise_pack/advanced/cyborg - energy_type = /datum/robot_energy_storage/medical/adv_brute_kit + energy_type = /datum/robot_storage/energy/medical/adv_brute_kit is_cyborg = TRUE /obj/item/stack/medical/bruise_pack/advanced/cyborg/syndicate - energy_type = /datum/robot_energy_storage/medical/adv_brute_kit/syndicate + energy_type = /datum/robot_storage/energy/medical/adv_brute_kit/syndicate //Ointment// @@ -260,11 +260,11 @@ dynamic_icon_state = FALSE /obj/item/stack/medical/ointment/advanced/cyborg - energy_type = /datum/robot_energy_storage/medical/adv_burn_kit + energy_type = /datum/robot_storage/energy/medical/adv_burn_kit is_cyborg = TRUE /obj/item/stack/medical/ointment/advanced/cyborg/syndicate - energy_type = /datum/robot_energy_storage/medical/adv_burn_kit/syndicate + energy_type = /datum/robot_storage/energy/medical/adv_burn_kit/syndicate //Medical Herbs// /obj/item/stack/medical/bruise_pack/comfrey @@ -345,11 +345,11 @@ use(1) /obj/item/stack/medical/splint/cyborg - energy_type = /datum/robot_energy_storage/medical/splint + energy_type = /datum/robot_storage/energy/medical/splint is_cyborg = TRUE /obj/item/stack/medical/splint/cyborg/syndicate - energy_type = /datum/robot_energy_storage/medical/splint/syndicate + energy_type = /datum/robot_storage/energy/medical/splint/syndicate /obj/item/stack/medical/splint/tribal name = "tribal splints" diff --git a/code/game/objects/items/stacks/nanopaste.dm b/code/game/objects/items/stacks/nanopaste.dm index e296d166601..53d367f3552 100644 --- a/code/game/objects/items/stacks/nanopaste.dm +++ b/code/game/objects/items/stacks/nanopaste.dm @@ -67,7 +67,7 @@ H.bleed_rate = 0 /obj/item/stack/nanopaste/cyborg - energy_type = /datum/robot_energy_storage/medical/nanopaste + energy_type = /datum/robot_storage/energy/medical/nanopaste is_cyborg = TRUE /obj/item/stack/nanopaste/cyborg/attack(mob/living/M, mob/user) @@ -77,4 +77,4 @@ return ..() /obj/item/stack/nanopaste/cyborg/syndicate - energy_type = /datum/robot_energy_storage/medical/nanopaste/syndicate + energy_type = /datum/robot_storage/energy/medical/nanopaste/syndicate diff --git a/code/game/objects/items/stacks/rods.dm b/code/game/objects/items/stacks/rods.dm index db2d1a8a644..d701fdfafaf 100644 --- a/code/game/objects/items/stacks/rods.dm +++ b/code/game/objects/items/stacks/rods.dm @@ -47,7 +47,7 @@ GLOBAL_LIST_INIT(rod_recipes, list ( /obj/item/stack/rods/cyborg - energy_type = /datum/robot_energy_storage/rods + energy_type = /datum/robot_storage/energy/rods is_cyborg = TRUE materials = list() diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm index 49734f15e06..646b1567ccc 100644 --- a/code/game/objects/items/stacks/sheets/glass.dm +++ b/code/game/objects/items/stacks/sheets/glass.dm @@ -49,14 +49,18 @@ GLOBAL_LIST_INIT(glass_recipes, list ( amount = 50 /obj/item/stack/sheet/glass/cyborg - energy_type = /datum/robot_energy_storage/glass + energy_type = /datum/robot_storage/material/glass is_cyborg = TRUE materials = list() /obj/item/stack/sheet/glass/cyborg/examine(mob/user) . = ..() - . += "As a synthetic, you can regain sheets of glass by recharging in a cyborg recharger." + var/mob/living/silicon/robot/robot = user + if(!istype(robot.module, /obj/item/robot_module/drone)) + . += "You can refill your glass by using your magnetic gripper on the Ore Redemption machine, or by picking it up from the ground." +/obj/item/stack/sheet/glass/cyborg/drone + energy_type = /datum/robot_storage/energy/glass /obj/item/stack/sheet/glass/New(loc, amount) recipes = GLOB.glass_recipes @@ -136,13 +140,18 @@ GLOBAL_LIST_INIT(pglass_recipes, list ( )) /obj/item/stack/sheet/rglass/cyborg - energy_type = /datum/robot_energy_storage/rglass + energy_type = /datum/robot_storage/material/rglass is_cyborg = TRUE materials = list() /obj/item/stack/sheet/rglass/cyborg/examine(mob/user) . = ..() - . += "As a synthetic, you can regain sheets of reinforced glass by recharging in a cyborg recharger." + var/mob/living/silicon/robot/robot = user + if(!istype(robot.module, /obj/item/robot_module/drone)) + . += "You can refill your reinforced glass by picking it up from the ground." + +/obj/item/stack/sheet/rglass/cyborg/drone + energy_type = /datum/robot_storage/energy/rglass /obj/item/stack/sheet/plasmaglass name = "plasma glass" diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm index c6818200998..ceccaf3c74c 100644 --- a/code/game/objects/items/stacks/sheets/sheet_types.dm +++ b/code/game/objects/items/stacks/sheets/sheet_types.dm @@ -136,13 +136,18 @@ GLOBAL_LIST_INIT(metal_recipes, list( . += "Metal is used in various different construction sequences." /obj/item/stack/sheet/metal/cyborg - energy_type = /datum/robot_energy_storage/metal + energy_type = /datum/robot_storage/material/metal is_cyborg = TRUE materials = list() /obj/item/stack/sheet/metal/cyborg/examine(mob/user) . = ..() - . += "As a synthetic, you can regain sheets of reinforced glass by recharging in a cyborg recharger." + var/mob/living/silicon/robot/robot = user + if(!istype(robot.module, /obj/item/robot_module/drone)) + . += "You can refill your metal by using your magnetic gripper on the Ore Redemption machine, or by picking it up from the ground." + +/obj/item/stack/sheet/metal/cyborg/drone + energy_type = /datum/robot_storage/energy/metal /obj/item/stack/sheet/metal/fifty amount = 50 @@ -196,7 +201,7 @@ GLOBAL_LIST_INIT(plasteel_recipes, list( return ..() /obj/item/stack/sheet/wood/cyborg - energy_type = /datum/robot_energy_storage/wood + energy_type = /datum/robot_storage/energy/wood is_cyborg = TRUE /* diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 59fbda65aa8..bf31c6cdacd 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -12,8 +12,8 @@ origin_tech = "materials=1" /// Whether this stack is a `/cyborg` subtype or not. var/is_cyborg = FALSE - /// The energy storage datum that will be used with this stack. Used only with `/cyborg` type stacks. - var/datum/robot_energy_storage/source + /// The storage datum that will be used with this stack. Used only with `/cyborg` type stacks. + var/datum/robot_storage/source /// Which `robot_energy_storage` to choose when this stack is created in cyborgs. Used only with `/cyborg` type stacks. var/energy_type /// How much energy using 1 sheet from the stack costs. Used only with `/cyborg` type stacks. @@ -250,8 +250,8 @@ return amount if(!source) // The energy source has not yet been initializied - return 0 - return round(source.energy / cost) + return FALSE + return round(source.amount / cost) /obj/item/stack/proc/get_max_amount() return max_amount @@ -321,7 +321,7 @@ // Also qdels the stack gracefully if it is. /obj/item/stack/proc/zero_amount() if(is_cyborg) - return source.energy < cost + return source.amount < cost if(amount < 1) if(ismob(loc)) var/mob/living/L = loc // At this stage, stack code is so horrible and atrocious, I wouldn't be all surprised ghosts can somehow have stacks. If this happens, then the world deserves to burn. @@ -339,7 +339,7 @@ return FALSE var/transfer = get_amount() if(S.is_cyborg) - transfer = min(transfer, round((S.source.max_energy - S.source.energy) / S.cost)) + transfer = min(transfer, round((S.source.max_amount - S.source.amount) / S.cost)) else transfer = min(transfer, S.max_amount - S.amount) if(transfer <= 0) diff --git a/code/game/objects/items/stacks/tiles/tile_types.dm b/code/game/objects/items/stacks/tiles/tile_types.dm index dbceeea68f1..d299e7a0eb9 100644 --- a/code/game/objects/items/stacks/tiles/tile_types.dm +++ b/code/game/objects/items/stacks/tiles/tile_types.dm @@ -65,7 +65,7 @@ resistance_flags = FLAMMABLE /obj/item/stack/tile/wood/cyborg - energy_type = /datum/robot_energy_storage/wood_tile + energy_type = /datum/robot_storage/energy/wood_tile is_cyborg = TRUE //Carpets @@ -186,7 +186,7 @@ resistance_flags = FIRE_PROOF /obj/item/stack/tile/plasteel/cyborg - energy_type = /datum/robot_energy_storage/metal_tile + energy_type = /datum/robot_storage/energy/metal_tile is_cyborg = TRUE //Light @@ -290,5 +290,5 @@ resistance_flags = FIRE_PROOF /obj/item/stack/tile/catwalk/cyborg - energy_type = /datum/robot_energy_storage/catwalk + energy_type = /datum/robot_storage/energy/catwalk is_cyborg = TRUE diff --git a/code/modules/mining/machine_redemption.dm b/code/modules/mining/machine_redemption.dm index 81faa38130b..b2f9cb8bb06 100644 --- a/code/modules/mining/machine_redemption.dm +++ b/code/modules/mining/machine_redemption.dm @@ -207,6 +207,12 @@ user.visible_message("[user] inserts [I] into [src].", "You insert [I] into [src].") return + + else if(istype(I, /obj/item/gripper_engineering)) + if(!try_refill_storage(user)) + to_chat(user, "You fail to retrieve any sheets from [src].") + return + return ..() /obj/machinery/mineral/ore_redemption/crowbar_act(mob/user, obj/item/I) @@ -506,6 +512,38 @@ "You insert [I] into [src].") return TRUE +/obj/machinery/mineral/ore_redemption/proc/try_refill_storage(mob/living/silicon/robot/robot) + . = FALSE + if(!istype(robot)) + return + if(!istype(robot.module, /obj/item/robot_module/engineering)) // Should only happen for drones + return + + for(var/datum/robot_storage/material/mat_store in robot.module.material_storages) + if(mat_store.amount == mat_store.max_amount) // Already full, no need to run a check + to_chat(robot, "[mat_store] could not be filled due to it already being full.") + continue + var/datum/component/material_container/container_component = GetComponent(/datum/component/material_container) + for(var/mat_id in container_component.materials) + var/datum/material/stack = container_component.materials[mat_id] // Should have only `/datum/material` in the list + var/obj/item/stack/sheet/sheet = stack.sheet_type + if(ispath(mat_store.stack, sheet)) + var/amount_to_add + var/total_stacks = stack.amount / MINERAL_MATERIAL_AMOUNT // To account for 1 sheet being 2000 units of metal + if(total_stacks >= (mat_store.max_amount - mat_store.amount)) + amount_to_add = round(mat_store.max_amount - mat_store.amount) + to_chat(robot, "You refill [mat_store] to full.") + else + amount_to_add = round(total_stacks) // In case we have half a sheet stored + to_chat(robot, "You refill [amount_to_add] sheets to [mat_store].") + mat_store.amount += amount_to_add + remove_from_storage(stack, amount_to_add) + . = TRUE + break // We found our match for this material storage, so we go to the next one + +/obj/machinery/mineral/ore_redemption/proc/remove_from_storage(datum/material/stack, sheet_amount) + return stack.amount -= sheet_amount * MINERAL_MATERIAL_AMOUNT + /** * Called when an item is inserted manually as material. * diff --git a/code/modules/mob/living/silicon/robot/!robot_mob.dm b/code/modules/mob/living/silicon/robot/!robot_mob.dm index 74a8e7d253d..30ef3f5dfff 100644 --- a/code/modules/mob/living/silicon/robot/!robot_mob.dm +++ b/code/modules/mob/living/silicon/robot/!robot_mob.dm @@ -772,8 +772,8 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( var/turf/turf = get_turf(src) return list("GPS:", "[COORD(turf)]") -/mob/living/silicon/robot/proc/show_stack_energy(datum/robot_energy_storage/robot_energy_storage) - return list("[robot_energy_storage.statpanel_name]:", "[robot_energy_storage.energy] / [robot_energy_storage.max_energy]") +/mob/living/silicon/robot/proc/show_stack_energy(datum/robot_storage/robot_storage) + return list("[robot_storage.statpanel_name]:", "[robot_storage.amount] / [robot_storage.max_amount]") // update the status screen display /mob/living/silicon/robot/get_status_tab_items() @@ -788,8 +788,8 @@ GLOBAL_LIST_INIT(robot_verbs_default, list( if(locate(/obj/item/gps/cyborg) in module.modules) status_tab_data[++status_tab_data.len] = show_gps_coords() - for(var/datum/robot_energy_storage/robot_energy_storage in module.storages) - status_tab_data[++status_tab_data.len] = show_stack_energy(robot_energy_storage) + for(var/datum/robot_storage/robot_storage in module.storages) + status_tab_data[++status_tab_data.len] = show_stack_energy(robot_storage) /mob/living/silicon/robot/restrained() return 0 diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index cdde95777bd..e18de9d9fec 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -24,8 +24,10 @@ var/list/malf_modules = list() /// A list of modules that require special recharge handling. Examples include things like flashes, sprays and welding tools. var/list/special_rechargables = list() - /// A list of all "energy stacks", i.e metal, glass, brute kits, splints, etc. + /// A list of all "energy stacks", i.e cables, brute kits, splints, etc. var/list/storages = list() + /// A list of all "material stacks", i.e. metal, glass, and reinforced glass + var/list/material_storages = list() /// Special actions this module will gain when chosen such as meson vision, or thermal vision. var/list/module_actions = list() /// Available tools given in the verb tab such as a crew monitor, or power monitor. @@ -143,17 +145,20 @@ * Returns a `robot_energy_strage` datum of type `storage_type`. If one already exists, it returns that one, otherwise it create a new one. * * Arguments: - * * storage_type - the subtype of `datum/robot_energy_storage` to fetch or create. + * * storage_type - the subtype of `datum/robot_storage` to fetch or create. */ /obj/item/robot_module/proc/get_or_create_estorage(storage_type) for(var/e_storage in storages) - var/datum/robot_energy_storage/S = e_storage + var/datum/robot_storage/energy/S = e_storage if(istype(S, storage_type)) return S + var/datum/robot_storage/material/M = e_storage + if(istype(M, storage_type)) + return M return new storage_type(src) /** - * Adds the item `I` to our `modules` list, and sets up an `/datum/robot_energy_storage` if its a stack. + * Adds the item `I` to our `modules` list, and sets up an `/datum/robot_storage/energy` if its a stack. * * Arugments: * * I - the item to add to our modules. @@ -230,7 +235,7 @@ */ /obj/item/robot_module/proc/recharge_consumables(mob/living/silicon/robot/R, coeff = 1) for(var/e_storage in storages) - var/datum/robot_energy_storage/E = e_storage + var/datum/robot_storage/energy/E = e_storage E.add_charge(max(1, coeff * E.recharge_rate)) for(var/item in special_rechargables) var/obj/item/I = item @@ -791,13 +796,13 @@ /obj/item/t_scanner, /obj/item/rpd, /obj/item/analyzer, - /obj/item/stack/sheet/metal/cyborg, + /obj/item/stack/sheet/metal/cyborg/drone, /obj/item/stack/rods/cyborg, /obj/item/stack/tile/plasteel/cyborg, /obj/item/stack/tile/catwalk/cyborg, /obj/item/stack/cable_coil/cyborg, - /obj/item/stack/sheet/glass/cyborg, - /obj/item/stack/sheet/rglass/cyborg, + /obj/item/stack/sheet/glass/cyborg/drone, + /obj/item/stack/sheet/rglass/cyborg/drone, /obj/item/stack/sheet/wood/cyborg, /obj/item/stack/tile/wood/cyborg ) @@ -832,116 +837,153 @@ * The `recharge_rate` will be affected by the charge rate of a borg recharger, depending on the level of parts. By default it is 1. * This amount will be given every 2 seconds. So at round start, rechargers will give 1 energy back every 2 seconds, to each stack the borg has. */ -/datum/robot_energy_storage - /// The name of the energy storage. - var/name = "Generic energy storage" + +/datum/robot_storage + /// The name of the storage. + var/name = "Generic storage" /// The name that will be displayed in the status panel. var/statpanel_name = "Statpanel name" - /// The max amount of energy the stack can hold at once. - var/max_energy = 50 - /// The amount of energy the stack will regain while charging. - var/recharge_rate = 1 - /// Current amount of energy. - var/energy + /// The max amount of materials the stack can hold at once. + var/max_amount = 50 + /// Current amount of materials. + var/amount -/datum/robot_energy_storage/New(obj/item/robot_module/R = null) - if(!energy) - energy = max_energy - if(R) - R.storages += src +/datum/robot_storage/New(obj/item/robot_module/R) + if(!amount) + amount = max_amount /** - * Called whenever the cyborg uses one of its stacks. Subtract the amount used from this datum's `energy` variable. + * Called whenever the cyborg uses one of its stacks. Subtract the amount used from this datum's `amount` variable. * * Arguments: - * * amount - the number to subtract from the `energy` var. + * * reduction - the number to subtract from the `amount` var. */ -/datum/robot_energy_storage/proc/use_charge(amount) - if(energy < amount) +/datum/robot_storage/proc/use_charge(reduction) + if(amount < reduction) return FALSE // If we have more energy that we're about to drain, return - energy -= amount + amount -= reduction return TRUE /** * Called whenever the cyborg is recharging and gains charge on its stack, or when clicking on other same-type stacks in the world. * * Arguments: - * * amount - the number to add to the `energy` var. + * * addition - the number to add to the `energy` var. */ -/datum/robot_energy_storage/proc/add_charge(amount) - energy = min(energy + amount, max_energy) +/datum/robot_storage/proc/add_charge(addition) + amount = min(amount + addition, max_amount) -/datum/robot_energy_storage/metal +/datum/robot_storage/energy + name = "Generic energy storage" + /// The amount of energy the stack will regain while charging. + var/recharge_rate = 1 + +/datum/robot_storage/energy/New(obj/item/robot_module/R) + . = ..() + if(R) + R.storages += src + +/datum/robot_storage/energy/metal name = "Metal Synthesizer" statpanel_name = "Metal" -/datum/robot_energy_storage/metal_tile +/datum/robot_storage/energy/metal_tile name = "Floor tile Synthesizer" statpanel_name = "Floor tiles" - max_energy = 60 + max_amount = 60 -/datum/robot_energy_storage/rods +/datum/robot_storage/energy/rods name = "Rod Synthesizer" statpanel_name = "Rods" -/datum/robot_energy_storage/catwalk +/datum/robot_storage/energy/catwalk name= "Catwalk Synthesizer" statpanel_name = "Catwalk Tiles" - max_energy = 60 + max_amount = 60 -/datum/robot_energy_storage/glass +/datum/robot_storage/energy/glass name = "Glass Synthesizer" statpanel_name = "Glass" -/datum/robot_energy_storage/rglass +/datum/robot_storage/energy/rglass name = "Reinforced glass Synthesizer" statpanel_name = "Reinforced glass" -/datum/robot_energy_storage/wood +/datum/robot_storage/energy/wood name = "Wood Synthesizer" statpanel_name = "Wood" -/datum/robot_energy_storage/wood_tile +/datum/robot_storage/energy/wood_tile name = "Wooden tile Synthesizer" statpanel_name = "Wooden tiles" - max_energy = 60 + max_amount = 60 -/datum/robot_energy_storage/cable +/datum/robot_storage/energy/cable name = "Cable Synthesizer" statpanel_name = "Cable" // For the medical stacks, even though the recharge rate is 0, it will be set to 1 by default because of a `max()` proc. // It will always take ~12 seconds to fully recharge these stacks beacuse of this. This time does not apply to the syndicate storages. -/datum/robot_energy_storage/medical +/datum/robot_storage/energy/medical name = "Medical Synthesizer" - max_energy = 6 + max_amount = 6 recharge_rate = 0 -/datum/robot_energy_storage/medical/splint +/datum/robot_storage/energy/medical/splint name = "Splint Synthesizer" statpanel_name = "Splints" -/datum/robot_energy_storage/medical/splint/syndicate - max_energy = 25 +/datum/robot_storage/energy/medical/splint/syndicate + max_amount = 25 -/datum/robot_energy_storage/medical/adv_burn_kit +/datum/robot_storage/energy/medical/adv_burn_kit name = "Burn kit Synthesizer" statpanel_name = "Burn kits" -/datum/robot_energy_storage/medical/adv_burn_kit/syndicate - max_energy = 25 +/datum/robot_storage/energy/medical/adv_burn_kit/syndicate + max_amount = 25 -/datum/robot_energy_storage/medical/adv_brute_kit +/datum/robot_storage/energy/medical/adv_brute_kit name = "Trauma kit Synthesizer" statpanel_name = "Brute kits" -/datum/robot_energy_storage/medical/adv_brute_kit/syndicate - max_energy = 25 +/datum/robot_storage/energy/medical/adv_brute_kit/syndicate + max_amount = 25 -/datum/robot_energy_storage/medical/nanopaste +/datum/robot_storage/energy/medical/nanopaste name = "Nanopaste Synthesizer" statpanel_name = "Nanopaste" -/datum/robot_energy_storage/medical/nanopaste/syndicate - max_energy = 25 +/datum/robot_storage/energy/medical/nanopaste/syndicate + max_amount = 25 + +/// This datum is an alternative to the energy storages, instead being recharged in different ways +/datum/robot_storage/material + name = "Generic material storage" + /// What stacktype do we originally have + var/stack + /// Does this get added to the autorefill from the ORM + var/add_to_storage = FALSE + +/datum/robot_storage/material/New(obj/item/robot_module/R) + if(R && add_to_storage) + R.material_storages += src + ..() + +/datum/robot_storage/material/glass + name = "Glass Storage" + statpanel_name = "Glass" + stack = /obj/item/stack/sheet/glass + add_to_storage = TRUE + +/datum/robot_storage/material/rglass + name = "Reinforced glass Storage" + statpanel_name = "Reinforced glass" + stack = /obj/item/stack/sheet/rglass + +/datum/robot_storage/material/metal + name = "Metal Storage" + statpanel_name = "Metal" + stack = /obj/item/stack/sheet/metal + add_to_storage = TRUE diff --git a/code/modules/power/cables/cable_coil.dm b/code/modules/power/cables/cable_coil.dm index aef1d636919..31176947c3a 100644 --- a/code/modules/power/cables/cable_coil.dm +++ b/code/modules/power/cables/cable_coil.dm @@ -388,7 +388,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe/cable_restrain update_wclass() /obj/item/stack/cable_coil/cyborg - energy_type = /datum/robot_energy_storage/cable + energy_type = /datum/robot_storage/energy/cable is_cyborg = TRUE /obj/item/stack/cable_coil/cyborg/update_icon_state()