初始化提交

This commit is contained in:
2025-07-09 01:08:35 +08:00
parent d3296791cf
commit 62e0f56c60
618 changed files with 173543 additions and 0 deletions

View File

@ -0,0 +1,58 @@
local InventoryArea = {}
local RoleUtils = require("GamePlay.Utils.RoleUtils")
local GameplayStatics = import("GameplayStatics")
local WidgetBlueprintLibrary = import("WidgetBlueprintLibrary")
local BusyActorManagerSubSystem = import("BusyActorManagerSubSystem")
function InventoryArea:ctor()
self.widgets = {}
end
function InventoryArea:PreConstruct(bIsDesignTime)
if not bIsDesignTime then return end
end
function InventoryArea:OnInitialized()
self:InitInventoryLayout(self.RowGridCnt, self.ColGridCnt, self.GridClass)
end
function InventoryArea:InitInventoryLayout(row_cnt, col_cnt, cls)
self.widgets = {}
local pc = GameplayStatics.GetPlayerController(self, 0)
for i=1, row_cnt do
for j=1, col_cnt do
local widget = WidgetBlueprintLibrary.Create(self, cls, pc)
self.GridPanel:AddChildToGrid(widget, i-1, j-1)
widget:SetData(nil)
table.insert(self.widgets, widget)
end
end
end
function InventoryArea:OnSwitchIn(inventory_name)
self:SetVisible(true)
local inventory = nil
if inventory_name == "BonfireInventory" then
local sub_system = BusyActorManagerSubSystem.Get(self)
local bonfire = sub_system:GetNearestBonfire()
inventory = bonfire.Inventory
elseif inventory_name == "RoleInventory" then
local role = RoleUtils.GetRole(self)
inventory = role.Inventory
end
if inventory == nil then return end
inventory:ForEach(slua.createDelegate(function(idx, grid)
local widget = self.widgets[idx+1]
widget:SetData(grid)
widget:SetInventoryInfo(inventory, idx)
end))
end
function InventoryArea:OnSwitchOut(inventory_name)
self:SetVisible(false)
end
return Class(nil, nil, InventoryArea)