-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: spells always usable when spellactivation is active (#865)
* chore(spellactivation): first iteration of spell activation glow tracking * chore(spellactivation): rename module name
- Loading branch information
Showing
4 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { AceModule } from "@wowts/tsaddon"; | ||
import aceEvent, { AceEvent } from "@wowts/ace_event-3.0"; | ||
import { DebugTools, Tracer } from "../engine/debug"; | ||
import { OvaleClass } from "../Ovale"; | ||
import { LuaArray } from "@wowts/lua"; | ||
import { | ||
ConditionFunction, | ||
OvaleConditionClass, | ||
returnBoolean, | ||
} from "../engine/condition"; | ||
import { AstFunctionNode, NamedParametersOf } from "../engine/ast"; | ||
import { GetSpellInfo } from "@wowts/wow-mock"; | ||
|
||
export class SpellActivationGlow { | ||
private module: AceModule & AceEvent; | ||
private debug: Tracer; | ||
private spellActivationSpellsShown: LuaArray<boolean> = {}; | ||
|
||
constructor(ovale: OvaleClass, ovaleDebug: DebugTools) { | ||
this.module = ovale.createModule( | ||
"SpellActivationGlow", | ||
this.handleInitialize, | ||
this.handleDisable, | ||
aceEvent | ||
); | ||
this.debug = ovaleDebug.create("SpellActivationGlow"); | ||
} | ||
|
||
private handleInitialize = () => { | ||
this.module.RegisterEvent( | ||
"SPELL_ACTIVATION_OVERLAY_GLOW_SHOW", | ||
this.handleSpellActivationOverlayGlow | ||
); | ||
this.module.RegisterEvent( | ||
"SPELL_ACTIVATION_OVERLAY_GLOW_HIDE", | ||
this.handleSpellActivationOverlayGlow | ||
); | ||
}; | ||
|
||
private handleDisable = () => { | ||
this.module.UnregisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_SHOW"); | ||
this.module.UnregisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_HIDE"); | ||
}; | ||
|
||
private handleSpellActivationOverlayGlow = ( | ||
event: string, | ||
spellId: number | ||
) => { | ||
const spellName = GetSpellInfo(spellId); | ||
this.debug.debug( | ||
"Event %s with spellId %d (%s)", | ||
event, | ||
spellId, | ||
spellName | ||
); | ||
this.spellActivationSpellsShown[spellId] = | ||
event == "SPELL_ACTIVATION_OVERLAY_GLOW_SHOW" || false; | ||
}; | ||
|
||
hasSpellActivationGlow(spellId: number) { | ||
return this.spellActivationSpellsShown[spellId] || false; | ||
} | ||
|
||
public registerConditions(ovaleCondition: OvaleConditionClass) { | ||
ovaleCondition.registerCondition( | ||
"spellactivationglowactive", | ||
false, | ||
this.spellActivationGlowActive | ||
); | ||
ovaleCondition.registerAlias( | ||
"spellactivationglowactive", | ||
"spellactivationglowshown" | ||
); | ||
} | ||
|
||
private spellActivationGlowActive: ConditionFunction = ( | ||
positionalParams: LuaArray<any>, | ||
namedParams: NamedParametersOf<AstFunctionNode>, | ||
atTime: number | ||
) => { | ||
const spellId = positionalParams[1]; | ||
const retValue = this.hasSpellActivationGlow(spellId) || false; | ||
return returnBoolean(retValue); | ||
}; | ||
} |