-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aba6b1f
commit 4d56757
Showing
17 changed files
with
210 additions
and
102 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
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
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 |
---|---|---|
@@ -1,13 +1,29 @@ | ||
import { IfNode } from '../if_else' | ||
import { ConditionNode } from './condition' | ||
|
||
import type { SandstoneCore } from '#core' | ||
|
||
export class OrNode extends ConditionNode { | ||
variable | ||
|
||
constructor(sandstoneCore: SandstoneCore, public conditions: ConditionNode[]) { | ||
super(sandstoneCore) | ||
} | ||
|
||
getValue = (negated?: boolean | undefined) => { | ||
throw new Error('OR conditions must be postprocessed.') | ||
const { Variable, _ } = sandstoneCore.pack | ||
|
||
this.variable = Variable(undefined, 'condition') | ||
|
||
const currentNode = this.sandstoneCore.getCurrentMCFunctionOrThrow() | ||
|
||
currentNode.resource.push(() => { | ||
this.variable.reset() | ||
|
||
for (const condition of conditions) { | ||
// eslint-disable-next-line no-new | ||
new IfNode(sandstoneCore, condition, () => this.variable.add(1), false) | ||
} | ||
}) | ||
} | ||
|
||
getValue = (negated?: boolean | undefined) => this.variable.matches('1..')._toMinecraftCondition().getValue(negated) | ||
} |
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,14 @@ | ||
import { SingleExecuteNode } from './condition' | ||
|
||
import type { Score } from 'sandstone/variables/Score' | ||
import type { SandstoneCore } from '#core' | ||
|
||
export class SuccessConditionNode extends SingleExecuteNode { | ||
constructor(sandstoneCore: SandstoneCore, readonly score: Score) { | ||
super(sandstoneCore) | ||
} | ||
|
||
getCondition(): unknown[] { | ||
return ['store', 'success', 'score', this.score] | ||
} | ||
} |
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
Oops, something went wrong.