var t = require; var e = module; var i = exports; e = (this && this.__decorate) || function (t, e, i, s) { var o, a = arguments.length, n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s); else for (var r = t.length - 1; 0 <= r; r--) (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n); return 3 < a && n && Object.defineProperty(e, i, n), n; }; Object.defineProperty(i, "__esModule", {value: !0}); const s = t("App"), o = t("SoundEffectConst"), a = t("GameConst"), n = t("DeskService"), r = t("MapService"), l = t("OrderService"), h = t("RoleService"), c = t("BaseMan"), d = t("ChefAI"), u = t("MoveComponent"), {ccclass: p} = cc._decorator; e = e( [p], (e = class extends d.default { constructor() { super(...arguments), (this.man = null); } onLoad() { (this.man = this.getComponent(c.default)), (this.move = this.getComponent(u.default)), (this.orderDataList = l.default.ins.orders[a.MachineType.type1]); } think() { if (n.default.ins.cookDatas.length) return ( (this.cookData = n.default.ins.cookDatas.pop()), this.move.moveTo(this.cookData.passSectionData.waiter.pos), void (this.state = d.AI_STATE.MOVE_TO_SEND_FOOD) ); if (this.orderDataList.hasEmp) { const t = (this.cookData = this.orderDataList.cookOrder()); return ( t.init(this.man), this.move.moveTo(t.slot.chefPos), void (this.state = d.AI_STATE.MOVE_TO_COOKING) ); } if (l.default.ins.waitOrderList.length) return ( (this.waitOrderData = l.default.ins.waitOrderList.pop()), this.move.moveTo(this.waitOrderData.pos), void (this.state = d.AI_STATE.MOVE_TO_ORDERING) ); this.state !== d.AI_STATE.MOVE_TO_REST && this.state !== d.AI_STATE.REST && this.state !== d.AI_STATE.DEEP_REST && (this.move.moveTo(this.man.basePos), (this.state = d.AI_STATE.MOVE_TO_REST)); } update(t) { if (this.man.state === c.CharactorState.stand) switch (this.state) { case d.AI_STATE.NONE: this.think(); break; case d.AI_STATE.DEEP_REST: this.think(), this.state !== d.AI_STATE.DEEP_REST && h.default.ins.showLang(this.node, a.RoleLangType.WALK_UP); break; case d.AI_STATE.REST: if ((this.think(), this.state !== d.AI_STATE.REST)) break; (this.leftTime -= t), this.leftTime < 0 && (this.man.playAni("sleep2"), (this.state = d.AI_STATE.DEEP_REST)); break; case d.AI_STATE.MOVE_TO_SEND_FOOD: this.move.moveTo(this.cookData.order.customer.posData.staff.pos), this.cookData.passSectionData.removeCookData(this.cookData), this.man.showFood(this.cookData.order.display.food.spriteFrame, this.cookData.foodValue), (this.state = d.AI_STATE.SEND_FOOD), (this.man.state = c.CharactorState.send_food); break; case d.AI_STATE.MOVE_TO_ORDERING: (this.man.direction = this.waitOrderData.direction), (this.maxTime = r.default.ins.define.crew_order_time), (this.leftTime = 0), (this.man.progress.progress = this.leftTime / this.maxTime), (this.man.progress.node.active = !0), (this.state = d.AI_STATE.ORDERING); break; case d.AI_STATE.MOVE_TO_COOKING: this.onMoveToCookingFinish(); break; case d.AI_STATE.ORDERING: if (((this.leftTime += t), this.leftTime < this.maxTime)) { this.man.progress.progress = this.leftTime / this.maxTime; break; } (this.man.progress.node.active = !1), this.waitOrderData.cb.call(this.waitOrderData.target), (this.waitOrderData = null), (this.state = d.AI_STATE.NONE), s.default.SoundManager.playEffect(o.SoundsDefine.MIAOW), h.default.ins.showLang(this.node, a.RoleLangType.ORDER_FINISH); break; case d.AI_STATE.COOKING: this.onCooking(t); break; case d.AI_STATE.SEND_FOOD: this.cookData.finishOrder(), this.man.hideFood(), (this.cookData = null), (this.state = d.AI_STATE.NONE), s.default.SoundManager.playEffect("get_coin2"); break; case d.AI_STATE.MOVE_TO_REST: this.moveToRest(); } else this.man.state === c.CharactorState.run && this.state === d.AI_STATE.MOVE_TO_REST && this.think(); } onCooking(t) { (this.leftTime += t), this.leftTime < this.maxTime ? (this.man.progress.progress = this.leftTime / this.maxTime) : (s.default.SoundManager.playEffect(o.SoundsDefine.COOK_FINISH), (this.man.progress.node.active = !1), (t = this.man.getPerfectDishRate()), this.cookData.finishCook(t && t > Math.random()), this.orderDataList.checkHasEmp(), this.move.moveTo(this.cookData.order.customer.posData.staff.pos), this.man.showFood(this.cookData.order.display.food.spriteFrame, this.cookData.foodValue), (this.man.state = c.CharactorState.send_food), (this.state = d.AI_STATE.SEND_FOOD), this.man.removeFire(), h.default.ins.showLang(this.node, a.RoleLangType.MACHINE_FINISH)); } }) ); i.default = e;