Compare commits
2 Commits
cb74c13494
...
f80c48465c
| Author | SHA1 | Date | |
|---|---|---|---|
| f80c48465c | |||
| f9674f5445 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -43,6 +43,7 @@ int32 UContainerInfo::AddContainerItem(FContainerItem Item)
|
|||||||
if (Item.IsSlotUsing(FIntPoint(x, y)))
|
if (Item.IsSlotUsing(FIntPoint(x, y)))
|
||||||
{
|
{
|
||||||
SlotInUsing.Add(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y), true);
|
SlotInUsing.Add(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y), true);
|
||||||
|
SlotItems.Add(FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y), ItemID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,6 +62,7 @@ bool UContainerInfo::RemoveContainerItem(const int32& ItemID)
|
|||||||
if (Item.IsSlotUsing(FIntPoint(x, y )))
|
if (Item.IsSlotUsing(FIntPoint(x, y )))
|
||||||
{
|
{
|
||||||
SlotInUsing[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] = false;
|
SlotInUsing[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] = false;
|
||||||
|
SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,6 +72,32 @@ bool UContainerInfo::RemoveContainerItem(const int32& ItemID)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TSet<int32> UContainerInfo::GetOverlapOtherItem(FContainerItem Item)
|
||||||
|
{
|
||||||
|
TSet<int32> OverlapItems;
|
||||||
|
if (IsItemInContainerShape(Item))
|
||||||
|
{
|
||||||
|
for (int x = 0; x < Item.GetItemWIdth(); x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < Item.GetItemHeight(); y++)
|
||||||
|
{
|
||||||
|
if (Item.IsSlotUsing(FIntPoint(x, y)))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ContainerShape->IsSlotActive(Item.ContainerStartPos.X + x, Item.ContainerStartPos.Y + y) &&
|
||||||
|
SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] != -1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
OverlapItems.Add(SlotItems[FIntPoint(x + Item.ContainerStartPos.X, y + Item.ContainerStartPos.Y)] );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OverlapItems;
|
||||||
|
}
|
||||||
|
|
||||||
bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem)
|
bool UContainerInfo::IsItemOverlapOtherItem(FContainerItem NewItem)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -143,6 +171,7 @@ bool UContainerInfo::LoadFromSaveData(FPrimaryAssetId ShapeID, const TArray<FCon
|
|||||||
// 清空当前数据
|
// 清空当前数据
|
||||||
Items.Empty();
|
Items.Empty();
|
||||||
SlotInUsing.Empty();
|
SlotInUsing.Empty();
|
||||||
|
SlotItems.Empty();
|
||||||
//从存档中加载仓库形状
|
//从存档中加载仓库形状
|
||||||
FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(ShapeID);
|
FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(ShapeID);
|
||||||
UShapeAsset* ShapeAsset = Cast<UShapeAsset>(ShipShapePath.TryLoad());
|
UShapeAsset* ShapeAsset = Cast<UShapeAsset>(ShipShapePath.TryLoad());
|
||||||
|
|||||||
@ -115,6 +115,8 @@ public:
|
|||||||
int32 AddContainerItem(FContainerItem Item);
|
int32 AddContainerItem(FContainerItem Item);
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
bool RemoveContainerItem(const int32& ItemID);
|
bool RemoveContainerItem(const int32& ItemID);
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
TSet<int32> GetOverlapOtherItem(FContainerItem Item);
|
||||||
|
|
||||||
// 获取存档数据
|
// 获取存档数据
|
||||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||||
@ -142,4 +144,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
int32 NextItemID = 0;
|
int32 NextItemID = 0;
|
||||||
TMap<FIntPoint, bool> SlotInUsing;
|
TMap<FIntPoint, bool> SlotInUsing;
|
||||||
|
TMap<FIntPoint, int32> SlotItems;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user