diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 05b4eca..534d2f1 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -15,7 +15,7 @@ ManualIPAddress= [/Script/EngineSettings.GameMapsSettings] GlobalDefaultGameMode=/Game/Blueprint/Bp_BusyGameMode.Bp_BusyGameMode_C GameInstanceClass=/Script/BusyRabbit.BusyGameInstance -EditorStartupMap=/Game/Level/HomeLand.HomeLand +EditorStartupMap=/Game/Level/FalconPlain.FalconPlain GameDefaultMap=/Game/Level/FalconPlain.FalconPlain [/Script/Engine.RendererSettings] diff --git a/Config/DefaultGameplayTags.ini b/Config/DefaultGameplayTags.ini index a77ea33..23bb19c 100644 --- a/Config/DefaultGameplayTags.ini +++ b/Config/DefaultGameplayTags.ini @@ -1,3 +1,4 @@ +;METADATA=(Diff=true, UseCommands=true) [/Script/GameplayTags.GameplayTagsSettings] ImportTagsFromConfig=True WarnOnInvalidTags=True @@ -57,6 +58,9 @@ NetIndexFirstBitSegment=16 +GameplayTagList=(Tag="Ingredient.Vegetable.Carrot",DevComment="胡萝卜") +GameplayTagList=(Tag="Recover.Role.Health",DevComment="回复生命值") +GameplayTagList=(Tag="Recover.Role.Hunger",DevComment="恢复饥饿值") ++GameplayTagList=(Tag="Resource",DevComment="资源") ++GameplayTagList=(Tag="Resource.Building",DevComment="建筑物") ++GameplayTagList=(Tag="Resource.Building.Campsite",DevComment="营地") +GameplayTagList=(Tag="Status.Role.Invincible",DevComment="不掉血标签") +GameplayTagList=(Tag="Terrain.Desert",DevComment="荒漠地形") +GameplayTagList=(Tag="Terrain.Forest",DevComment="森林") diff --git a/Content/Blueprint/Level/Actor/Static/BP_Campsite.uasset b/Content/Blueprint/Level/Actor/Static/BP_Campsite.uasset index 25043b8..a855f54 100644 Binary files a/Content/Blueprint/Level/Actor/Static/BP_Campsite.uasset and b/Content/Blueprint/Level/Actor/Static/BP_Campsite.uasset differ diff --git a/Content/Blueprint/Level/BP_LevelMap.uasset b/Content/Blueprint/Level/BP_LevelMap.uasset index 02d5547..6156fca 100644 Binary files a/Content/Blueprint/Level/BP_LevelMap.uasset and b/Content/Blueprint/Level/BP_LevelMap.uasset differ diff --git a/Content/Data/BusyGameAsset.uasset b/Content/Data/BusyGameAsset.uasset index c6a2ce8..f593f2e 100644 Binary files a/Content/Data/BusyGameAsset.uasset and b/Content/Data/BusyGameAsset.uasset differ diff --git a/Content/Data/Level/LevelBaseConfig.uasset b/Content/Data/Level/LevelBaseConfig.uasset deleted file mode 100644 index 44e9636..0000000 Binary files a/Content/Data/Level/LevelBaseConfig.uasset and /dev/null differ diff --git a/Content/Data/Level/LevelResourceConfig.uasset b/Content/Data/Level/LevelResourceConfig.uasset new file mode 100644 index 0000000..e72cf88 Binary files /dev/null and b/Content/Data/Level/LevelResourceConfig.uasset differ diff --git a/Script/ManagedBusyRabbit/Level/GameSettings/BusyLevelPlayerState.cs b/Script/ManagedBusyRabbit/Level/GameSettings/BusyLevelPlayerState.cs index 04bcc44..783404c 100644 --- a/Script/ManagedBusyRabbit/Level/GameSettings/BusyLevelPlayerState.cs +++ b/Script/ManagedBusyRabbit/Level/GameSettings/BusyLevelPlayerState.cs @@ -1,5 +1,7 @@ +using UnrealSharp; using UnrealSharp.Attributes; using UnrealSharp.BusyRabbit; +using UnrealSharp.CoreUObject; using UnrealSharp.Engine; namespace Level.GameSettings; @@ -11,7 +13,17 @@ public class ABusyLevelPlayerState : ALevelPlayerState { base.BeginPlay(); APlayerController pc = UGameplayStatics.GetPlayerController(0); - var role = CreateRoleRoster(pc) as APawn; - pc.Possess(role); + UGameplayStatics.GetAllActorsWithTag("Resource.Building.Campsite", out IList FoundActors); + FVector SpawnLocation = new FVector(0, 0, 10); + if (FoundActors.Count > 0) + { + SpawnLocation = FoundActors[0].ActorLocation; + } + + if(CreateRoleRoster(pc) is APawn Role) + { + pc.Possess(Role); + Role.SetActorLocation(SpawnLocation); + } } } diff --git a/Source/BusyRabbit/Private/Level/Actor/BusyStaticResource.cpp b/Source/BusyRabbit/Private/Level/Actor/BusyStaticResource.cpp index e7e3182..e32e53b 100644 --- a/Source/BusyRabbit/Private/Level/Actor/BusyStaticResource.cpp +++ b/Source/BusyRabbit/Private/Level/Actor/BusyStaticResource.cpp @@ -1,6 +1,8 @@ #include "Level/Actor/BusyStaticResource.h" #include "SpineSkeletonRendererComponent.h" #include "SpineSkeletonAnimationComponent.h" +#include "BusyGameplayLibrary.h" +#include "Data/BusyResourceConfig.h" ABusyStaticResource::ABusyStaticResource() { @@ -21,4 +23,19 @@ void ABusyStaticResource::BeginPlay() Super::BeginPlay(); SpineAnimationComponent->SetSkin("default"); SpineAnimationComponent->SetAnimation(0, "idle", true); + + if (ResourceName.IsNone()) return; + + const UDataTable* ResourceTable = UBusyGameplayLibrary::GetGameDataTable("ResourceConfig"); + if (!ResourceTable) return; + + FBusyResourceConfig* Config = ResourceTable->FindRow( + ResourceName, *FString::Printf(TEXT("ABusyStaticResource::BeginPlay Find Config: %s"), *ResourceName.ToString()) + ); + if (Config == nullptr) return; + + for (const FGameplayTag& Tag : Config->GameplayTags) + { + Tags.AddUnique(Tag.GetTagName()); + } } diff --git a/Source/BusyRabbit/Private/Level/Map/Components/StaticResourceLayerComponent.cpp b/Source/BusyRabbit/Private/Level/Map/Components/StaticResourceLayerComponent.cpp index 6cc9ce4..d3d3af9 100644 --- a/Source/BusyRabbit/Private/Level/Map/Components/StaticResourceLayerComponent.cpp +++ b/Source/BusyRabbit/Private/Level/Map/Components/StaticResourceLayerComponent.cpp @@ -113,7 +113,7 @@ void UStaticResourceLayerComponent::GenerateResourcePoints(TArray& Ou const IGameMapInterface * MapInterface = Cast(Owner); if (!MapInterface) return; - float MapWidth, MapHeight; + int32 MapWidth, MapHeight; MapInterface->Execute_GetMapSize(Owner, MapWidth, MapHeight); const UMitchellBestCandidate *PointCreator = NewObject(); diff --git a/Source/BusyRabbit/Private/Level/Map/Components/TerrainLayerComponent.cpp b/Source/BusyRabbit/Private/Level/Map/Components/TerrainLayerComponent.cpp index 3f37888..9a60953 100644 --- a/Source/BusyRabbit/Private/Level/Map/Components/TerrainLayerComponent.cpp +++ b/Source/BusyRabbit/Private/Level/Map/Components/TerrainLayerComponent.cpp @@ -171,11 +171,25 @@ UTerrainLayerComponent::UTerrainLayerComponent() void UTerrainLayerComponent::BeginPlay() { Super::BeginPlay(); + + AActor* Owner = GetOwner(); + if (IGameMapInterface* GameMap = Cast(Owner)) + { + GameMap->Execute_GetMapSize(Owner, MapWidth, MapHeight); + TileSetSize = GameMap->Execute_GetMapFieldSize(Owner); + } + else + { + MapWidth = MapHeight = 32; + TileSetSize = 128; + } + SetupTerrainActors(); TArray Priority; TArray TerrainData; TArray TerrainTypes; + for (auto TileSetConfig : TileSetConfigs) { TerrainTypes.Add(TileSetConfig.Key); diff --git a/Source/BusyRabbit/Private/Level/Map/GameMapActor.cpp b/Source/BusyRabbit/Private/Level/Map/GameMapActor.cpp index eb492af..d08cba2 100644 --- a/Source/BusyRabbit/Private/Level/Map/GameMapActor.cpp +++ b/Source/BusyRabbit/Private/Level/Map/GameMapActor.cpp @@ -11,7 +11,7 @@ AGameMapActor::AGameMapActor() this->RootComponent = SceneComp; } -void AGameMapActor::GetMapSize_Implementation(float& OutWidth, float& OutHeight) +void AGameMapActor::GetMapSize_Implementation(int32& OutWidth, int32& OutHeight) { OutWidth = MapWidth; OutHeight = MapHeight; @@ -22,7 +22,7 @@ FGameplayTag AGameMapActor::GetTerrainAt_Implementation(const float X, const flo return TerrainLayer->GetTerrainAt(X, Y); } -float AGameMapActor::GetMapFieldSize_Implementation() +int32 AGameMapActor::GetMapFieldSize_Implementation() { return MapFieldSize; } diff --git a/Source/BusyRabbit/Public/BusyGameplayLibrary.h b/Source/BusyRabbit/Public/BusyGameplayLibrary.h index b05c64f..ec1be07 100644 --- a/Source/BusyRabbit/Public/BusyGameplayLibrary.h +++ b/Source/BusyRabbit/Public/BusyGameplayLibrary.h @@ -18,7 +18,7 @@ class BUSYRABBIT_API UBusyGameplayLibrary : public UBlueprintFunctionLibrary GENERATED_BODY() public: - UFUNCTION(BlueprintCallable) + UFUNCTION(BlueprintPure) static UDataTable* GetGameDataTable(const FString& TableName); UFUNCTION(BlueprintCallable) diff --git a/Source/BusyRabbit/Public/Data/BusyPawnConfig.h b/Source/BusyRabbit/Public/Data/BusyPawnConfig.h index e202136..1a136fc 100644 --- a/Source/BusyRabbit/Public/Data/BusyPawnConfig.h +++ b/Source/BusyRabbit/Public/Data/BusyPawnConfig.h @@ -20,7 +20,7 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName="移动速度") float MoveSpeed; - + UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName="技能列表") TArray> DefaultAbilities; }; diff --git a/Source/BusyRabbit/Public/Data/BusyResourceConfig.h b/Source/BusyRabbit/Public/Data/BusyResourceConfig.h new file mode 100644 index 0000000..890b0a5 --- /dev/null +++ b/Source/BusyRabbit/Public/Data/BusyResourceConfig.h @@ -0,0 +1,15 @@ +#pragma once +#include "GameplayTagContainer.h" +#include "BusyResourceConfig.generated.h" + +USTRUCT(BlueprintType) +struct FBusyResourceConfig : public FTableRowBase +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, DisplayName="备注") + FString Desc; + + UPROPERTY(EditAnywhere, DisplayName="物品标签") + FGameplayTagContainer GameplayTags; +}; \ No newline at end of file diff --git a/Source/BusyRabbit/Public/Level/Actor/BusyStaticResource.h b/Source/BusyRabbit/Public/Level/Actor/BusyStaticResource.h index c586ca1..0244a98 100644 --- a/Source/BusyRabbit/Public/Level/Actor/BusyStaticResource.h +++ b/Source/BusyRabbit/Public/Level/Actor/BusyStaticResource.h @@ -28,5 +28,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly) TObjectPtr SpineAnimationComponent; /*-------------------------------------------------------------------*/ + +protected: + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly) + FName ResourceName; }; diff --git a/Source/BusyRabbit/Public/Level/Map/Components/TerrainLayerComponent.h b/Source/BusyRabbit/Public/Level/Map/Components/TerrainLayerComponent.h index ae0b58c..05e294e 100644 --- a/Source/BusyRabbit/Public/Level/Map/Components/TerrainLayerComponent.h +++ b/Source/BusyRabbit/Public/Level/Map/Components/TerrainLayerComponent.h @@ -62,14 +62,9 @@ protected: protected: - UPROPERTY(EditAnywhere, BlueprintReadWrite) - int32 MapWidth = 32; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - int32 MapHeight = 32; - - UPROPERTY(EditAnywhere, BlueprintReadWrite) - int32 TileSetSize = 128; + int32 MapWidth = 32; // 用Owner的Width覆盖 + int32 MapHeight = 32; // 用Owner的Height覆盖 + int32 TileSetSize = 128; // 用Owner的Size覆盖 UPROPERTY(EditAnywhere, BlueprintReadOnly) TMap> TileSetConfigs; diff --git a/Source/BusyRabbit/Public/Level/Map/GameMapActor.h b/Source/BusyRabbit/Public/Level/Map/GameMapActor.h index dfa5b12..af0fe9e 100644 --- a/Source/BusyRabbit/Public/Level/Map/GameMapActor.h +++ b/Source/BusyRabbit/Public/Level/Map/GameMapActor.h @@ -18,10 +18,10 @@ class IGameMapInterface GENERATED_BODY() public: UFUNCTION(BlueprintCallable, BlueprintNativeEvent) - void GetMapSize(float &OutX, float &OutY); + void GetMapSize(int32 &OutX, int32 &OutY); UFUNCTION(BlueprintCallable, BlueprintNativeEvent) - float GetMapFieldSize(); + int32 GetMapFieldSize(); UFUNCTION(BlueprintCallable, BlueprintNativeEvent) FGameplayTag GetTerrainAt(const float X, const float Y); @@ -37,9 +37,9 @@ public: AGameMapActor(); public: - virtual void GetMapSize_Implementation(float& OutWidth, float& OutHeight) override; + virtual void GetMapSize_Implementation(int32& OutWidth, int32& OutHeight) override; virtual FGameplayTag GetTerrainAt_Implementation(const float X, const float Y) override; - virtual float GetMapFieldSize_Implementation() override; + virtual int32 GetMapFieldSize_Implementation() override; public: virtual void BeginPlay() override; @@ -58,11 +58,11 @@ public: protected: UPROPERTY(EditAnywhere, BlueprintReadOnly) - float MapWidth = 32; + int32 MapWidth = 32; UPROPERTY(EditAnywhere, BlueprintReadOnly) - float MapHeight = 32; + int32 MapHeight = 32; UPROPERTY(EditAnywhere, BlueprintReadOnly) - float MapFieldSize = 128; + int32 MapFieldSize = 128; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)