beeg commit

This commit is contained in:
Jerry Wester
2022-12-10 00:55:20 -07:00
parent b538ad721b
commit f7ac3c7624
73 changed files with 3502 additions and 533 deletions
+3 -259
View File
@@ -1,259 +1,3 @@
/obj/item/mod/module
name = "MOD module"
icon_state = "module"
/// If it can be removed
var/removable = TRUE
/// If it's passive, togglable, usable or active
var/module_type = MODULE_PASSIVE
/// Is the module active
var/active = FALSE
/// How much space it takes up in the MOD
var/complexity = 0
/// Power use when idle
var/idle_power_cost = DEFAULT_CELL_DRAIN * 0
/// Power use when active
var/active_power_cost = DEFAULT_CELL_DRAIN * 0
/// Power use when used, we call it manually
var/use_power_cost = DEFAULT_CELL_DRAIN * 0
/// ID used by their TGUI
var/tgui_id
/// Linked MODsuit
var/obj/item/mod/control/mod
/// If we're an active module, what item are we?
var/obj/item/device
/// Overlay given to the user when the module is inactive
var/overlay_state_inactive
/// Overlay given to the user when the module is active
var/overlay_state_active
/// Overlay given to the user when the module is used, lasts until cooldown finishes
var/overlay_state_use
/// What modules are we incompatible with?
var/list/incompatible_modules = list()
/// Cooldown after use
var/cooldown_time = 0
/// The mouse button needed to use this module
var/used_signal
/// Timer for the cooldown
COOLDOWN_DECLARE(cooldown_timer)
/obj/item/mod/module/Initialize(mapload)
. = ..()
if(module_type != MODULE_ACTIVE)
return
if(ispath(device))
device = new device(src)
ADD_TRAIT(device, TRAIT_NODROP, MOD_TRAIT)
RegisterSignal(device, COMSIG_PARENT_PREQDELETED, .proc/on_device_deletion)
RegisterSignal(src, COMSIG_ATOM_EXITED, .proc/on_exit)
/obj/item/mod/module/Destroy()
mod?.uninstall(src)
if(device)
UnregisterSignal(device, COMSIG_PARENT_PREQDELETED)
QDEL_NULL(device)
return ..()
/obj/item/mod/module/examine(mob/user)
. = ..()
if(HAS_TRAIT(user, TRAIT_DIAGNOSTIC_HUD))
. += span_notice("Complexity level: [complexity]")
/// Called from MODsuit's install() proc, so when the module is installed.
/obj/item/mod/module/proc/on_install()
return
/// Called from MODsuit's uninstall() proc, so when the module is uninstalled.
/obj/item/mod/module/proc/on_uninstall()
return
/// Called when the MODsuit is activated
/obj/item/mod/module/proc/on_suit_activation()
return
/// Called when the MODsuit is deactivated
/obj/item/mod/module/proc/on_suit_deactivation()
return
/// Called when the MODsuit is equipped
/obj/item/mod/module/proc/on_equip()
return
/// Called when the MODsuit is unequipped
/obj/item/mod/module/proc/on_unequip()
return
/// Called when the module is selected from the TGUI
/obj/item/mod/module/proc/on_select()
if(!mod.active || mod.activating || module_type == MODULE_PASSIVE)
return
if(module_type != MODULE_USABLE)
if(active)
on_deactivation()
else
on_activation()
else
on_use()
SEND_SIGNAL(mod, COMSIG_MOD_MODULE_SELECTED)
/// Called when the module is activated
/obj/item/mod/module/proc/on_activation()
if(!COOLDOWN_FINISHED(src, cooldown_timer))
balloon_alert(mod.wearer, "on cooldown!")
return FALSE
if(!mod.active || mod.activating || !mod.cell?.charge)
balloon_alert(mod.wearer, "unpowered!")
return FALSE
if(module_type == MODULE_ACTIVE)
if(mod.selected_module && !mod.selected_module.on_deactivation())
return
mod.selected_module = src
if(device)
if(mod.wearer.put_in_hands(device))
balloon_alert(mod.wearer, "[device] extended")
RegisterSignal(mod.wearer, COMSIG_ATOM_EXITED, .proc/on_exit)
else
balloon_alert(mod.wearer, "can't extend [device]!")
return
else
var/used_button = mod.wearer.client?.prefs.read_preference(/datum/preference/choiced/mod_select) || MIDDLE_CLICK
update_signal(used_button)
balloon_alert(mod.wearer, "[src] activated, [used_button]-click to use")
active = TRUE
COOLDOWN_START(src, cooldown_timer, cooldown_time)
mod.wearer.update_inv_back()
return TRUE
/// Called when the module is deactivated
/obj/item/mod/module/proc/on_deactivation()
active = FALSE
if(module_type == MODULE_ACTIVE)
mod.selected_module = null
if(device)
mod.wearer.transferItemToLoc(device, src, TRUE)
balloon_alert(mod.wearer, "[device] retracted")
UnregisterSignal(mod.wearer, COMSIG_ATOM_EXITED)
else
balloon_alert(mod.wearer, "[src] deactivated")
UnregisterSignal(mod.wearer, used_signal)
used_signal = null
mod.wearer.update_inv_back()
return TRUE
/// Called when the module is used
/obj/item/mod/module/proc/on_use()
if(!COOLDOWN_FINISHED(src, cooldown_timer))
return FALSE
if(!check_power(use_power_cost))
return FALSE
COOLDOWN_START(src, cooldown_timer, cooldown_time)
addtimer(CALLBACK(mod.wearer, /mob.proc/update_inv_back), cooldown_time)
mod.wearer.update_inv_back()
return TRUE
/// Called when an activated module without a device is used
/obj/item/mod/module/proc/on_select_use(atom/target)
mod.wearer.face_atom(target)
if(!on_use())
return FALSE
return TRUE
/// Called when an activated module without a device is active and the user alt/middle-clicks
/obj/item/mod/module/proc/on_special_click(mob/source, atom/target)
SIGNAL_HANDLER
on_select_use(target)
return COMSIG_MOB_CANCEL_CLICKON
/// Called on the MODsuit's process
/obj/item/mod/module/proc/on_process(delta_time)
if(active)
if(!drain_power(active_power_cost * delta_time))
on_deactivation()
return FALSE
on_active_process(delta_time)
else
drain_power(idle_power_cost * delta_time)
return TRUE
/// Called on the MODsuit's process if it is an active module
/obj/item/mod/module/proc/on_active_process(delta_time)
return
/// Drains power from the suit cell
/obj/item/mod/module/proc/drain_power(amount)
if(!check_power(amount))
return FALSE
mod.cell.charge = max(0, mod.cell.charge - amount)
return TRUE
/obj/item/mod/module/proc/check_power(amount)
if(!mod.cell || (mod.cell.charge < amount))
return FALSE
return TRUE
/// Adds additional things to the MODsuit ui_data()
/obj/item/mod/module/proc/add_ui_data()
return list()
/// Creates a list of configuring options for this module
/obj/item/mod/module/proc/get_configuration()
return list()
/// Generates an element of the get_configuration list with a display name, type and value
/obj/item/mod/module/proc/add_ui_configuration(display_name, type, value, list/values)
return list("display_name" = display_name, "type" = type, "value" = value, "values" = values)
/// Receives configure edits from the TGUI and edits the vars
/obj/item/mod/module/proc/configure_edit(key, value)
return
/// Called when the device moves to a different place on active modules
/obj/item/mod/module/proc/on_exit(datum/source, atom/movable/part, direction)
SIGNAL_HANDLER
if(!active)
return
if(part.loc == src)
return
if(part.loc == mod.wearer)
return
if(part == device)
on_deactivation()
/// Called when the device gets deleted on active modules
/obj/item/mod/module/proc/on_device_deletion(datum/source)
SIGNAL_HANDLER
if(source == device)
device = null
qdel(src)
/// Generates an icon to be used for the suit's worn overlays
/obj/item/mod/module/proc/generate_worn_overlay(mutable_appearance/standing)
. = list()
var/used_overlay
if(overlay_state_use && !COOLDOWN_FINISHED(src, cooldown_timer))
used_overlay = overlay_state_use
else if(overlay_state_active && active)
used_overlay = overlay_state_active
else if(overlay_state_inactive)
used_overlay = overlay_state_inactive
else
return
var/mutable_appearance/module_icon = mutable_appearance('icons/mob/mod.dmi', used_overlay, layer = standing.layer + 0.1)
. += module_icon
/// Updates the signal used by active modules to be activated
/obj/item/mod/module/proc/update_signal(value)
switch(value)
if(MIDDLE_CLICK)
mod.selected_module.used_signal = COMSIG_MOB_MIDDLECLICKON
if(ALT_CLICK)
mod.selected_module.used_signal = COMSIG_MOB_ALTCLICKON
RegisterSignal(mod.wearer, mod.selected_module.used_signal, /obj/item/mod/module.proc/on_special_click)
icon_state = "magic_nullifier"
removable = FALSE
incompatible_modules = list(/obj/item/mod/module/anti_magic)
/obj/item/mod/module/anti_magic/on_suit_activation()
ADD_TRAIT(mod.wearer, TRAIT_ANTIMAGIC, MOD_TRAIT)
ADD_TRAIT(mod.wearer, TRAIT_HOLY, MOD_TRAIT)
@@ -288,8 +32,8 @@
module_type = MODULE_TOGGLE
// complexity = 3
complexity = 0
active_power_cost = DEFAULT_CELL_DRAIN*0.75
// use_power_cost = DEFAULT_CELL_DRAIN*3
active_power_cost = DEFAULT_CHARGE_DRAIN*0.75
// use_power_cost = DEFAULT_CHARGE_DRAIN*3
removable = FALSE
incompatible_modules = list(/obj/item/mod/module/kinesis)
cooldown_time = 0.5 SECONDS
@@ -324,7 +68,7 @@
incompatible_modules = list(/obj/item/mod/module/insignia)
overlay_state_inactive = "insignia"
/obj/item/mod/module/insignia/generate_worn_overlay(mutable_appearance/standing)
/obj/item/mod/module/insignia/generate_worn_overlay()
overlay_state_inactive = "[initial(overlay_state_inactive)]-[mod.skin]"
. = ..()
for(var/mutable_appearance/appearance as anything in .)