调整关卡切换后的地图数据保存问题

This commit is contained in:
997146918 2025-09-23 19:30:06 +08:00
parent 6f67c20a2e
commit a235d423b5
11 changed files with 22 additions and 18 deletions

View File

@ -96,7 +96,8 @@ ManualIPAddress=
+ClassRedirects=(OldName="/Script/ProjectFish.Skill_Pull",NewName="/Script/ProjectFish.SkillEffect_Damage") +ClassRedirects=(OldName="/Script/ProjectFish.Skill_Pull",NewName="/Script/ProjectFish.SkillEffect_Damage")
+ClassRedirects=(OldName="/Script/ProjectFish.SkillEffect_Pull",NewName="/Script/ProjectFish.SkillEffect_Damage") +ClassRedirects=(OldName="/Script/ProjectFish.SkillEffect_Pull",NewName="/Script/ProjectFish.SkillEffect_Damage")
+ClassRedirects=(OldName="/Script/ProjectFish.PlayerInventorySubsystem",NewName="/Script/ProjectFish.FishingRodConfigSubsystem") +ClassRedirects=(OldName="/Script/ProjectFish.PlayerInventorySubsystem",NewName="/Script/ProjectFish.FishingRodConfigSubsystem")
+ClassRedirects=(OldName="/Script/ProjectFish.SimpleMapSystem",NewName="/Script/ProjectFish.FishingMapSystem") +ClassRedirects=(OldName="/Script/ProjectFish.SimpleMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
+ClassRedirects=(OldName="/Script/ProjectFish.FishingMapSystem",NewName="/Script/ProjectFish.FishingMapSubSystem")
[/Script/Engine.CollisionProfile] [/Script/Engine.CollisionProfile]
-Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False) -Profiles=(Name="NoCollision",CollisionEnabled=NoCollision,ObjectTypeName="WorldStatic",CustomResponses=((Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore)),HelpMessage="No collision",bCanModify=False)

View File

@ -7,7 +7,7 @@
#include "ProjectFish/Definations.h" #include "ProjectFish/Definations.h"
#include "ProjectFish/PawnWithSkill.h" #include "ProjectFish/PawnWithSkill.h"
#include "ProjectFish/DataAsset/BagConfigAsset.h" #include "ProjectFish/DataAsset/BagConfigAsset.h"
#include "ProjectFish/Subsystem/FishingRodConfigSubsystem.h" #include "ProjectFish/Gameplay/Subsystem/FishingRodConfigSubsystem.h"
// Sets default values for this component's properties // Sets default values for this component's properties

View File

@ -1,4 +1,4 @@
#include "FishingMapSystem.h" #include "FishingMapSubSystem.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "ProjectFish/DataAsset/MapConfigAsset.h" #include "ProjectFish/DataAsset/MapConfigAsset.h"
@ -18,17 +18,17 @@ void UFishingMapNode::RandomNodeType()
NodeType = static_cast<EMapNodeType>(FMath::RandRange(0, 1)); NodeType = static_cast<EMapNodeType>(FMath::RandRange(0, 1));
} }
UFishingMapSystem::UFishingMapSystem() UFishingMapSubSystem::UFishingMapSubSystem()
{ {
} }
void UFishingMapSystem::GenerateMap() void UFishingMapSubSystem::GenerateMap()
{ {
GenerateMapWithConfig(MapConfig); GenerateMapWithConfig(MapConfig);
} }
void UFishingMapSystem::GenerateMapWithConfig(const UMapConfigAsset* Config) void UFishingMapSubSystem::GenerateMapWithConfig(const UMapConfigAsset* Config)
{ {
// 清空现有数据 // 清空现有数据
ClearMap(); ClearMap();
@ -46,7 +46,7 @@ void UFishingMapSystem::GenerateMapWithConfig(const UMapConfigAsset* Config)
GetLayerCount(), AllNodes.Num(), AllConnections.Num()); GetLayerCount(), AllNodes.Num(), AllConnections.Num());
} }
int32 UFishingMapSystem::GetNodeAtLayerIndex(FGuid NodeID) const int32 UFishingMapSubSystem::GetNodeAtLayerIndex(FGuid NodeID) const
{ {
for (FMapLayer Layer: AllLayers) for (FMapLayer Layer: AllLayers)
{ {
@ -59,7 +59,7 @@ int32 UFishingMapSystem::GetNodeAtLayerIndex(FGuid NodeID) const
return -1; return -1;
} }
UFishingMapNode* UFishingMapSystem::GetNode(FGuid NodeID) UFishingMapNode* UFishingMapSubSystem::GetNode(FGuid NodeID)
{ {
for (auto node: AllNodes) for (auto node: AllNodes)
{ {
@ -69,15 +69,16 @@ UFishingMapNode* UFishingMapSystem::GetNode(FGuid NodeID)
return nullptr; return nullptr;
} }
void UFishingMapSystem::ClearMap() void UFishingMapSubSystem::ClearMap()
{ {
AllNodes.Empty(); AllNodes.Empty();
AllConnections.Empty(); AllConnections.Empty();
AllLayers.Empty(); AllLayers.Empty();
} }
void UFishingMapSystem::MoveToNode(FGuid NodeID) void UFishingMapSubSystem::MoveToNode(FGuid NodeID)
{ {
PlayerPosNodeID = NodeID;
TArray<FGuid> MoveableNodeIDs; TArray<FGuid> MoveableNodeIDs;
GetAllConnectedNodes(NodeID, MoveableNodeIDs); GetAllConnectedNodes(NodeID, MoveableNodeIDs);
for (auto node:AllNodes) for (auto node:AllNodes)
@ -104,7 +105,7 @@ void UFishingMapSystem::MoveToNode(FGuid NodeID)
} }
void UFishingMapSystem::GenerateNodes() void UFishingMapSubSystem::GenerateNodes()
{ {
AllLayers.SetNum(MapConfig->TotalLayers); AllLayers.SetNum(MapConfig->TotalLayers);
UE_LOG(LogTemp, Warning, TEXT("生成layer层数 %d "), MapConfig->TotalLayers ); UE_LOG(LogTemp, Warning, TEXT("生成layer层数 %d "), MapConfig->TotalLayers );
@ -142,7 +143,7 @@ void UFishingMapSystem::GenerateNodes()
} }
} }
void UFishingMapSystem::CalculateNodePositions() void UFishingMapSubSystem::CalculateNodePositions()
{ {
for (int32 LayerIndex = 0; LayerIndex < AllLayers.Num(); ++LayerIndex) for (int32 LayerIndex = 0; LayerIndex < AllLayers.Num(); ++LayerIndex)
{ {
@ -162,7 +163,7 @@ void UFishingMapSystem::CalculateNodePositions()
} }
} }
void UFishingMapSystem::GenerateConnections() void UFishingMapSubSystem::GenerateConnections()
{ {
AllConnections.Empty(); AllConnections.Empty();
@ -188,7 +189,7 @@ void UFishingMapSystem::GenerateConnections()
} }
} }
TArray<FSimpleConnection> UFishingMapSystem::GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer) TArray<FSimpleConnection> UFishingMapSubSystem::GenerateNonCrossingConnections(int32 FromLayer, int32 ToLayer)
{ {
TArray<FSimpleConnection> Connections; TArray<FSimpleConnection> Connections;
@ -258,7 +259,7 @@ TArray<FSimpleConnection> UFishingMapSystem::GenerateNonCrossingConnections(int3
return Connections; return Connections;
} }
void UFishingMapSystem::GetAllConnectedNodes(FGuid NodeID, TArray<FGuid>& ConnectedNodes) void UFishingMapSubSystem::GetAllConnectedNodes(FGuid NodeID, TArray<FGuid>& ConnectedNodes)
{ {
//获取所有可移动的节点 //获取所有可移动的节点
ConnectedNodes.Add(NodeID); ConnectedNodes.Add(NodeID);

View File

@ -3,7 +3,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/DataAsset.h" #include "Engine/DataAsset.h"
#include "ProjectFish/Definations.h" #include "ProjectFish/Definations.h"
#include "FishingMapSystem.generated.h" #include "FishingMapSubSystem.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNodeStateChange, FGuid, NodeID, EMapNodeState, NewState); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNodeStateChange, FGuid, NodeID, EMapNodeState, NewState);
@ -45,12 +45,12 @@ public:
* *
*/ */
UCLASS(BlueprintType) UCLASS(BlueprintType)
class PROJECTFISH_API UFishingMapSystem : public UObject class PROJECTFISH_API UFishingMapSubSystem : public UGameInstanceSubsystem
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
UFishingMapSystem(); UFishingMapSubSystem();
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "地图配置")) UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ToolTip = "地图配置"))
class UMapConfigAsset* MapConfig; class UMapConfigAsset* MapConfig;
@ -67,6 +67,8 @@ public:
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FOnNodeStateChange OnNodeStateChange; FOnNodeStateChange OnNodeStateChange;
UPROPERTY(BlueprintReadWrite)
FGuid PlayerPosNodeID;
// 生成地图 // 生成地图
UFUNCTION(BlueprintCallable, Category = "FishingMap") UFUNCTION(BlueprintCallable, Category = "FishingMap")
void GenerateMap(); void GenerateMap();