chore: safety

This commit is contained in:
cha0s 2021-02-11 18:07:06 -06:00
parent d227502553
commit 6b5ea8d18a
2 changed files with 8 additions and 5 deletions

View File

@ -122,7 +122,7 @@ export default () => class Mobile extends decorate(Trait) {
},
moveToward: (entity, duration) => {
if (duration <= 0) {
if (!entity.is('Positioned') || duration <= 0) {
return undefined;
}
const calculateMovement = () => Vector.normalize(

View File

@ -121,15 +121,18 @@ export default () => class Positioned extends decorate(Trait) {
methods() {
return {
pointAround: (radius, angle) => (
Vector.add(
pointAround: (radius, angle) => {
if (!this.entity.is('Positioned')) {
return [0, 0];
}
return Vector.add(
this.entity.position,
[
radius * Math.cos(angle),
radius * -Math.sin(angle),
],
)
),
);
},
setPosition: (position) => {
this.trackedPosition = position;