Skip to content

Commit

Permalink
timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Dec 26, 2024
1 parent 956f5c0 commit 253ae4d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 15 deletions.
4 changes: 2 additions & 2 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@
#include "code\datums\browser\listpicker.dm"
#include "code\datums\browser\preflikepicker.dm"
#include "code\datums\combo\combo.dm"
#include "code\datums\combo\combo_holder.dm"
#include "code\datums\combo\combo_set.dm"
#include "code\datums\combo\combo_tracker.dm"
#include "code\datums\components\_component.dm"
#include "code\datums\components\anti_magic.dm"
#include "code\datums\components\connect_loc_behalf.dm"
Expand Down Expand Up @@ -1108,7 +1108,7 @@
#include "code\game\click\rig.dm"
#include "code\game\click\telekinesis.dm"
#include "code\game\click\melee\melee_combo.dm"
#include "code\game\click\melee\melee_combo_holder.dm"
#include "code\game\click\melee\melee_combo_tracker.dm"
#include "code\game\click\melee\melee_combo_set.dm"
#include "code\game\content\enigmas\unsorted\cursedform.dm"
#include "code\game\content\enigmas\unsorted\deadringer.dm"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/combo/combo_set.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* ## Hey! Listen!
*
* * A design flaw in how /datum/combo_holder works means that combo sets and their internal combos **will** be hard referenced
* * A design flaw in how /datum/combo_tracker works means that combo sets and their internal combos **will** be hard referenced
* and there's currently no way to inform holders to clear ref when we're being deleted. For now.
* A component signal system will be added later. For now, until we need to start deleting these / runtime-generating,
* please store combo sets in global variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* todo: unit test this shit
*/
/datum/combo_holder
/datum/combo_tracker
/// current stored key sequence, first to last
/// * this is not a lazy list
var/list/stored = list()
Expand All @@ -16,7 +16,7 @@
var/tmp/list/datum/combo/sec_possible
var/tmp/sec_position

/datum/combo_holder/proc/reset()
/datum/combo_tracker/proc/reset()
stored = list()
sec_set = null
sec_possible = null
Expand All @@ -33,11 +33,11 @@
*
* * a shorter combo will always mask a longer one if it is present at any point in the longer one
*/
/datum/combo_holder/proc/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set) as /datum/combo
/datum/combo_tracker/proc/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set) as /datum/combo
stored += inbound
return evaluate_via_tail_match(combo_set)

/datum/combo_holder/proc/evaluate_via_tail_match(datum/combo_set/combo_set) as /datum/combo
/datum/combo_tracker/proc/evaluate_via_tail_match(datum/combo_set/combo_set) as /datum/combo
if(!stored)
return
var/datum/combo/found
Expand Down Expand Up @@ -89,7 +89,7 @@
*
* @return list(datum/combo/resolved, position, finished, list/datum/combo/possible)
*/
/datum/combo_holder/proc/evaluate_inbound_via_stateful_exclusive_chain(inbound, datum/combo_set/combo_set)
/datum/combo_tracker/proc/evaluate_inbound_via_stateful_exclusive_chain(inbound, datum/combo_set/combo_set)
// reset if we changed combos
if(combo_set != sec_set)
sec_set = combo_set
Expand Down
2 changes: 1 addition & 1 deletion code/game/click/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ avoid code duplication. This includes items that may sometimes act as a standard
/mob/living/get_attack_speed_legacy(obj/item/using_item)
var/speed = base_attack_cooldown
if(istype(using_item))
speed = using_item.melee_click_cd_cooldown * using_iwztem.melee_click_cd_multiply
speed = using_item.melee_click_cd_base * using_item.melee_click_cd_multiply
for(var/datum/modifier/M in modifiers)
if(!isnull(M.attack_speed_percent))
speed *= M.attack_speed_percent
Expand Down
6 changes: 0 additions & 6 deletions code/game/click/melee/melee_combo_holder.dm

This file was deleted.

36 changes: 36 additions & 0 deletions code/game/click/melee/melee_combo_tracker.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

/datum/combo_tracker/melee
/// if set, we automatically clear ourselves if nothing happens for this time
var/continuation_timeout = 3 SECONDS
var/tmp/continuation_timeout_active = FALSE
var/tmp/continuation_last

/datum/combo_tracker/melee/New(continuation_timeout)
if(!isnull(continuation_timeout))
src.continuation_timeout = continuation_timeout

/datum/combo_tracker/melee/proc/keep_alive()
continuation_last = world.time
if(!continuation_timeout_active)
on_timeout()

/datum/combo_tracker/melee/proc/on_timeout()
continuation_timeout_active = FALSE
var/remaining_time = continuation_last - (world.time - continuation_timeout)
if(remaining_time < 0)
reset()
return
addtimer(CALLBACK(src, PROC_REF(on_timeout)), remaining_time)
continuation_timeout_active = TRUE

/datum/combo_tracker/melee/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set)
keep_alive()
return ..()

/datum/combo_tracker/melee/evaluate_inbound_via_stateful_exclusive_match(inbound, datum/combo_set/combo_set)
keep_alive()
return ..()

Check failure on line 34 in code/game/click/melee/melee_combo_tracker.dm

View workflow job for this annotation

GitHub Actions / Run Linters

proc has no parent: /datum/combo_tracker/melee/proc/evaluate_inbound_via_stateful_exclusive_match

/datum/combo_tracker/melee/intent_based

0 comments on commit 253ae4d

Please sign in to comment.