53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "FishingRodConfigSubsystem.h"
|
|
|
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
|
#include "ProjectFish/DataAsset/BagShapeAsset.h"
|
|
|
|
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UBagShapeAsset* FishingRodShape, class UBagConfigAsset* PlayerBagConfig)
|
|
{
|
|
//鱼竿的技能配置资源
|
|
fishingRodInventoryConfig = NewObject<UBagConfigAsset>(this);
|
|
fishingRodInventoryConfig->BagShapeAsset = FishingRodShape;
|
|
//玩家背包的技能配置资源
|
|
// playerInventoryConfig = NewObject<UBagConfigAsset>(this);
|
|
// playerInventoryConfig->BagShapeAsset = PlayerBagShape;
|
|
playerInventoryConfig = DuplicateObject<UBagConfigAsset>(PlayerBagConfig, this);
|
|
}
|
|
|
|
UBagConfigAsset* UFishingRodConfigSubsystem::GetFishingRodInventory()
|
|
{
|
|
return this->fishingRodInventoryConfig;
|
|
}
|
|
|
|
UBagConfigAsset* UFishingRodConfigSubsystem::GetPlayerInventory()
|
|
{
|
|
return playerInventoryConfig;
|
|
}
|
|
|
|
bool UFishingRodConfigSubsystem::AddSkillByConfig(USkillAsset* SkillAsset, UBagConfigAsset* InventoryConfig,
|
|
FIntPoint Position)
|
|
{
|
|
return InventoryConfig->AddSkill(SkillAsset, Position.X, Position.Y);
|
|
}
|
|
|
|
bool UFishingRodConfigSubsystem::AddSkillToPlayerInventory(USkillAsset* SkillAsset)
|
|
{
|
|
|
|
int32 width = playerInventoryConfig->BagShapeAsset->BagWidth;
|
|
int32 height = playerInventoryConfig->BagShapeAsset->BagHeight;
|
|
for (int x = 0; x < width; x++)
|
|
{
|
|
for (int y = 0; y < height; y++)
|
|
{
|
|
if (playerInventoryConfig->AddSkill(SkillAsset, x, y))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|