feat: Fleshed out Alive

This commit is contained in:
cha0s 2021-02-02 01:22:50 -06:00
parent 589303bede
commit 4194556cb8
2 changed files with 57 additions and 12 deletions

View File

@ -1,25 +1,63 @@
import {join} from 'path';
import {PropTypes, React} from '@latus/react';
import {Number} from '@persea/core';
import {useJsonPatcher} from '@persea/json';
import Condition from '../behavior-components/condition';
import Expressions from '../behavior-components/expressions';
const Alive = ({
entity,
json,
path,
}) => (
<div className="alive">
<div className="label">
<div className="vertical">Death actions</div>
<Expressions
context={entity.context}
value={json.params.deathActions}
path={join(path, 'params/deathActions')}
/>
}) => {
const patch = useJsonPatcher();
return (
<div className="alive">
<div className="label">
<div className="vertical">Death actions</div>
<Expressions
context={entity.context}
value={json.params.deathActions}
path={join(path, 'params/deathActions')}
/>
</div>
<div className="label">
<div className="vertical">Death condition</div>
<Condition
context={entity.context}
value={json.params.deathCondition}
path={join(path, 'params/deathCondition')}
/>
</div>
<label>
Life
<div className="alive__life">
<Number
onChange={(event, value) => {
patch({
path: join(path, 'state/life'),
value,
});
}}
value={json.state.life}
/>
<div className="alive__life-separator">/</div>
<Number
onChange={(event, value) => {
patch({
path: join(path, 'state/maxLife'),
value,
});
}}
value={json.state.maxLife}
/>
</div>
</label>
</div>
</div>
);
);
};
Alive.displayName = 'Alive';
@ -33,7 +71,6 @@ Alive.propTypes = {
expressions: PropTypes.arrayOf(PropTypes.shape({})),
}),
deathCondition: PropTypes.shape({}),
deathSound: PropTypes.string,
}),
state: PropTypes.shape({
life: PropTypes.number,

View File

@ -0,0 +1,8 @@
.alive__life {
align-items: center;
display: flex;
}
.alive__life-separator {
padding: 0 0.5em;
}