TempCups.ts 528 B

123456789101112131415161718192021222324
  1. import { _decorator, Component, Node } from 'cc';
  2. import { TempCup } from './TempCup';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('TempCups')
  5. export class TempCups extends Component {
  6. start() {
  7. }
  8. /** 查找暂存区空杯*/
  9. findAvailableTempCup(): TempCup | null {
  10. // 添加空值检查和类型过滤
  11. return this.node.children
  12. .map(node => node.getComponent(TempCup))
  13. .find(cup => cup && !cup.isFull) || null;
  14. }
  15. update(deltaTime: number) {
  16. }
  17. }