Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] MODsuit now uses spacesuit cell hud element #2944

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion code/__DEFINES/alerts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#define ALERT_HACKING_APC "hackingapc"

/** MODsuit/Mech related */
#define ALERT_MODSUIT_CHARGE "mod_charge"
#define ALERT_MECH_DAMAGE "mech_damage"

/** Food related */
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,7 @@


/mob/living/carbon/proc/update_spacesuit_hud_icon(cell_state = "empty")
if(hud_used?.spacesuit)
hud_used.spacesuit.icon_state = "spacesuit_[cell_state]"
hud_used?.spacesuit?.icon_state = "spacesuit_[cell_state]"


/mob/living/carbon/set_health(new_value)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mod/mod_activation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@
for(var/obj/item/mod/module/module as anything in modules)
module.on_suit_deactivation()
update_speed()
update_icon_state()
update_appearance(UPDATE_ICON_STATE)
update_charge_alert()
wearer.update_clothing(slot_flags)

/// Quickly deploys all the suit parts and if successful, seals them and turns on the suit. Intended mostly for outfits.
Expand Down
24 changes: 14 additions & 10 deletions code/modules/mod/mod_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
if(malfunctioning)
malfunctioning_charge_drain = rand(1,20)
subtract_charge((charge_drain + malfunctioning_charge_drain) * seconds_per_tick)
update_charge_alert()
for(var/obj/item/mod/module/module as anything in modules)
if(malfunctioning && module.active && SPT_PROB(5, seconds_per_tick))
module.on_deactivation(display_message = TRUE)
Expand Down Expand Up @@ -319,7 +318,6 @@
wrench.play_tool_sound(src, 100)
balloon_alert(user, "core removed")
core.forceMove(drop_location())
update_charge_alert()
return TRUE
return ..()

Expand Down Expand Up @@ -402,7 +400,6 @@
attacking_core.install(src)
balloon_alert(user, "core installed")
playsound(src, 'sound/machines/click.ogg', 50, TRUE, SILENCED_SOUND_EXTRARANGE)
update_charge_alert()
return TRUE
else if(is_wire_tool(attacking_item) && open)
wires.interact(user)
Expand Down Expand Up @@ -487,8 +484,8 @@
for(var/obj/item/mod/module/module as anything in modules)
module.on_unequip()
UnregisterSignal(wearer, list(COMSIG_ATOM_EXITED, COMSIG_SPECIES_GAIN))
wearer.clear_alert(ALERT_MODSUIT_CHARGE)
SEND_SIGNAL(src, COMSIG_MOD_WEARER_UNSET, wearer)
wearer.update_spacesuit_hud_icon("0")
wearer = null

/obj/item/mod/control/proc/clean_up()
Expand Down Expand Up @@ -631,13 +628,21 @@
/obj/item/mod/control/proc/check_charge(amount)
return core?.check_charge(amount) || FALSE

/**
* Updates the wearer's hud according to the current state of the MODsuit
*/
/obj/item/mod/control/proc/update_charge_alert()
if(!wearer)
return
if(!core)
wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocore)
if(isnull(wearer))
return
core.update_charge_alert()
var/state_to_use
if(!active)
state_to_use = "0"
else if(isnull(core))
state_to_use = "coreless"
else
state_to_use = core.get_charge_icon_state()

wearer.update_spacesuit_hud_icon(state_to_use || "0")

/obj/item/mod/control/proc/update_speed()
var/list/all_parts = mod_parts + src
Expand Down Expand Up @@ -703,7 +708,6 @@
return
if(part == core)
core.uninstall()
update_charge_alert()
return
if(part.loc == wearer)
return
Expand Down
102 changes: 53 additions & 49 deletions code/modules/mod/mod_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
mod = mod_unit
mod.core = src
forceMove(mod)
mod.update_charge_alert()

/obj/item/mod/core/proc/uninstall()
mod.core = null
mod.update_charge_alert()
mod = null

/obj/item/mod/core/proc/charge_source()
Expand All @@ -41,8 +43,11 @@
/obj/item/mod/core/proc/check_charge(amount)
return FALSE

/obj/item/mod/core/proc/update_charge_alert()
mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE)
/**
* Gets what icon state to display on the HUD for the charge level of this core
*/
/obj/item/mod/core/proc/get_charge_icon_state()
return "0"

/obj/item/mod/core/infinite
name = "MOD infinite core"
Expand All @@ -68,6 +73,9 @@
/obj/item/mod/core/infinite/check_charge(amount)
return TRUE

/obj/item/mod/core/infinite/get_charge_icon_state()
return "high"

/obj/item/mod/core/standard
name = "MOD standard core"
icon_state = "mod-core-standard"
Expand All @@ -80,8 +88,7 @@
var/obj/item/stock_parts/cell/cell

/obj/item/mod/core/standard/Destroy()
if(cell)
QDEL_NULL(cell)
QDEL_NULL(cell)
return ..()

/obj/item/mod/core/standard/install(obj/item/mod/control/mod_unit)
Expand Down Expand Up @@ -116,54 +123,57 @@

/obj/item/mod/core/standard/add_charge(amount)
var/obj/item/stock_parts/cell/charge_source = charge_source()
if(!charge_source)
if(isnull(charge_source))
return FALSE
return charge_source.give(amount)
. = charge_source.give(amount)
if(.)
mod.update_charge_alert()
return .

/obj/item/mod/core/standard/subtract_charge(amount)
var/obj/item/stock_parts/cell/charge_source = charge_source()
if(!charge_source)
if(isnull(charge_source))
return FALSE
return charge_source.use(amount, TRUE)
. = charge_source.use(amount, TRUE)
if(.)
mod.update_charge_alert()
return .

/obj/item/mod/core/standard/check_charge(amount)
return charge_amount() >= amount

/obj/item/mod/core/standard/update_charge_alert()
var/obj/item/stock_parts/cell/charge_source = charge_source()
if(!charge_source)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocell)
return
var/remaining_cell = charge_amount() / max_charge_amount()
switch(remaining_cell)
/obj/item/mod/core/standard/get_charge_icon_state()
if(isnull(charge_source()))
return "missing"

switch(round(charge_amount() / max_charge_amount(), 0.01))
if(0.75 to INFINITY)
mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE)
return "high"
if(0.5 to 0.75)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 1)
return "mid"
if(0.25 to 0.5)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 2)
if(0.01 to 0.25)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell, 3)
else
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/emptycell)
return "low"
if(0.02 to 0.25)
return "very_low"

return "empty"

/obj/item/mod/core/standard/proc/install_cell(new_cell)
cell = new_cell
cell.forceMove(src)
RegisterSignal(src, COMSIG_ATOM_EXITED, PROC_REF(on_exit))
mod.update_charge_alert()

/obj/item/mod/core/standard/proc/uninstall_cell()
if(!cell)
return
cell.update_appearance()
cell = null
UnregisterSignal(src, COMSIG_ATOM_EXITED)

/obj/item/mod/core/standard/proc/on_exit(datum/source, obj/item/stock_parts/cell, direction)
SIGNAL_HANDLER
mod.update_charge_alert()

if(!istype(cell) || cell.loc == src)
return
uninstall_cell()
/obj/item/mod/core/standard/Exited(atom/movable/gone, direction)
. = ..()
if(gone == cell)
uninstall_cell()

/obj/item/mod/core/standard/proc/on_examine(datum/source, mob/examiner, list/examine_text)
SIGNAL_HANDLER
Expand Down Expand Up @@ -195,7 +205,6 @@
var/obj/item/cell_to_move = cell
cell_to_move.forceMove(drop_location())
user.put_in_hands(cell_to_move)
mod.update_charge_alert()

/obj/item/mod/core/standard/proc/on_attackby(datum/source, obj/item/attacking_item, mob/user)
SIGNAL_HANDLER
Expand All @@ -212,7 +221,6 @@
install_cell(attacking_item)
mod.balloon_alert(user, "cell installed")
playsound(mod, 'sound/machines/click.ogg', 50, TRUE, SILENCED_SOUND_EXTRARANGE)
mod.update_charge_alert()
return COMPONENT_NO_AFTERATTACK
return NONE

Expand All @@ -232,7 +240,6 @@
SIGNAL_HANDLER

add_charge(amount)
mod.update_charge_alert()

/obj/item/mod/core/ethereal
name = "MOD ethereal core"
Expand Down Expand Up @@ -272,12 +279,8 @@
/obj/item/mod/core/ethereal/check_charge(amount)
return charge_amount() >= amount*charge_modifier

/obj/item/mod/core/ethereal/update_charge_alert()
var/obj/item/organ/internal/stomach/ethereal/charge_source = charge_source()
if(charge_source)
mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE)
return
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/nocell)
/obj/item/mod/core/ethereal/get_charge_icon_state()
return charge_source() ? "0" : "missing"

#define PLASMA_CORE_ORE_CHARGE 1500
#define PLASMA_CORE_SHEET_CHARGE 2000
Expand Down Expand Up @@ -318,28 +321,29 @@

/obj/item/mod/core/plasma/add_charge(amount)
charge = min(maxcharge, charge + amount)
mod.update_charge_alert()
return TRUE

/obj/item/mod/core/plasma/subtract_charge(amount)
charge = max(0, charge - amount)
mod.update_charge_alert()
return TRUE

/obj/item/mod/core/plasma/check_charge(amount)
return charge_amount() >= amount

/obj/item/mod/core/plasma/update_charge_alert()
var/remaining_plasma = charge_amount() / max_charge_amount()
switch(remaining_plasma)
/obj/item/mod/core/plasma/get_charge_icon_state()
switch(round(charge_amount() / max_charge_amount(), 0.01))
if(0.75 to INFINITY)
mod.wearer.clear_alert(ALERT_MODSUIT_CHARGE)
return "high"
if(0.5 to 0.75)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 1)
return "mid"
if(0.25 to 0.5)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 2)
if(0.01 to 0.25)
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/lowcell/plasma, 3)
else
mod.wearer.throw_alert(ALERT_MODSUIT_CHARGE, /atom/movable/screen/alert/emptycell/plasma)
return "low"
if(0.02 to 0.25)
return "very_low"

return "empty"

/obj/item/mod/core/plasma/proc/on_attackby(datum/source, obj/item/attacking_item, mob/user)
SIGNAL_HANDLER
Expand Down
1 change: 0 additions & 1 deletion code/modules/mod/modules/_module.dm
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
if(!check_power(amount))
return FALSE
mod.subtract_charge(amount)
mod.update_charge_alert()
return TRUE

/// Checks if there is enough power in the suit
Expand Down
Binary file modified icons/hud/screen_gen.dmi
Binary file not shown.
Loading