summaryrefslogtreecommitdiff
path: root/src/engine/components/Highlight.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-02 02:22:46 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-03-02 02:24:18 -0700
commit06bb4177202b432d5f42141975ec82b5a8837f0e (patch)
tree7a9cb1e4177684848a3fcca91eed2ec703c787fb /src/engine/components/Highlight.ts
parentcd6a3a56b0a9f27dd7250c7641776fe1bd184888 (diff)
downloadthe-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.ts28
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();
+ }
}
}