import { Vector2 } from 'touchcontroller'; import { Anchor } from './Anchor'; import { Rect } from './Rect'; import { Acceptor } from './Acceptor'; export class Donor extends Anchor { public acceptor: Acceptor | null; constructor( rect: Rect, type: string, relativePosition: Vector2, public follow = false, ) { super(rect, type, relativePosition); this.acceptor = null; } clone(): Donor { return new Donor( this.rect, this.type, this.relativePosition, this.follow, ); } release() { if (this.acceptor) { this.acceptor.donors = this.acceptor.donors.filter( (donor) => donor !== this, ); this.acceptor = null; } } }