Project02/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/FishingRodConfigSubsystem.cpp
2025-10-15 18:25:31 +08:00

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/ShapeAsset.h"
void UFishingRodConfigSubsystem::CreateFishingRodInventory(class UShapeAsset* 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->ShapeWidth;
int32 height = playerInventoryConfig->BagShapeAsset->ShapeHeight;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
if (playerInventoryConfig->AddSkill(SkillAsset, x, y))
{
return true;
}
}
}
return false;
}