You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TCollider.js 495B

12345678910111213141516171819202122232425262728
  1. import {Trait} from "../Entity.js";
  2. export default class Collider extends Trait {
  3. constructor(entity) {
  4. super(entity, "collider");
  5. this.collides = false;
  6. this.entities = [];
  7. this.structures = [];
  8. this.structureBounds = [];
  9. }
  10. collideEntity(e) {
  11. this.collides = true;
  12. this.entities.push(e);
  13. }
  14. collideStructure(s) {
  15. this.collides = true;
  16. this.structures.push(s);
  17. }
  18. postUpdate() {
  19. this.entities.length = 0;
  20. this.structures.length = 0;
  21. this.collides = false;
  22. }
  23. }