feat: condition

This commit is contained in:
cha0s 2021-02-06 20:17:57 -06:00
parent bfeeb6c318
commit 9b87f9ea74
2 changed files with 19 additions and 0 deletions

View File

@ -203,6 +203,23 @@ const Expression = ({
if ('any' === arg.type) { if ('any' === arg.type) {
return {type: 'undefined'}; return {type: 'undefined'};
} }
if ('condition' === arg.type) {
return {
...(false === arg.compile ? {compile: false} : {}),
type: 'condition',
operator: 'and',
operands: [
{
type: 'literal',
value: true,
},
{
type: 'literal',
value: true,
},
],
};
}
if ('expressions' === arg.type) { if ('expressions' === arg.type) {
return { return {
type: 'expressions', type: 'expressions',

View File

@ -2,6 +2,7 @@ import {basename, extname} from 'path';
import {camelCase} from '@latus/core'; import {camelCase} from '@latus/core';
import Condition from './behavior-components/condition';
import Expression from './behavior-components/expression'; import Expression from './behavior-components/expression';
import Expressions from './behavior-components/expressions'; import Expressions from './behavior-components/expressions';
import Literal from './behavior-components/literal'; import Literal from './behavior-components/literal';
@ -21,6 +22,7 @@ export default {
const TraitRenderers = latus.invokeReduce('@persea/entity/trait-components'); const TraitRenderers = latus.invokeReduce('@persea/entity/trait-components');
latus.set('%trait-components', TraitRenderers); latus.set('%trait-components', TraitRenderers);
latus.set('%behavior-controllers', { latus.set('%behavior-controllers', {
condition: Condition,
expression: Expression, expression: Expression,
expressions: Expressions, expressions: Expressions,
literal: Literal, literal: Literal,