自动化烹饪流程
This commit is contained in:
		| @ -1,26 +1,43 @@ | ||||
| -- 锅的控件 | ||||
| local CookingPot = {} | ||||
| local Utils = require("GamePlay.Utils") | ||||
| local Emitter = require("Utils.Emitter") | ||||
| local ESlateVisibility = import("ESlateVisibility") | ||||
|  | ||||
| function CookingPot:ctor() | ||||
|     self.cook_slot_clicked_handle = nil | ||||
|     self.cook_material_change_handle = nil | ||||
| end | ||||
|  | ||||
|  | ||||
| function CookingPot:Construct() | ||||
|     self.cook_slot_clicked_handle = Emitter.OnEvent( | ||||
|         "cook_slot_clicked", | ||||
|         function(slot) self:OnCookSlotClicked(slot) end | ||||
|     self.MaterialImg:SetVisibility(ESlateVisibility.Collapsed) | ||||
|     self.cook_material_change_handle = Emitter.OnEvent( | ||||
|         "cook_material_change", | ||||
|         function(cook_material_id, is_auto_push) self:OnCookMaterialChange(cook_material_id, is_auto_push) end | ||||
|     ) | ||||
|  | ||||
| end | ||||
|  | ||||
| function CookingPot:Destruct() | ||||
|     Emitter.OffEvent("cook_slot_clicked", self.cook_slot_clicked_handle) | ||||
|     Emitter.OffEvent("cook_material_change", self.cook_material_change_handle) | ||||
| end | ||||
|  | ||||
| function CookingPot:OnCookSlotClicked(slot) | ||||
|     local item = slot:ConsumeMaterial() | ||||
|     if item == nil then  end | ||||
|  | ||||
| function CookingPot:OnCookMaterialChange(cook_material_id, is_auto_push) | ||||
|     print(cook_material_id, is_auto_push) | ||||
|     local config = Utils.GetHomelandItemDesc(cook_material_id) | ||||
|     if config == nil then return end | ||||
|     self.MaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible) | ||||
|     self.MaterialImg:SetBrushFromSoftTexture(config.DisplayResource, true) | ||||
|     if not is_auto_push then | ||||
|         self:PlayAnimation(self.Anim_Cook, 0, 1, 0, 1, false) | ||||
|     end | ||||
| end | ||||
|  | ||||
| function CookingPot:OnCookSlotClicked(config) | ||||
|     if config == nil then return end | ||||
|     self.MaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible) | ||||
|     self.MaterialImg:SetBrushFromSoftTexture(config.DisplayResource, true) | ||||
|     self:PlayAnimation(self.Anim_Cook, 0, 1, 0, 1, false) | ||||
| end | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user