Skip to content

Commit 1b4393a

Browse files
author
PatrickSachs
committed
Prevent adding leaves on leaves for now
1 parent a314eb1 commit 1b4393a

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/components/App.vue

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ import Locale, { defaultLocale } from "@/Locale";
203203
import BackgroundSkin from "@/BackgroundSkin";
204204
import TreeType from "@/TreeType";
205205
import uuid from "@/utils/uuid";
206+
import LeavesGameObject from "@/gameobjects/LeavesGameObject";
206207
207208
interface IMenuItem {
208209
id: string;
@@ -351,20 +352,22 @@ export default class STApp extends Vue {
351352
}
352353
// todo: Can we somehow use the secondary interact mode for something here?
353354
} else {
354-
const treeType = TreeType.byId(this.tree) || TreeType.random();
355-
this.game!.cmd.execute(
356-
new AddTreeElementCommand(this.scene!.tree, e.element.id, {
357-
id: uuid(),
358-
x: e.x,
359-
y: e.y,
360-
angle: this.angle,
361-
treeType: treeType.id,
362-
elementType:
363-
e.mode === InteractMode.PRIMARY
364-
? TreeElementType.BRANCH
365-
: TreeElementType.LEAVES
366-
})
367-
);
355+
if (!(e.element instanceof LeavesGameObject)) {
356+
const treeType = TreeType.byId(this.tree) || TreeType.random();
357+
this.game!.cmd.execute(
358+
new AddTreeElementCommand(this.scene!.tree, e.element.id, {
359+
id: uuid(),
360+
x: e.x,
361+
y: e.y,
362+
angle: this.angle,
363+
treeType: treeType.id,
364+
elementType:
365+
e.mode === InteractMode.PRIMARY
366+
? TreeElementType.BRANCH
367+
: TreeElementType.LEAVES
368+
})
369+
);
370+
}
368371
}
369372
this.cache();
370373
}

src/gameobjects/LeavesGameObject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ export default class LeavesGameObject extends TreeElement<JSON> {
111111
}
112112

113113
addLeaves(details: ITreeElementDetails): LeavesGameObject {
114+
// todo: Allow leaves on leaves
114115
throw new Error("Not supported.");
115116
}
116117

@@ -129,7 +130,7 @@ export default class LeavesGameObject extends TreeElement<JSON> {
129130
this.treeType = TreeType.byId(json.treeType) || TreeType.BROADLEAF;
130131
}
131132

132-
/**
133+
/**
133134
* Called whenever the mous eleaves the branch.
134135
* @param e The pointer event.
135136
*/

0 commit comments

Comments
 (0)