var t = require; var e = module; var i = exports; var s, 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}), (i.WaitOrderData = i.OrderDataList = void 0); const a = t("App"), o = t("NodePool"), n = t("OrderData"), r = t("GameConst"), l = t("GlobalAttr"), h = t("BaseService"), c = t("MachineService"), d = t("MapService"), {ccclass: u} = cc._decorator; (s = class extends h.default { constructor() { super(...arguments), (this.orders = null), (this.waitOrderList = null), (this.orderPool = null), (this.globalAttr = null); } onLoad() { s.ins = this; } init() { (this.globalAttr = l.default.ins), (this.waitOrderList = []), (this.orders = {[r.MachineType.type1]: new p(), [r.MachineType.type2]: new p()}), (this.orderPool = new o.default()), (this.orderPool.prefab = d.default.ins.foodBundle.get("Order", cc.Prefab)), a.default.NotificationCenter.addListener(r.GameNotificationConst.UNLOCK_SLOT, this.onUnlockSlot, this); } onUnlockSlot(t) { this.orders[t.machineData.cfg.machine_type].checkHasEmp(); } createOrders(t) { const e = c.default.ins.unlockMachines; if (e.length) { var i = a.default.RandomUtils.shuffle(e.concat()).slice(0, t), s = i.length; const o = []; for (let t = 0; t < s; t++) { const e = new n.default(); (e.machine = i[t]), (o[t] = e), (e.cnt = a.default.RandomUtils.limitInteger(1, e.machine.attr.slotCnt)), this.orders[e.machine.cfg.machine_type].addOrder(e); } return o; } return [this.createOrder()]; } createOrder() { const t = new n.default(); return ( c.default.ins.unlockMachines.length ? ((t.machine = a.default.RandomUtils.randomArray(c.default.ins.unlockMachines)), (t.cnt = a.default.RandomUtils.limitInteger(1, t.machine.attr.slotCnt))) : ((t.machine = c.default.ins.machineDatas[0]), (t.cnt = 1)), this.orders[t.machine.cfg.machine_type].addOrder(t), t ); } finshOrder(t) { const e = this.orders[t.machine.cfg.machine_type]; t.finishOrder(), t.cnt <= 0 && e.orders.remove(t); } }), (s = e([u], s)); i.default = s; class p { constructor() { (this.hasEmp = !1), (this.orders = []); } addOrder(t) { this.orders.push(t), !this.hasEmp && t.canCook() && (this.hasEmp = !0); } cookOrder() { for (const e of this.orders) if (e.canCook()) { e.cookingCnt++; var t = e.startCook(); return this.checkHasEmp(), t; } return null; } checkHasEmp() { for (const t of this.orders) if (t.canCook()) return (this.hasEmp = !0), !0; return (this.hasEmp = !1); } } (i.OrderDataList = p), (i.WaitOrderData = class { constructor() { (this.cb = null), (this.target = null); } });