diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-02 02:22:46 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-02 02:24:18 -0700 |
commit | 06bb4177202b432d5f42141975ec82b5a8837f0e (patch) | |
tree | 7a9cb1e4177684848a3fcca91eed2ec703c787fb /src/engine/components/Highlight.ts | |
parent | cd6a3a56b0a9f27dd7250c7641776fe1bd184888 (diff) | |
download | the-abstraction-engine-06bb4177202b432d5f42141975ec82b5a8837f0e.tar.gz the-abstraction-engine-06bb4177202b432d5f42141975ec82b5a8837f0e.zip |
slight refactor in collision behavior
Diffstat (limited to 'src/engine/components/Highlight.ts')
-rw-r--r-- | src/engine/components/Highlight.ts | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/engine/components/Highlight.ts b/src/engine/components/Highlight.ts index 49d9f96..5875057 100644 --- a/src/engine/components/Highlight.ts +++ b/src/engine/components/Highlight.ts @@ -1,7 +1,33 @@ import { Component, ComponentNames } from "."; export class Highlight extends Component { - constructor() { + public isHighlighted: boolean; + private onHighlight: Function; + private onUnhighlight: Function; + + constructor( + onHighlight: Function, + onUnhighlight: Function, + isHighlighted: boolean = false, + ) { super(ComponentNames.Highlight); + + this.isHighlighted = isHighlighted; + this.onHighlight = onHighlight; + this.onUnhighlight = onUnhighlight; + } + + public highlight() { + if (!this.isHighlighted) { + this.isHighlighted = true; + this.onHighlight(); + } + } + + public unhighlight() { + if (this.isHighlighted) { + this.isHighlighted = false; + this.onUnhighlight(); + } } } |