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 565B

123456789101112131415161718192021222324252627282930
  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, b) {
  15. this.collides = true;
  16. this.structures.push(s);
  17. this.structureBounds.push(b);
  18. }
  19. postUpdate() {
  20. this.entities.length = 0;
  21. this.structures.length = 0;
  22. this.structureBounds.length = 0;
  23. this.collides = false;
  24. }
  25. }