mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Recharger refactor
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
|
||||
var/obj/machinery/computer3/laptop/stored_computer = null
|
||||
|
||||
/obj/item/device/laptop/get_cell()
|
||||
return stored_computer.battery
|
||||
|
||||
/obj/item/device/laptop/verb/open_computer()
|
||||
set name = "Open Laptop"
|
||||
set category = "Object"
|
||||
|
||||
@@ -41,35 +41,12 @@ obj/machinery/recharger
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/gun/energy))
|
||||
var/obj/item/weapon/gun/energy/E = G
|
||||
if(!E.power_supply)
|
||||
to_chat(user, "<span class='notice'>Your gun has no power cell.</span>")
|
||||
return
|
||||
if(E.self_recharge)
|
||||
to_chat(user, "<span class='notice'>Your gun has no recharge port.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/gun/energy/staff))
|
||||
if(!G.get_cell())
|
||||
to_chat(user, "This device does not have a battery installed.")
|
||||
return
|
||||
if(istype(G, /obj/item/device/flashlight))
|
||||
var/obj/item/device/flashlight/F = G
|
||||
if(!F.power_use)
|
||||
return
|
||||
if(!F.cell)
|
||||
return
|
||||
if(istype(G, /obj/item/device/laptop))
|
||||
var/obj/item/device/laptop/L = G
|
||||
if(!L.stored_computer.battery)
|
||||
user << "There's no battery in it!"
|
||||
return
|
||||
if(istype(G, /obj/item/device/electronic_assembly))
|
||||
var/obj/item/device/electronic_assembly/assembly = G
|
||||
if(!assembly.battery)
|
||||
to_chat(user, "<span class='warning'>The assembly doesn't have a power cell.</span>")
|
||||
return
|
||||
if(istype(G, /obj/item/weapon/weldingtool/electric))
|
||||
var/obj/item/weapon/weldingtool/electric/welder = G
|
||||
if(!welder.power_supply)
|
||||
to_chat(user, "<span class='notice'>Your welder has no power cell.</span>")
|
||||
return
|
||||
|
||||
user.drop_item()
|
||||
G.loc = src
|
||||
@@ -109,71 +86,8 @@ obj/machinery/recharger
|
||||
update_use_power(1)
|
||||
icon_state = icon_state_idle
|
||||
else
|
||||
if(istype(charging, /obj/item/weapon/gun/energy))
|
||||
var/obj/item/weapon/gun/energy/E = charging
|
||||
if(!E.power_supply.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
E.power_supply.give(active_power_usage*CELLRATE)
|
||||
update_use_power(2)
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/weapon/gun/magnetic))
|
||||
var/obj/item/weapon/gun/magnetic/M = charging
|
||||
if(!M.cell.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
M.cell.give(active_power_usage*CELLRATE)
|
||||
update_use_power(2)
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/weapon/melee/baton))
|
||||
var/obj/item/weapon/melee/baton/B = charging
|
||||
if(B.bcell)
|
||||
if(!B.bcell.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
B.bcell.give(active_power_usage*CELLRATE)
|
||||
update_use_power(2)
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
else
|
||||
icon_state = icon_state_idle
|
||||
update_use_power(1)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/device/laptop))
|
||||
var/obj/item/device/laptop/L = charging
|
||||
if(!L.stored_computer.battery.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
L.stored_computer.battery.give(active_power_usage*CELLRATE)
|
||||
update_use_power(2)
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/device/flashlight))
|
||||
var/obj/item/device/flashlight/F = charging
|
||||
if(F.cell)
|
||||
if(!F.cell.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
F.cell.give(active_power_usage*CELLRATE)
|
||||
update_use_power(2)
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
else
|
||||
icon_state = icon_state_idle
|
||||
update_use_power(1)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/weapon/cell))
|
||||
var/obj/item/weapon/cell/C = charging
|
||||
var/obj/item/weapon/cell/C = charging.get_cell()
|
||||
if(istype(C))
|
||||
if(!C.fully_charged())
|
||||
icon_state = icon_state_charging
|
||||
C.give(active_power_usage*CELLRATE)
|
||||
@@ -181,6 +95,7 @@ obj/machinery/recharger
|
||||
else
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
<<<<<<< HEAD
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/device/electronic_assembly))
|
||||
@@ -221,21 +136,19 @@ obj/machinery/recharger
|
||||
icon_state = icon_state_charged
|
||||
update_use_power(1)
|
||||
return
|
||||
=======
|
||||
>>>>>>> 32557da... Merge pull request #5356 from Anewbe/recharger_refactor
|
||||
|
||||
/obj/machinery/recharger/emp_act(severity)
|
||||
if(stat & (NOPOWER|BROKEN) || !anchored)
|
||||
..(severity)
|
||||
return
|
||||
|
||||
if(istype(charging, /obj/item/weapon/gun/energy))
|
||||
var/obj/item/weapon/gun/energy/E = charging
|
||||
if(E.power_supply)
|
||||
E.power_supply.emp_act(severity)
|
||||
if(charging)
|
||||
var/obj/item/weapon/cell/C = charging.get_cell()
|
||||
if(istype(C))
|
||||
C.emp_act(severity)
|
||||
|
||||
else if(istype(charging, /obj/item/weapon/melee/baton))
|
||||
var/obj/item/weapon/melee/baton/B = charging
|
||||
if(B.bcell)
|
||||
B.bcell.charge = 0
|
||||
..(severity)
|
||||
|
||||
/obj/machinery/recharger/update_icon() //we have an update_icon() in addition to the stuff in process to make it feel a tiny bit snappier.
|
||||
@@ -244,7 +157,6 @@ obj/machinery/recharger
|
||||
else
|
||||
icon_state = icon_state_idle
|
||||
|
||||
|
||||
/obj/machinery/recharger/wallcharger
|
||||
name = "wall recharger"
|
||||
icon = 'icons/obj/stationobjs.dmi'
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
processing_objects -= src
|
||||
return ..()
|
||||
|
||||
/obj/item/device/flashlight/get_cell()
|
||||
return cell
|
||||
|
||||
/obj/item/device/flashlight/verb/toggle()
|
||||
set name = "Toggle Flashlight Brightness"
|
||||
set category = "Object"
|
||||
|
||||
@@ -38,6 +38,9 @@ var/global/list/active_radio_jammers = list()
|
||||
qdel_null(power_source)
|
||||
return ..()
|
||||
|
||||
/obj/item/device/radio_jammer/get_cell()
|
||||
return power_source
|
||||
|
||||
/obj/item/device/radio_jammer/proc/turn_off(mob/user)
|
||||
if(user)
|
||||
to_chat(user,"<span class='warning'>\The [src] deactivates.</span>")
|
||||
|
||||
@@ -19,16 +19,19 @@
|
||||
var/obj/item/weapon/cell/bcell = null
|
||||
var/hitcost = 240
|
||||
|
||||
/obj/item/weapon/melee/baton/suicide_act(mob/user)
|
||||
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
|
||||
user.visible_message("<span class='suicide'>\The [user] is putting the live [name] in [TU.his] mouth! It looks like [TU.he] [TU.is] trying to commit suicide.</span>")
|
||||
return (FIRELOSS)
|
||||
|
||||
/obj/item/weapon/melee/baton/New()
|
||||
..()
|
||||
update_icon()
|
||||
return
|
||||
|
||||
/obj/item/weapon/melee/baton/get_cell()
|
||||
return bcell
|
||||
|
||||
/obj/item/weapon/melee/baton/suicide_act(mob/user)
|
||||
var/datum/gender/TU = gender_datums[user.get_visible_gender()]
|
||||
user.visible_message("<span class='suicide'>\The [user] is putting the live [name] in [TU.his] mouth! It looks like [TU.he] [TU.is] trying to commit suicide.</span>")
|
||||
return (FIRELOSS)
|
||||
|
||||
/obj/item/weapon/melee/baton/MouseDrop(obj/over_object as obj)
|
||||
if(!canremove)
|
||||
return
|
||||
|
||||
@@ -776,6 +776,9 @@
|
||||
acti_sound = 'sound/effects/sparks4.ogg'
|
||||
deac_sound = 'sound/effects/sparks4.ogg'
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/unloaded/New()
|
||||
cell_type = null
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/New()
|
||||
..()
|
||||
if(cell_type == null)
|
||||
@@ -786,8 +789,8 @@
|
||||
power_supply = new /obj/item/weapon/cell/device(src)
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/unloaded/New()
|
||||
cell_type = null
|
||||
/obj/item/weapon/weldingtool/electric/get_cell()
|
||||
return power_supply
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/examine(mob/user)
|
||||
if(get_dist(src, user) > 1)
|
||||
|
||||
@@ -163,3 +163,6 @@
|
||||
|
||||
/obj/proc/show_message(msg, type, alt, alt_type)//Message, type of message (1 or 2), alternative message, alt message type (1 or 2)
|
||||
return
|
||||
|
||||
/obj/proc/get_cell()
|
||||
return
|
||||
@@ -19,6 +19,9 @@
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/device/electronic_assembly/get_cell()
|
||||
return battery
|
||||
|
||||
/obj/item/device/assembly/electronic_assembly/proc/toggle_open(mob/user)
|
||||
playsound(get_turf(src), 'sound/items/Crowbar.ogg', 50, 1)
|
||||
opened = !opened
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
processing_objects -= src
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/cell/get_cell()
|
||||
return src
|
||||
|
||||
/obj/item/weapon/cell/process()
|
||||
if(self_recharge)
|
||||
if(world.time >= last_use + charge_delay)
|
||||
|
||||
@@ -23,17 +23,6 @@
|
||||
|
||||
var/battery_lock = 0 //If set, weapon cannot switch batteries
|
||||
|
||||
/obj/item/weapon/gun/energy/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/energy/switch_firemodes(mob/user)
|
||||
if(..())
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/emp_act(severity)
|
||||
..()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/New()
|
||||
..()
|
||||
if(self_recharge)
|
||||
@@ -52,6 +41,9 @@
|
||||
processing_objects.Remove(src)
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/gun/energy/get_cell()
|
||||
return power_supply
|
||||
|
||||
/obj/item/weapon/gun/energy/process()
|
||||
if(self_recharge) //Every [recharge_time] ticks, recharge a shot for the battery
|
||||
if(world.time > last_shot + charge_delay) //Doesn't work if you've fired recently
|
||||
@@ -75,6 +67,17 @@
|
||||
charge_tick = 0
|
||||
return 1
|
||||
|
||||
/obj/item/weapon/gun/energy/attackby(var/obj/item/A as obj, mob/user as mob)
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/energy/switch_firemodes(mob/user)
|
||||
if(..())
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/emp_act(severity)
|
||||
..()
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/gun/energy/consume_next_projectile()
|
||||
if(!power_supply) return null
|
||||
if(!ispath(projectile_type)) return null
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
qdel_null(capacitor)
|
||||
. = ..()
|
||||
|
||||
/obj/item/weapon/gun/magnetic/get_cell()
|
||||
return cell
|
||||
|
||||
/obj/item/weapon/gun/magnetic/process()
|
||||
if(capacitor)
|
||||
if(cell)
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
var/obj/item/weapon/cell/device/cell
|
||||
var/enabled = 0
|
||||
|
||||
/obj/item/weapon/shield_diffuser/update_icon()
|
||||
if(enabled)
|
||||
icon_state = "hdiffuser_on"
|
||||
else
|
||||
icon_state = "hdiffuser_off"
|
||||
|
||||
/obj/item/weapon/shield_diffuser/New()
|
||||
cell = new(src)
|
||||
@@ -24,6 +19,9 @@
|
||||
processing_objects.Remove(src)
|
||||
. = ..()
|
||||
|
||||
/obj/item/weapon/shield_diffuser/get_cell()
|
||||
return cell
|
||||
|
||||
/obj/item/weapon/shield_diffuser/process()
|
||||
if(!enabled)
|
||||
return
|
||||
@@ -34,6 +32,12 @@
|
||||
if(istype(S) && cell.checked_use(10 KILOWATTS * CELLRATE))
|
||||
qdel(S)
|
||||
|
||||
/obj/item/weapon/shield_diffuser/update_icon()
|
||||
if(enabled)
|
||||
icon_state = "hdiffuser_on"
|
||||
else
|
||||
icon_state = "hdiffuser_off"
|
||||
|
||||
/obj/item/weapon/shield_diffuser/attack_self()
|
||||
enabled = !enabled
|
||||
update_icon()
|
||||
|
||||
Reference in New Issue
Block a user