修复物品拖拽bug

This commit is contained in:
997146918 2025-10-24 15:05:20 +08:00
parent 34039547f9
commit f2173d2ae1
6 changed files with 7 additions and 8 deletions

View File

@ -22,17 +22,17 @@ void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape)
} }
} }
bool UContainerInfo::AddContainerItem(FContainerItem Item, int32& ItemID) int32 UContainerInfo::AddContainerItem(FContainerItem Item)
{ {
if (!IsItemInContainerShape(Item)) if (!IsItemInContainerShape(Item))
{ {
return false; return -1;
} }
if (IsItemOverlapOtherItem(Item)) if (IsItemOverlapOtherItem(Item))
{ {
return false; return -1;
} }
ItemID = NextItemID; int32 ItemID = NextItemID;
Items.Add(NextItemID, Item); Items.Add(NextItemID, Item);
++NextItemID; ++NextItemID;
//设置容器指定位置的占用状态 //设置容器指定位置的占用状态
@ -46,7 +46,7 @@ bool UContainerInfo::AddContainerItem(FContainerItem Item, int32& ItemID)
} }
} }
} }
return true; return ItemID;
} }
bool UContainerInfo::RemoveContainerItem(const int32& ItemID) bool UContainerInfo::RemoveContainerItem(const int32& ItemID)
@ -163,8 +163,7 @@ bool UContainerInfo::LoadFromSaveData(FPrimaryAssetId ShapeID, const TArray<FCon
NewItem.RewardItem = Cast<UFishingRewardDataAsset>(RewardItemPath.TryLoad()); NewItem.RewardItem = Cast<UFishingRewardDataAsset>(RewardItemPath.TryLoad());
//添加物品到容器中 //添加物品到容器中
FIntPoint Position(ItemData.PosX, ItemData.PosY); FIntPoint Position(ItemData.PosX, ItemData.PosY);
int32 ItemID; AddContainerItem(NewItem);
AddContainerItem(NewItem, ItemID);
} }
return true; return true;

View File

@ -112,7 +112,7 @@ public:
void InitContainerByShape(UShapeAsset* InContainerShape); void InitContainerByShape(UShapeAsset* InContainerShape);
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
bool AddContainerItem(FContainerItem Item, int32& ItemID); int32 AddContainerItem(FContainerItem Item);
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
bool RemoveContainerItem(const int32& ItemID); bool RemoveContainerItem(const int32& ItemID);