123456789101112131415161718192021222324252627282930 |
- import {Trait} from "../Entity.js";
-
- export default class Collider extends Trait {
- constructor(entity) {
- super(entity, "collider");
-
- this.collides = false;
- this.entities = [];
- this.structures = [];
- this.structureBounds = [];
- }
-
- collideEntity(e) {
- this.collides = true;
- this.entities.push(e);
- }
-
- collideStructure(s, b) {
- this.collides = true;
- this.structures.push(s);
- this.structureBounds.push(b);
- }
-
- postUpdate() {
- this.entities.length = 0;
- this.structures.length = 0;
- this.structureBounds.length = 0;
- this.collides = false;
- }
- }
|