summaryrefslogtreecommitdiff
path: root/src/engine/components/Highlight.ts
diff options
context:
space:
mode:
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();
+ }
}
}