Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default component values are the same object? #69

Open
esromneb opened this issue Mar 27, 2021 · 0 comments
Open

Default component values are the same object? #69

esromneb opened this issue Mar 27, 2021 · 0 comments

Comments

@esromneb
Copy link
Contributor

esromneb commented Mar 27, 2021

It seems like default values of components are actually the same (Warning I'm on an old release 609c511)

I have this component:

export class UnitBuildQueue extends Component {
static properties = {
    queue: [],
    frameAdded: 0,
  };
};

I have this code:

let e0, e1; // two entities initialized elsewhere
e0.addComponent({
  type: 'UnitBuildQueue',
  key: 'q',
  frameAdded: 10,
});


e1.addComponent({
  type: 'UnitBuildQueue',
  key: 'q',
  frameAdded: 20,
});

e0.c.q.queue.push('foo');

console.log(e1.c.q.queue); // THIS HAS FOO

This is fixed if I instead do this:

e0.addComponent({
  type: 'UnitBuildQueue',
  key: 'q',
  frameAdded: 10,
  queue: [],  // THE FIX
});

Any thoughts? Did this ever get fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant