Skip to content

Commit

Permalink
buffs are now SIGNALS, work with holders
Browse files Browse the repository at this point in the history
  • Loading branch information
Doubleumc committed Nov 13, 2023
1 parent e4399d6 commit 9fdbc1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
15 changes: 9 additions & 6 deletions code/modules/vehicles/hardpoints/hardpoint.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,18 @@

/// Apply hardpoint effects to vehicle and self.
/obj/item/hardpoint/proc/on_install(obj/vehicle/multitile/vehicle)
if(!vehicle) //in loose holder
return
RegisterSignal(vehicle, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES, PROC_REF(recalculate_hardpoint_bonuses))
apply_buff(vehicle)
recalculate_hardpoint_bonuses()
return

/// Remove hardpoint effects from vehicle and self.
/obj/item/hardpoint/proc/on_uninstall(obj/vehicle/multitile/vehicle)
if(!vehicle) //in loose holder
return
UnregisterSignal(vehicle, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES)
remove_buff(vehicle)
recalculate_hardpoint_bonuses()
return
//resetting values like set_gun_config_values() would be tidy, but unnecessary as it gets recalc'd on install anyway

/// Applying passive buffs like damage type resistance, speed, accuracy, cooldowns.
/obj/item/hardpoint/proc/apply_buff(obj/vehicle/multitile/vehicle)
Expand All @@ -214,7 +217,7 @@
for(var/type in buff_multipliers)
vehicle.misc_multipliers[type] *= LAZYACCESS(buff_multipliers, type)
buff_applied = TRUE
vehicle.on_modifiers_change()
SEND_SIGNAL(vehicle, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES)

/// Removing passive buffs like damage type resistance, speed, accuracy, cooldowns.
/obj/item/hardpoint/proc/remove_buff(obj/vehicle/multitile/vehicle)
Expand All @@ -227,7 +230,7 @@
for(var/type in buff_multipliers)
vehicle.misc_multipliers[type] *= 1 / LAZYACCESS(buff_multipliers, type)
buff_applied = FALSE
vehicle.on_modifiers_change()
SEND_SIGNAL(vehicle, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES)

/// Recalculates hardpoint values based on vehicle modifiers.
/obj/item/hardpoint/proc/recalculate_hardpoint_bonuses()
Expand Down
19 changes: 15 additions & 4 deletions code/modules/vehicles/hardpoints/holder/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,21 @@
for(var/obj/item/hardpoint/H in hardpoints)
H.take_damage(damage)

/obj/item/hardpoint/holder/on_install(obj/vehicle/multitile/V)
for(var/obj/item/hardpoint/HP in hardpoints)
HP.owner = V
return
/obj/item/hardpoint/holder/on_install(obj/vehicle/multitile/vehicle)
..()
if(!vehicle) //in loose holder
return
for(var/obj/item/hardpoint/hardpoint in hardpoints)
hardpoint.owner = vehicle
hardpoint.on_install(vehicle)

/obj/item/hardpoint/holder/on_uninstall(obj/vehicle/multitile/vehicle)
if(!vehicle) //in loose holder
return
for(var/obj/item/hardpoint/hardpoint in hardpoints)
hardpoint.on_uninstall(vehicle)
hardpoint.owner = null
..()

/obj/item/hardpoint/holder/proc/can_install(obj/item/hardpoint/H)
// Can only have 1 hardpoint of each slot type
Expand Down
6 changes: 0 additions & 6 deletions code/modules/vehicles/multitile/multitile_hardpoints.dm
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,3 @@
qdel(old)

update_icon()

/// Trigger vehicle hardpoints to update values based on new modifiers.
/obj/vehicle/multitile/proc/on_modifiers_change() //should this be a signal?
var/list/hardpoints = get_hardpoints_copy() //could be more selective with get_hardpoints_with_ammo(), as only autofire weapons need it
for(var/obj/item/hardpoint/hardpoint in hardpoints)
hardpoint.recalculate_hardpoint_bonuses()

0 comments on commit 9fdbc1b

Please sign in to comment.