烹饪基本流程完成
This commit is contained in:
		| @ -1,14 +1,14 @@ | ||||
| local CookManager = {} | ||||
| local Utils = require("GamePlay.Utils") | ||||
| local Emitter = require("Utils.Emitter") | ||||
| local CookMaterialUtils = require("Utils.Cook.CookMaterial") | ||||
| local ECookingHeat = import("ECookingHeat") | ||||
|  | ||||
| --- @enum ECookCheckStatus | ||||
| local ECookCheckStatus = { | ||||
|     Normal = 0,     -- 不用做任何操作 | ||||
|     NextState = 1,  -- 可以进入下一个阶段 | ||||
|     OverCook = 2,   -- 炸锅了,结束游戏 | ||||
|     Error = 3,      -- 出现了错误 | ||||
|     Error = 2,      -- 出现了错误 | ||||
| } | ||||
|  | ||||
| local function TemperatureToDoneness(temperature) | ||||
| @ -16,6 +16,7 @@ local function TemperatureToDoneness(temperature) | ||||
| end | ||||
|  | ||||
| function CookManager:Reset() | ||||
|     self.current_temperature = 0       -- 当前的温度 | ||||
|     self.temperature_thresholds = {}   -- 温度临界值,缓存表格内容 | ||||
|     self.heating_record_table = {}     -- 食材受热记录表 | ||||
|  | ||||
| @ -23,10 +24,11 @@ end | ||||
|  | ||||
| function CookManager:Tick(temperature, delta_time) | ||||
|     local need_remove_record = {}   -- 记录已经到火候,或其他原因,需要移除的食材 | ||||
|     self.current_temperature = temperature | ||||
|  | ||||
|     -- 遍历,为所有的食材加热 | ||||
|     for cook_material_id, record_table in pairs(self.heating_record_table) do | ||||
|         local doneness = TemperatureToDoneness(temperature) -- 获取此时的火候 | ||||
|         local doneness = CookMaterialUtils.TemperatureToDoneness(temperature) -- 获取此时的火候 | ||||
|         local record_value = record_table[doneness] or 0 | ||||
|         record_table[doneness] = record_value + (delta_time * 1000) | ||||
|  | ||||
| @ -54,9 +56,6 @@ end | ||||
|  | ||||
| function CookManager:GetCookMaterialNextState(cook_material_id, doneness) | ||||
|     local threshold = self.temperature_thresholds[cook_material_id] | ||||
|  | ||||
|     print(threshold, "here ---------------") | ||||
|  | ||||
|     if not threshold then return "None" end | ||||
|     local state_config = threshold.CookConfig:Get(doneness) | ||||
|     if not state_config then return "None" end | ||||
| @ -95,5 +94,18 @@ function CookManager:AddCookMaterial(cook_material_id, is_auto_push) | ||||
|     Emitter.EmitEvent("cook_material_change", cook_material_id, is_auto_push) | ||||
| end | ||||
|  | ||||
| function CookManager:UseCookware(cookward_id) | ||||
|     for cook_materiad_id, _ in pairs(self.heating_record_table) do | ||||
|         local next_state = CookMaterialUtils.GetCookwareOpNextState( | ||||
|             cookward_id, cook_materiad_id, self.current_temperature | ||||
|         ) | ||||
|         if next_state ~= "None" then | ||||
|             self:AddCookMaterial(next_state, true) | ||||
|         end | ||||
|     end | ||||
|  | ||||
|     Emitter.EmitEvent("use_cookward", self.cookware_id) | ||||
| end | ||||
|  | ||||
|  | ||||
| return CookManager | ||||
		Reference in New Issue
	
	Block a user