feat: Fleshed out Alive
This commit is contained in:
parent
589303bede
commit
4194556cb8
|
@ -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,
|
||||
|
|
8
packages/entity/src/trait-components/alive.scss
Normal file
8
packages/entity/src/trait-components/alive.scss
Normal file
|
@ -0,0 +1,8 @@
|
|||
.alive__life {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.alive__life-separator {
|
||||
padding: 0 0.5em;
|
||||
}
|
Loading…
Reference in New Issue
Block a user