diff --git a/Content/Data/BusyItemDesc.uasset b/Content/Data/BusyItemDesc.uasset index d884469..966c6e8 100644 Binary files a/Content/Data/BusyItemDesc.uasset and b/Content/Data/BusyItemDesc.uasset differ diff --git a/Content/Data/Homeland/BusyHomelandItemDesc.uasset b/Content/Data/Homeland/BusyHomelandItemDesc.uasset index fcb6b49..0e42b57 100644 Binary files a/Content/Data/Homeland/BusyHomelandItemDesc.uasset and b/Content/Data/Homeland/BusyHomelandItemDesc.uasset differ diff --git a/Content/Data/Homeland/CookMaterialStateConfig.uasset b/Content/Data/Homeland/CookMaterialStateConfig.uasset index 0853f4d..f7cea4d 100644 Binary files a/Content/Data/Homeland/CookMaterialStateConfig.uasset and b/Content/Data/Homeland/CookMaterialStateConfig.uasset differ diff --git a/Content/Lua/GamePlay/CookSystem/CookManager.lua b/Content/Lua/GamePlay/CookSystem/CookManager.lua index 621c75a..96f86bc 100644 --- a/Content/Lua/GamePlay/CookSystem/CookManager.lua +++ b/Content/Lua/GamePlay/CookSystem/CookManager.lua @@ -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 \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingPot.lua b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingPot.lua index babc65e..bf81156 100644 --- a/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingPot.lua +++ b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingPot.lua @@ -5,6 +5,7 @@ local Emitter = require("Utils.Emitter") local ESlateVisibility = import("ESlateVisibility") function CookingPot:ctor() + self.cookware_click_handle = nil self.cook_material_change_handle = nil end @@ -16,10 +17,16 @@ function CookingPot:Construct() function(cook_material_id, is_auto_push) self:OnCookMaterialChange(cook_material_id, is_auto_push) end ) + self.cookware_click_handle = Emitter.OnEvent( + "use_cookward", + function(cookware_id) self:OnUseCookware(cookware_id) end + ) + end function CookingPot:Destruct() Emitter.OffEvent("cook_material_change", self.cook_material_change_handle) + Emitter.OffEvent("use_cookward", self.cookware_click_handle) end @@ -34,6 +41,11 @@ function CookingPot:OnCookMaterialChange(cook_material_id, is_auto_push) end end +function CookingPot:OnUseCookware(cookware_id) + self:PlayAnimation(self.Anim_StirFry, 0, 1, 0, 1, false) +end + + function CookingPot:OnCookSlotClicked(config) if config == nil then return end self.MaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible) diff --git a/Content/Lua/HomeLand/UI/Hearth/Widgets/Cookware.lua b/Content/Lua/HomeLand/UI/Hearth/Widgets/Cookware.lua new file mode 100644 index 0000000..624b295 --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/Widgets/Cookware.lua @@ -0,0 +1,22 @@ +---@class Cookware +local Cookware = {} +local Emitter = require("Utils.Emitter") +local CookManager = require("GamePlay.CookSystem.CookManager") + + +function Cookware:OnInitialized() + self.cookware_id = 0 + self.MainBtn.OnClicked:Add(function() + CookManager:UseCookware(self.cookware_id) + end) +end +function Cookware:Construct() + +end + +function Cookware:Destruct() + +end + + +return Class(nil, nil, Cookware) \ No newline at end of file diff --git a/Content/Lua/Utils/Cook/CookMaterial.lua b/Content/Lua/Utils/Cook/CookMaterial.lua new file mode 100644 index 0000000..8bfc97c --- /dev/null +++ b/Content/Lua/Utils/Cook/CookMaterial.lua @@ -0,0 +1,20 @@ +local CookMaterialUtils = {} +local Utils = require("GamePlay.Utils") + +function CookMaterialUtils.TemperatureToDoneness(temperature) + return math.floor(temperature / 70) +end + +function CookMaterialUtils.GetCookwareOpNextState(cookward_id, cook_material_id, temperature) + local config = Utils.GetDataTableConfig( + "CookMaterialStateConfig", cook_material_id + ) + if not config then return nil end + local doneness = CookMaterialUtils.TemperatureToDoneness(temperature) + local doneness_config = config.CookConfig:Get(doneness) + if not doneness_config then return nil end + return doneness_config.CookwareNextStateID +end + + +return CookMaterialUtils \ No newline at end of file diff --git a/Content/Resource/Texture/UI/Homeland/Hearth/wokSpatula.uasset b/Content/Resource/Texture/UI/Homeland/Hearth/wokSpatula.uasset new file mode 100644 index 0000000..367a2b4 Binary files /dev/null and b/Content/Resource/Texture/UI/Homeland/Hearth/wokSpatula.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset index e2df1f7..6ae6145 100644 Binary files a/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset and b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_Cookware.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_Cookware.uasset new file mode 100644 index 0000000..d43280d Binary files /dev/null and b/Content/UI/HomeLand/Hearth/Widgets/WBP_Cookware.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset index 15560cf..f198f29 100644 Binary files a/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset and b/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset differ diff --git a/Source/BusyRabbit/Public/GameAsset/BusyItem.h b/Source/BusyRabbit/Public/GameAsset/BusyItem.h index 60ae63d..57cc010 100644 --- a/Source/BusyRabbit/Public/GameAsset/BusyItem.h +++ b/Source/BusyRabbit/Public/GameAsset/BusyItem.h @@ -98,6 +98,9 @@ struct FBusyCookMaterialStateChangeConfig : public FTableRowBase { UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "用于渐变的资源") TSoftObjectPtr TransformMask; + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "使用厨具后,下一个状态ID") + FName CookwareNextStateID; + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "烹饪时长: Ms") float CookingDuration; };