diff --git a/.emmyrc.json b/.emmyrc.json new file mode 100644 index 0000000..18bba0e --- /dev/null +++ b/.emmyrc.json @@ -0,0 +1,93 @@ +{ + "completion": { + "enable": true, + "autoRequire": true, + "autoRequireFunction": "require", + "autoRequireNamingConvention": "keep", + "autoRequireSeparator": ".", + "callSnippet": false, + "postfix": "@", + "baseFunctionIncludesName": true + }, + "diagnostics": { + "disable": [ + "unnecessary-if" + ], + "enable": true, + "globals": [], + "globalsRegex": [], + "severity": {}, + "enables": [], + "diagnosticInterval": 500 + }, + "signature": { + "detailSignatureHelper": true + }, + "hint": { + "enable": true, + "paramHint": true, + "indexHint": true, + "localHint": true, + "overrideHint": true, + "metaCallHint": true + }, + "runtime": { + "version": "LuaLatest", + "requireLikeFunction": [], + "frameworkVersions": [], + "extensions": [], + "requirePattern": [], + "classDefaultCall": { + "functionName": "", + "forceNonColon": false, + "forceReturnSelf": false + } + }, + "workspace": { + "ignoreDir": [], + "ignoreGlobs": [], + "library": [], + "workspaceRoots": [], + "preloadFileSize": 0, + "encoding": "utf-8", + "moduleMap": [], + "reindexDuration": 5000, + "enableReindex": false + }, + "resource": { + "paths": [] + }, + "codeLens": { + "enable": true + }, + "strict": { + "requirePath": false, + "typeCall": false, + "arrayIndex": true, + "metaOverrideFileDefine": true, + "docBaseConstMatchBaseType": true + }, + "semanticTokens": { + "enable": true + }, + "references": { + "enable": true, + "fuzzySearch": true, + "shortStringSearch": false + }, + "hover": { + "enable": true + }, + "documentColor": { + "enable": true + }, + "codeAction": { + "insertSpace": false + }, + "inlineValues": { + "enable": true + }, + "doc": { + "privateName": [] + } +} \ No newline at end of file diff --git a/Config/DefaultGameplayTags.ini b/Config/DefaultGameplayTags.ini index 453eb23..da7183b 100644 --- a/Config/DefaultGameplayTags.ini +++ b/Config/DefaultGameplayTags.ini @@ -20,8 +20,18 @@ NetIndexFirstBitSegment=16 +GameplayTagList=(Tag="Change.Role.Health",DevComment="角色生命值发生的变动") +GameplayTagList=(Tag="Change.Role.Hunger",DevComment="角色饥饿值发生变动") +GameplayTagList=(Tag="Change.Role.MoveSpeed",DevComment="改变角色移动速度") ++GameplayTagList=(Tag="CookProcess",DevComment="烹饪加工") ++GameplayTagList=(Tag="CookProcess.Cubed",DevComment="切块") ++GameplayTagList=(Tag="CookProcess.Diced",DevComment="切丁") ++GameplayTagList=(Tag="CookProcess.Mashed",DevComment="切泥") ++GameplayTagList=(Tag="CookProcess.Sliced",DevComment="切片操作") +GameplayTagList=(Tag="GameItem.Building",DevComment="建筑物") +GameplayTagList=(Tag="GameItem.Food",DevComment="游戏内的可食用物品") ++GameplayTagList=(Tag="Ingredient",DevComment="烹饪食材") ++GameplayTagList=(Tag="Ingredient.Fruit",DevComment="水果类食材") ++GameplayTagList=(Tag="Ingredient.Fruit.Apple",DevComment="苹果") ++GameplayTagList=(Tag="Ingredient.Vegetable",DevComment="蔬菜类食材") ++GameplayTagList=(Tag="Ingredient.Vegetable.Carrot",DevComment="胡萝卜") +GameplayTagList=(Tag="Recover.Role.Health",DevComment="回复生命值") +GameplayTagList=(Tag="Recover.Role.Hunger",DevComment="恢复饥饿值") +GameplayTagList=(Tag="Status.Role.Invincible",DevComment="不掉血标签") diff --git a/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset index 782bd11..2ef9319 100644 Binary files a/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset and b/Content/Blueprint/HomeLand/Bp_HomeLandHud.uasset differ diff --git a/Content/Data/Items/BusyLevelItemDesc.uasset b/Content/Data/Items/BusyLevelItemDesc.uasset index fe88669..bddd5c5 100644 Binary files a/Content/Data/Items/BusyLevelItemDesc.uasset and b/Content/Data/Items/BusyLevelItemDesc.uasset differ diff --git a/Content/Lua/@types/UE.d.lua b/Content/Lua/@types/UE.d.lua index 5bb51e2..8deed1e 100644 --- a/Content/Lua/@types/UE.d.lua +++ b/Content/Lua/@types/UE.d.lua @@ -22,3 +22,8 @@ function Class(a, b, c) end slua = { createDelegate = function(func) end } + +--- @class KismetSystemLibrary +KismetSystemLibrary = { + K2_ClearTimerHandle = function() end +} diff --git a/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua b/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua index 3045612..23d9bf6 100644 --- a/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua +++ b/Content/Lua/HomeLand/UI/Hearth/HearthMain.lua @@ -5,6 +5,9 @@ function HearthMain:OnInitialized() self.BtnBack.OnClicked:Add(function() WidgetUtils.Hide(self, "HearthMain") end) + self.BtnOpenRecipe.OnClicked:Add(function() + WidgetUtils.Show(self, "RecipeMenu") + end) end diff --git a/Content/Lua/HomeLand/UI/Hearth/RecipeMenu.lua b/Content/Lua/HomeLand/UI/Hearth/RecipeMenu.lua new file mode 100644 index 0000000..087f2cf --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/RecipeMenu.lua @@ -0,0 +1,19 @@ +local WidgetUtils = require("Utils.UI.WidgetUtils") +local RecipeMenu = {} + +function RecipeMenu:OnInitialized() + self.BtnConfirm.OnClicked:Add(function() + WidgetUtils.Hide(self, "RecipeMenu") + local work_top = WidgetUtils.Show(self, "HearthWorkTop") + if work_top ~= nil then + work_top:setup_task() + end + end) + + self.BtnClose.OnClicked:Add(function() + WidgetUtils.Hide(self, "RecipeMenu") + end) + +end + +return Class(nil, nil, RecipeMenu) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingBench.lua b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingBench.lua new file mode 100644 index 0000000..6b83d62 --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingBench.lua @@ -0,0 +1,79 @@ +local CookingBench = {} +local KismetSystemLibrary = import("KismetSystemLibrary") +local ESlateVisibility = import("ESlateVisibility") + +function CookingBench:ctor() + self.is_cooking = false + self.temperature = 0 + self.max_temperature = 200 + self.burn_timer = nil +end + +function CookingBench:OnInitialized() + self.WBP_Rabbit.OnClicked:Add(function() self:OnRabbitClicked()end) +end + +function CookingBench:Construct() + self:UpdateCookState() + self:UpdateFireState() +end + + +function CookingBench:Destruct() + self.is_cooking = false + self:UpdateFireState() +end + + +function CookingBench:OnRabbitClicked() + if self.is_cooking then + local new_value = self.temperature + 8 + if new_value > self.max_temperature then + self.temperature = self.max_temperature + else + self.temperature = new_value + end + else + self.is_cooking = true + self.temperature = 100 + self.burn_timer = KismetSystemLibrary.K2_SetTimerDelegate( + slua.createDelegate(function() + local new_value = self.temperature - 1 + if new_value > 0 then + self.temperature = new_value + else + self.temperature = 0 + self.is_cooking = false + KismetSystemLibrary.K2_ClearTimerHandle(self, self.burn_timer) + self.burn_timer = nil + end + self:UpdateCookState() + self:UpdateFireState() + end), + 0.1, true, true, 0, 0 + ) + end + self:UpdateCookState() + self:UpdateFireState() +end + +function CookingBench:UpdateCookState() + if self.temperature > 0 then + self.WBP_CookingProcess:SetVisible(true) + local percent = self.temperature / self.max_temperature + self.WBP_CookingProcess.TemperatureProcess:SetPercent(percent) + else + self.WBP_CookingProcess:SetVisible(false) + end +end + +function CookingBench:UpdateFireState() + if self.is_cooking == true then + self.CookingFireImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible) + else + self.CookingFireImg:SetVisibility(ESlateVisibility.Collapsed) + end +end + + +return Class(nil, nil, CookingBench) \ 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 new file mode 100644 index 0000000..e101d9f --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingPot.lua @@ -0,0 +1,28 @@ +-- 锅的控件 +local CookingPot = {} +local Emitter = require("Utils.Emitter") + +function CookingPot:ctor() + self.cook_slot_clicked_handle = nil +end + + +function CookingPot:Construct() + self.cook_slot_clicked_handle = Emitter.OnEvent( + "cook_slot_clicked", + function(slot) self:OnCookSlotClicked(slot) end + ) +end + +function CookingPot:Destruct() + Emitter.OffEvent("cook_slot_clicked", self.cook_slot_clicked_handle) +end + +function CookingPot:OnCookSlotClicked(slot) + local item = slot:ConsumeMaterial() + if item == nil then end + self:PlayAnimation(self.Anim_Cook, 0, 1, 0, 1, false) +end + + +return Class(nil, nil, CookingPot) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingSlot.lua b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingSlot.lua new file mode 100644 index 0000000..efe507c --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/Widgets/CookingSlot.lua @@ -0,0 +1,42 @@ +local CookingSlot = {} +local Emitter = require("Utils.Emitter") +local ESlateVisibility = import("ESlateVisibility") + + + + +function CookingSlot:ctor() + self.cook_item = nil +end + +function CookingSlot:OnInitialized() + self.MainBtn.OnClicked:Add(function() + Emitter.EmitEvent("cook_slot_clicked", self) + end) +end + +function CookingSlot:SetCookMaterial(cook_item) + self.cook_item = cook_item + self:RefreshDisplay() +end + +function CookingSlot:SetEmpty() + self.CookingMaterialImg:SetVisibility(ESlateVisibility.Collapsed) +end + +function CookingSlot:RefreshDisplay() + self:SetEmpty() + if self.cook_item then + self.CookingMaterialImg:SetVisibility(ESlateVisibility.SelfHitTestInvisible) + end +end + +function CookingSlot:ConsumeMaterial() + -- if self.cook_item == nil then return end + local item = self.cook_item + self:SetCookMaterial(nil) + return item +end + + +return Class(nil, nil, CookingSlot) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/WorkTop/IngredientsWidget.lua b/Content/Lua/HomeLand/UI/Hearth/WorkTop/IngredientsWidget.lua new file mode 100644 index 0000000..aec7fe7 --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/WorkTop/IngredientsWidget.lua @@ -0,0 +1,4 @@ +local IngredientsWidget = {} + + +return Class(nil, nil, IngredientsWidget) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTableWidget.lua b/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTableWidget.lua new file mode 100644 index 0000000..305442d --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTableWidget.lua @@ -0,0 +1,3 @@ +local WorkTableWidget = {} + +return Class(nil, nil, WorkTableWidget) \ No newline at end of file diff --git a/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTopPanel.lua b/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTopPanel.lua new file mode 100644 index 0000000..3275bda --- /dev/null +++ b/Content/Lua/HomeLand/UI/Hearth/WorkTop/WorkTopPanel.lua @@ -0,0 +1,17 @@ +local WidgetUtils = require("Utils.UI.WidgetUtils") +local WorkTopPanel = {} + +function WorkTopPanel:OnInitialized() + self.BtnBack.OnClicked:Add(function() + WidgetUtils.Hide(self, "HearthWorkTop") + end) + self.BtnNext.OnClicked:Add(function() + WidgetUtils.Hide(self, "HearthWorkTop") + end) +end + +function WorkTopPanel:setup_task() + +end + +return Class(nil, nil, WorkTopPanel) \ No newline at end of file diff --git a/Content/Lua/Utils/Emitter.lua b/Content/Lua/Utils/Emitter.lua new file mode 100644 index 0000000..1b3f4c9 --- /dev/null +++ b/Content/Lua/Utils/Emitter.lua @@ -0,0 +1,53 @@ +local Emitter = { + EventHandlers = {} +} + +-- 注册事件监听 +function Emitter.OnEvent(eventName, handler) + if not eventName or type(handler) ~= "function" then + print("[EventSystem] Invalid event registration") + return + end + + if not Emitter.EventHandlers[eventName] then + Emitter.EventHandlers[eventName] = {} + end + + table.insert(Emitter.EventHandlers[eventName], handler) + return handler -- 返回handler用于注销 +end + +-- 触发事件 +function Emitter.EmitEvent(eventName, ...) + local handlers = Emitter.EventHandlers[eventName] + if not handlers then return end + + print("[EventSystem] Emitting event: " .. eventName) + for i = #handlers, 1, -1 do -- 倒序遍历允许在回调中移除事件 + local success, err = pcall(handlers[i], ...) + if not success then + print("[EventSystem] Error in handler: " .. tostring(err)) + end + end +end + +-- 注销事件 +function Emitter.OffEvent(eventName, handler) + local handlers = Emitter.EventHandlers[eventName] + if not handlers then return end + + for i = #handlers, 1, -1 do + if handlers[i] == handler then + table.remove(handlers, i) + end + end + + if #handlers == 0 then + Emitter.EventHandlers[eventName] = nil + end +end + + + + +return Emitter \ No newline at end of file diff --git a/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset b/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset index 94a4c84..94a694d 100644 Binary files a/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset and b/Content/UI/HomeLand/Hearth/WBP_HearthMain.uasset differ diff --git a/Content/UI/HomeLand/Hearth/WBP_RecipeMenu.uasset b/Content/UI/HomeLand/Hearth/WBP_RecipeMenu.uasset new file mode 100644 index 0000000..5fd2134 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/WBP_RecipeMenu.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset new file mode 100644 index 0000000..2907153 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingBench.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingProcess.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingProcess.uasset new file mode 100644 index 0000000..67cfc93 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingProcess.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingSlot.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingSlot.uasset new file mode 100644 index 0000000..aef710a Binary files /dev/null and b/Content/UI/HomeLand/Hearth/Widgets/WBP_CookingSlot.uasset differ diff --git a/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset b/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset new file mode 100644 index 0000000..b2b9ca7 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/Widgets/WBP_PotWidget.uasset differ diff --git a/Content/UI/HomeLand/Hearth/WorkTop/WBP_Ingredients.uasset b/Content/UI/HomeLand/Hearth/WorkTop/WBP_Ingredients.uasset new file mode 100644 index 0000000..5aa51d1 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/WorkTop/WBP_Ingredients.uasset differ diff --git a/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTable.uasset b/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTable.uasset new file mode 100644 index 0000000..12aac55 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTable.uasset differ diff --git a/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTop.uasset b/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTop.uasset new file mode 100644 index 0000000..085c2f4 Binary files /dev/null and b/Content/UI/HomeLand/Hearth/WorkTop/WBP_WorkTop.uasset differ diff --git a/Source/BusyRabbit/BusyRabbit.Build.cs b/Source/BusyRabbit/BusyRabbit.Build.cs index 1a18519..9370844 100644 --- a/Source/BusyRabbit/BusyRabbit.Build.cs +++ b/Source/BusyRabbit/BusyRabbit.Build.cs @@ -11,8 +11,7 @@ public class BusyRabbit : ModuleRules PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "Paper2D", "UMG", "Slate", - "GameplayAbilities", "GameplayTags","GameplayTasks", - "UnrealEd" + "GameplayAbilities", "GameplayTags","GameplayTasks" }); PrivateDependencyModuleNames.AddRange(new string[] { }); diff --git a/Source/BusyRabbit/Public/GameAsset/BusyItem.h b/Source/BusyRabbit/Public/GameAsset/BusyItem.h index 8cd688c..6b65a90 100644 --- a/Source/BusyRabbit/Public/GameAsset/BusyItem.h +++ b/Source/BusyRabbit/Public/GameAsset/BusyItem.h @@ -56,6 +56,9 @@ struct FBusyLevelItemDescription : public FTableRowBase { // 物品描述表头 UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品关卡内资源") TSoftObjectPtr LevelResource; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品标签列表") + FGameplayTagContainer ItemTags; };