自动化烹饪流程
This commit is contained in:
@ -1,22 +1,21 @@
|
||||
local CookingSlot = {}
|
||||
local Emitter = require("Utils.Emitter")
|
||||
local CookManager = require("GamePlay.CookSystem.CookManager")
|
||||
local Utils = require("GamePlay.Utils")
|
||||
local ESlateVisibility = import("ESlateVisibility")
|
||||
|
||||
|
||||
|
||||
|
||||
function CookingSlot:ctor()
|
||||
self.cook_item = nil
|
||||
self.material = "500001"
|
||||
end
|
||||
|
||||
function CookingSlot:OnInitialized()
|
||||
self.MainBtn.OnClicked:Add(function()
|
||||
Emitter.EmitEvent("cook_slot_clicked", self)
|
||||
CookManager:AddCookMaterial(self.material)
|
||||
self:ConsumeMaterial()
|
||||
end)
|
||||
self:SetCookMaterial("400009")
|
||||
end
|
||||
|
||||
function CookingSlot:SetCookMaterial(cook_item)
|
||||
self.cook_item = cook_item
|
||||
function CookingSlot:SetCookMaterial(material)
|
||||
self.material = material
|
||||
self:RefreshDisplay()
|
||||
end
|
||||
|
||||
@ -26,14 +25,16 @@ end
|
||||
|
||||
function CookingSlot:RefreshDisplay()
|
||||
self:SetEmpty()
|
||||
if self.cook_item then
|
||||
self.CookingMaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||||
end
|
||||
if not self.material then return end
|
||||
local config = Utils.GetHomelandItemDesc(self.material)
|
||||
if config == nil then return end
|
||||
self.CookingMaterialImg:SetBrushFromSoftTexture(config.DisplayResource, true)
|
||||
self.CookingMaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||||
end
|
||||
|
||||
function CookingSlot:ConsumeMaterial()
|
||||
-- if self.cook_item == nil then return end
|
||||
local item = self.cook_item
|
||||
if self.material == nil then return end
|
||||
local item = self.material
|
||||
self:SetCookMaterial(nil)
|
||||
return item
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user