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 {join} from 'path';
import {PropTypes, React} from '@latus/react'; 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'; import Expressions from '../behavior-components/expressions';
const Alive = ({ const Alive = ({
entity, entity,
json, json,
path, path,
}) => ( }) => {
<div className="alive"> const patch = useJsonPatcher();
<div className="label"> return (
<div className="vertical">Death actions</div> <div className="alive">
<Expressions <div className="label">
context={entity.context} <div className="vertical">Death actions</div>
value={json.params.deathActions} <Expressions
path={join(path, 'params/deathActions')} 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>
</div> );
); };
Alive.displayName = 'Alive'; Alive.displayName = 'Alive';
@ -33,7 +71,6 @@ Alive.propTypes = {
expressions: PropTypes.arrayOf(PropTypes.shape({})), expressions: PropTypes.arrayOf(PropTypes.shape({})),
}), }),
deathCondition: PropTypes.shape({}), deathCondition: PropTypes.shape({}),
deathSound: PropTypes.string,
}), }),
state: PropTypes.shape({ state: PropTypes.shape({
life: PropTypes.number, life: PropTypes.number,

View File

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