初始化提交

This commit is contained in:
2025-07-09 01:08:35 +08:00
parent d3296791cf
commit 62e0f56c60
618 changed files with 173543 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class BusyRabbitTarget : TargetRules
{
public BusyRabbitTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.Add("BusyRabbit");
}
}

View File

@ -0,0 +1,28 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class BusyRabbit : ModuleRules
{
public BusyRabbit(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] {
"Core", "CoreUObject", "Engine", "InputCore",
"EnhancedInput", "Paper2D", "UMG", "Slate",
"GameplayAbilities", "GameplayTags","GameplayTasks",
"UnrealEd"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "BusyRabbit.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, BusyRabbit, "BusyRabbit" );

View File

@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,53 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyActorManagerSubSystem.h"
#include "BusyGamePlayLibrary.h"
#include "Subsystems/SubsystemBlueprintLibrary.h"
void UBusyActorManagerSubSystem::Initialize(FSubsystemCollectionBase& Collection){
Super::Initialize(Collection);
ReceiveSubSystemInitialize();
}
void UBusyActorManagerSubSystem::OnWorldBeginPlay(UWorld& InWorld) {
Super::OnWorldBeginPlay(InWorld);
ReceiveWorldBeginPlay();
}
void UBusyActorManagerSubSystem::Deinitialize(){
// <20>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>Luaʵ<61>ֵĺ<D6B5><C4BA><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD><E1B9A9><EFBFBD>ٵ<EFBFBD>lua<75>ӿڰ<D3BF>
Super::Deinitialize();
}
FString UBusyActorManagerSubSystem::GetLuaFilePath_Implementation() const{
return TEXT("GamePlay/Level/BusyActorManagerSubSystem");
}
bool UBusyActorManagerSubSystem::GetLevelBaseConfig(FBusyLevelBaseConfig& config){
FBusyLevelBaseConfig* Config;
UDataTable *DataTable = UBusyGamePlayLibrary::GetGameDataTable("LevelBaseConfig");
if (!DataTable) return false;
Config = DataTable->FindRow<FBusyLevelBaseConfig>(
TEXT("Default"),
TEXT("UBusyActorManagerSubSystem::GetLevelBaseConfig"),
true
);
if (!Config) return false;
config = *Config;
return true;
}
UWorld* UBusyActorManagerSubSystem::K2_GetWorld(){
return this->GetWorld();
}
UBusyActorManagerSubSystem* UBusyActorManagerSubSystem::Get(UObject* WorldContextObject){
UWorldSubsystem *SubSystem = USubsystemBlueprintLibrary::GetWorldSubsystem(
WorldContextObject,
UBusyActorManagerSubSystem::StaticClass()
);
return Cast<UBusyActorManagerSubSystem>(SubSystem);
}

View File

@ -0,0 +1,21 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyBonfire.h"
#include "Components/CapsuleComponent.h"
#include "Components/InventoryComponent.h"
ABusyBonfire::ABusyBonfire(){
LuaFilePath = TEXT("GamePlay/Bonefire/Bonfire");
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("BonfireCapsule"));
CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);
CapsuleComp->SetupAttachment(SceneComp);
this->RootComponent = SceneComp;
}

View File

@ -0,0 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyCameraComponent.h"
UBusyCameraComponent::UBusyCameraComponent(){
this->SetProjectionMode(ECameraProjectionMode::Orthographic);
}

View File

@ -0,0 +1,8 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyCharacter.h"
FString ABusyCharacter::GetLuaFilePath_Implementation()const {
return LuaFilePath;
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyDataAsset.h"

View File

@ -0,0 +1,101 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyGameInstance.h"
#include "Misc/FileHelper.h"
#include "Misc/CoreDelegates.h"
#include "LuaCppBinding.h"
#include "GameplayTagsManager.h"
static uint8* ReadFile(IPlatformFile& PlatformFile, FString path, uint32& len) {
IFileHandle* FileHandle = PlatformFile.OpenRead(*path);
if (FileHandle) {
len = (uint32)FileHandle->Size();
uint8* buf = new uint8[len];
FileHandle->Read(buf, len);
delete FileHandle;
return buf;
}
return nullptr;
}
static int32 PrintLog(NS_SLUA::lua_State* L)
{
FString str;
size_t len;
const char* s = luaL_tolstring(L, 1, &len);
if (s) str += UTF8_TO_TCHAR(s);
NS_SLUA::Log::Log("PrintLog %s", TCHAR_TO_UTF8(*str));
return 0;
}
UBusyGameInstance::UBusyGameInstance(): state(nullptr){
CreateLuaState();
}
void UBusyGameInstance::CreateLuaState() {
NS_SLUA::LuaState::onInitEvent.AddUObject(this, &UBusyGameInstance::LuaStateInitCallback);
CloseLuaState();
state = new NS_SLUA::LuaState("SLuaMainState", this);
state->setLoadFileDelegate([](const char* fn, FString& filepath)->TArray<uint8> {
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FString path = FPaths::ProjectContentDir();
FString filename = UTF8_TO_TCHAR(fn);
path /= "Lua";
path /= filename.Replace(TEXT("."), TEXT("/"));
TArray<uint8> Content;
TArray<FString> luaExts = { UTF8_TO_TCHAR(".lua"), UTF8_TO_TCHAR(".luac") };
for (auto& it : luaExts) {
auto fullPath = path + *it;
FFileHelper::LoadFileToArray(Content, *fullPath);
if (Content.Num() > 0) {
filepath = fullPath;
return MoveTemp(Content);
}
}
return MoveTemp(Content);
});
state->init();
}
void UBusyGameInstance::CloseLuaState() {
if (state) {
state->close();
delete state;
state = nullptr;
}
}
void UBusyGameInstance::Init(){
Super::Init();
FCoreDelegates::OnEndFrame.AddUObject(this, &UBusyGameInstance::OnEndFrame);
}
void UBusyGameInstance::Shutdown() {
CloseLuaState();
FCoreDelegates::OnEndFrame.RemoveAll(this);
Super::Shutdown();
}
void UBusyGameInstance::LuaStateInitCallback(NS_SLUA::lua_State* L) {
using namespace slua;
lua_pushcfunction(L, PrintLog);
lua_setglobal(L, "PrintLog");
// <20><><EFBFBD><EFBFBD>EndFrame
LuaGameInstance = state->doFile("GameInstance");
LuaGameInstance.getFromTable("OnEndFrame", OnLuaEndFrame);
}
void UBusyGameInstance::OnEndFrame(){
OnLuaEndFrame.call();
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyGameMode.h"

View File

@ -0,0 +1,72 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyGamePlayLibrary.h"
#include "BusyDataAsset.h"
static inline const UBusyDataAsset* GetGameAsset() {
FSoftObjectPath AssetPath(TEXT("BusyRabbit.BusyDataAsset'/Game/Data/BusyGameAsset.BusyGameAsset'"));
return Cast<UBusyDataAsset>(AssetPath.TryLoad());
}
template<typename RowStruct>
static bool GetTableConfig(const FString& TableName, const FName& RowName, RowStruct& RowData) {
UDataTable* Table = UBusyGamePlayLibrary::GetGameDataTable(TableName);
RowStruct* Config = Table->FindRow<RowStruct>(
RowName,
*FString::Printf(TEXT("GetTableConfig, %s"), *RowName.ToString()),
true
);
if (Config != nullptr) {
RowData = *Config;
return true;
}
else {
return false;
}
}
UDataTable* UBusyGamePlayLibrary::GetGameDataTable(const FString& TableName){
const UBusyDataAsset* GameAsset = GetGameAsset();
if (!GameAsset) return nullptr;
auto Table = (GameAsset->DataTableMapping.Find(TableName));
return Table ? Table->Get() : nullptr;
}
UClass* UBusyGamePlayLibrary::GetGameClass(const FString& ClassName){
const UBusyDataAsset* GameAsset = GetGameAsset();
if (!GameAsset) return nullptr;
auto Class = (GameAsset->ClassPathMapping.Find(ClassName));
return Class ? Class->Get() : nullptr;
}
UClass* UBusyGamePlayLibrary::GetGameUIClass(const FString& ClassName){
const UBusyDataAsset* GameAsset = GetGameAsset();
if (!GameAsset) return nullptr;
auto Class = (GameAsset->UIPathMapping.Find(ClassName));
return Class ? Class->Get() : nullptr;
}
UWorld* UBusyGamePlayLibrary::K2_GetWorld(UObject* obj){
return Cast<UWorld>(obj->GetOuter());
}
bool UBusyGamePlayLibrary::GetLevelBaseConfig(const FName& RowName, FBusyLevelBaseConfig& RowData){
return GetTableConfig<FBusyLevelBaseConfig>(TEXT("LevelBaseConfig"), RowName, RowData);
}
bool UBusyGamePlayLibrary::GetLevelItemConfig(const FName& RowName, FBusyLevelItemConfig& RowData){
return GetTableConfig<FBusyLevelItemConfig>(TEXT("LevelItems"), RowName, RowData);
}
bool UBusyGamePlayLibrary::GetRoleConfig(const FName& RowName, FBusyRoleConfig& RowData){
return GetTableConfig<FBusyRoleConfig>(TEXT("RoleConfig"), RowName, RowData);
}
bool UBusyGamePlayLibrary::GetItemResourceConfig(const FName& RowName, FBusyLevelItemResourceConfig& RowData){
return GetTableConfig<FBusyLevelItemResourceConfig>(TEXT("LevelItemResource"), RowName, RowData);
}
bool UBusyGamePlayLibrary::GetLevelItemDescription(const FName& RowName, FBusyLevelItemDescription& RowData){
return GetTableConfig<FBusyLevelItemDescription>(TEXT("LevelItemDesc"), RowName, RowData);
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyGameState.h"

View File

@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyLevelLogicSubSystem.h"
UBusyLevelLogicSubSystem::UBusyLevelLogicSubSystem(){
}
void UBusyLevelLogicSubSystem::Initialize(FSubsystemCollectionBase& Collection){
Super::Initialize(Collection);
ReceiveSubSystemInitialize();
}
void UBusyLevelLogicSubSystem::Tick(float DeltaTime){
Super::Tick(DeltaTime);
ReceiveSubSystemTick(DeltaTime);
}
FString UBusyLevelLogicSubSystem::GetLuaFilePath_Implementation() const {
return TEXT("GamePlay/Level/BusyLevelLogicSubSystem");
}
void UBusyLevelLogicSubSystem::OnWorldBeginPlay(UWorld& InWorld){
Super::OnWorldBeginPlay(InWorld);
ReceiveWorldBeginPlay();
}
void UBusyLevelLogicSubSystem::Deinitialize(){
Super::Deinitialize();
}
TStatId UBusyLevelLogicSubSystem::GetStatId() const{
return Super::GetStatID();
}

View File

@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyPlayerController.h"
#include "BusyGameInstance.h"
void ABusyPlayerController::BeginPlay(){
Super::BeginPlay();
bShowMouseCursor = true; // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
FInputModeGameAndUI InputMode;
InputMode.SetHideCursorDuringCapture(false);
InputMode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
SetInputMode(InputMode);
}

View File

@ -0,0 +1,10 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BusyPlayerState.h"
#include "Components/InventoryComponent.h"
ABusyPlayerState::ABusyPlayerState(){
Inventory = CreateDefaultSubobject<UInventoryComponent>("Inventory");
}

View File

@ -0,0 +1,228 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Components/InventoryComponent.h"
#include "Math/UnrealMathUtility.h"
UInventoryComponent::UInventoryComponent() : Capacity(20) {
LuaFilePath = TEXT("GamePlay.Components.InventoryComponent");
}
bool UInventoryComponent::DepositItems(int32 ItemID, int32 ItemCnt) {
int32 RemainItemCnt = ItemCnt;
if (ItemCnt <= 0) {
return true;
}
if (!IsCanContain(ItemID, ItemCnt)) {
return false;
}
while (RemainItemCnt > 0) {
FInventoryGrid& Grid = GetOrCreateGrid(ItemID);
int32 GridRemainCapacity = Grid.MaxCount - Grid.CurrentCount;
int32 AddCount = FMath::Min(RemainItemCnt, GridRemainCapacity);
Grid.CurrentCount += AddCount;
RemainItemCnt -= AddCount;
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>¼<EFBFBD>
OnInventoryChanged.Broadcast(ItemID);
return true;
}
bool UInventoryComponent::WithdrawItems(int32 ItemID, int32 ItemCnt) {
if (ItemCnt <= 0) {
return true;
}
if (!IsEnough(ItemID, ItemCnt)) {
return false;
}
int32 RemainToWithdraw = ItemCnt;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E4BBAF><EFBFBD>
for (int32 i = InventoryList.Num() - 1; i >= 0 && RemainToWithdraw > 0; --i) {
FInventoryGrid& Grid = InventoryList[i];
if (Grid.ItemID == ItemID) {
int32 RemoveCount = FMath::Min(RemainToWithdraw, Grid.CurrentCount);
Grid.CurrentCount -= RemoveCount;
RemainToWithdraw -= RemoveCount;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>¼<EFBFBD>
OnInventoryChanged.Broadcast(ItemID);
return true;
}
bool UInventoryComponent::ConsumeItems(int32 Index, int32 ItemCnt) {
if (ItemCnt <= 0) {
return true;
}
if (!InventoryList.IsValidIndex(Index)) {
return false;
}
FInventoryGrid& SpecifiedGrid = InventoryList[Index];
int32 ItemID = SpecifiedGrid.ItemID;
if (!IsEnough(ItemID, ItemCnt)) {
return false;
}
// <20>ȿ۳<C8BF>ָ<EFBFBD><D6B8>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ʒ
int32 RemoveFromSpecified = FMath::Min(ItemCnt, SpecifiedGrid.CurrentCount);
SpecifiedGrid.CurrentCount -= RemoveFromSpecified;
int32 RemainToConsume = ItemCnt - RemoveFromSpecified;
// <20>ٿ۳<D9BF><DBB3><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ʒ
if (RemainToConsume > 0) {
for (int32 i = InventoryList.Num() - 1; i >= 0 && RemainToConsume > 0; --i) {
if (i == Index) continue; // <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>λ<EFBFBD><CEBB>
FInventoryGrid& Grid = InventoryList[i];
if (Grid.ItemID == ItemID) {
int32 RemoveCount = FMath::Min(RemainToConsume, Grid.CurrentCount);
Grid.CurrentCount -= RemoveCount;
RemainToConsume -= RemoveCount;
}
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>¼<EFBFBD>
OnInventoryChanged.Broadcast(ItemID);
return true;
}
void UInventoryComponent::SetInventoryCapacity(int MaxCapacity) {
int32 NewCapacity = FMath::Max(0, MaxCapacity);
if (Capacity != NewCapacity) {
Capacity = NewCapacity;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
OnInventoryCapacityChanged.Broadcast();
}
}
void UInventoryComponent::ReSortAllItem() {
// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA>ĸ<EFBFBD><C4B8><EFBFBD>
for (int32 i = InventoryList.Num() - 1; i >= 0; --i) {
if (InventoryList[i].CurrentCount <= 0) {
InventoryList.RemoveAt(i);
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
InventoryList.Sort([](const FInventoryGrid& A, const FInventoryGrid& B) {
return A.Priority > B.Priority; // <20><><EFBFBD>ȼ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ
});
}
bool UInventoryComponent::IsCanContain(int32 ItemID, int32 Count) {
if (Count <= 0) return true;
int32 EmptySlotCount= 0;
int32 ExistingSpace = 0;
int32 ExistingGrids = 0;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>пռ<D0BF>
for (const FInventoryGrid& Grid : InventoryList) {
if (Grid.ItemID == ItemID) {
ExistingSpace += (Grid.MaxCount - Grid.CurrentCount);
ExistingGrids++;
}else if (Grid.ItemID == 0 || Grid.CurrentCount == 0) {
EmptySlotCount++;
}
}
if (ExistingSpace >= Count) {
return true;
}
int32 NeededSpace = Count - ExistingSpace;
// <20><><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><C2B8>ӿ<EFBFBD><D3BF>ÿռ<C3BF>
int32 AvailableGridSlots = Capacity - InventoryList.Num() + EmptySlotCount;
if (AvailableGridSlots <= 0) {
return false;
}
// <20><>ȡ<EFBFBD><C8A1>ƷĬ<C6B7>϶ѵ<CFB6><D1B5><EFBFBD>С
FInventoryGrid TempGrid;
TempGrid.ItemID = ItemID;
InitItemGrid(TempGrid);
int32 NewGridSpace = AvailableGridSlots * TempGrid.MaxCount;
return (ExistingSpace + NewGridSpace) >= Count;
}
bool UInventoryComponent::IsEnough(int32 ItemID, int32 Count) {
if (Count <= 0) return true;
int32 Total = 0;
for (const FInventoryGrid& Grid : InventoryList) {
if (Grid.ItemID == ItemID) {
Total += Grid.CurrentCount;
}
}
return Total >= Count;
}
FInventoryGrid UInventoryComponent::GetGridWithIndex(int32 Index) {
return InventoryList.IsValidIndex(Index) ? InventoryList[Index] : FInventoryGrid();
}
void UInventoryComponent::InitItemGrid_Implementation(FInventoryGrid& Grid) {
Grid.CurrentCount = 0;
Grid.MaxCount = 20; // Ĭ<>϶ѵ<CFB6><D1B5><EFBFBD>С
Grid.Priority = 1; // Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
}
void UInventoryComponent::ForEach(const FVisitInventoryGridDelegate& VisitDelegate) {
for (int32 i = 0; i < InventoryList.Num(); ++i) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>CurrentCount <= 0<><30>
if (InventoryList[i].CurrentCount > 0) {
VisitDelegate.ExecuteIfBound(i, InventoryList[i]);
}
}
}
FInventoryGrid& UInventoryComponent::GetOrCreateGrid(int32 ItemID) {
// <20><><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
for (FInventoryGrid& Grid : InventoryList) {
if (Grid.ItemID == 0 || Grid.CurrentCount == 0) {
Grid.ItemID = ItemID;
InitItemGrid(Grid);
return Grid;
}
if (Grid.ItemID == ItemID && Grid.CurrentCount < Grid.MaxCount) {
return Grid;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (InventoryList.Num() >= Capacity) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static FInventoryGrid DummyGrid;
DummyGrid = FInventoryGrid();
InitItemGrid(DummyGrid);
DummyGrid.ItemID = ItemID;
return DummyGrid;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD><C2B8><EFBFBD>
FInventoryGrid NewGrid;
NewGrid.ItemID = ItemID;
InitItemGrid(NewGrid);
// <20><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EBB5BD>ȷλ<C8B7><CEBB>
int32 InsertIndex = 0;
for (; InsertIndex < InventoryList.Num(); InsertIndex++) {
if (NewGrid.Priority > InventoryList[InsertIndex].Priority) {
break;
}
}
return InventoryList.Insert_GetRef(NewGrid, InsertIndex);
}

View File

@ -0,0 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/BusyLuaActorComponent.h"
void UBusyLuaActorComponent::BeginPlay(){
Super::BeginPlay();
ReceiveLuaBeginPlay();
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/BusyLuaUserWidget.h"

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_Ability.h"
UPW_Ability::UPW_Ability(){
bHasBlueprintActivateFromEvent = true;
}
FString UPW_Ability::GetLuaFilePath_Implementation() const{
return LuaFilePath;
}
void UPW_Ability::ApplyCost(
const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo) const {
BP_ApplyCost(Handle, *ActorInfo, ActivationInfo);
}
void UPW_Ability::BP_ApplyCost_Implementation(
const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo& ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo ) const {
Super::ApplyCost(Handle, &ActorInfo, ActivationInfo);
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_AbilitySystemComponent.h"

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_ListViewEntry.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_Object.h"
UPW_Object::UPW_Object(){
//FString Left, Right;
//if (this->GetName().Split(TEXT("_"), &Left, &Right)) {
// LuaFilePath = Left;
//}else {
// LuaFilePath = this->GetName();
//}
}
FString UPW_Object::GetLuaFilePath_Implementation() const{
return LuaFilePath;
}

View File

@ -0,0 +1,33 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_TimerModule.h"
//int UPW_TimerModule::SetTimer(slua::LuaVar cb){
// UWorld* World = GetWorld();
// if (!World) {
// return -1;
// }
// FTimerManager &TimerManager = World->GetTimerManager();
//
// //// <20><><EFBFBD><EFBFBD>ί<EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD>Lambda
// //FTimerDelegate Delegate = FTimerDelegate::CreateLambda(
// // [this](int32 index) {
// // UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
// // }
// //);
//
//
//
// //// <20><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD>
// //TimerManager.SetTimer(
// // TimerHandle,
// // Delegate,
// // 2.0f,
// // false,
// // "Hello from Timer!" // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>ί<EFBFBD>д<EFBFBD><D0B4><EFBFBD>
// //);
//
// //TimerManager.SetTimer()
// //return 0;
//}

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/PW_UserWidget.h"
UPW_SimpleWidget::UPW_SimpleWidget():bVisible(true){
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
}
bool UPW_SimpleWidget::Initialize(){
return UUserWidget::Initialize();
}
void UPW_SimpleWidget::SetVisible(bool Visible){
if (bVisible == Visible) { return; }
if ((bVisible = Visible)) {
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
}
else {
SetVisibility(ESlateVisibility::Collapsed);
}
}

View File

@ -0,0 +1,175 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/UI/PW_TableSwitcher.h"
#include "Components/Button.h"
#include "Components/Overlay.h"
#include "Components/TextBlock.h"
#include "Components/HorizontalBox.h"
#include "Components/HorizontalBoxSlot.h"
void UPW_TableSwitcherWidget::NativeOnInitialized(){
Super::NativeOnInitialized();
BtnMain->SetRenderOpacity(0);
}
void UPW_TableSwitcherWidget::NativeConstruct(){
Super::NativeConstruct();
BtnMain->SetIsEnabled(true);
BtnMain->OnClicked.AddDynamic(this, &UPW_TableSwitcherWidget::OnWidgetClicked);
BtnMain->OnHovered.AddDynamic(this, &UPW_TableSwitcherWidget::OnWidgetHovered);
BtnMain->OnUnhovered.AddDynamic(this, &UPW_TableSwitcherWidget::OnWidgetUnHovered);
}
void UPW_TableSwitcherWidget::NativeDestruct(){
Super::NativeDestruct();
BtnMain->SetIsEnabled(false);
BtnMain->OnClicked.Clear();
}
void UPW_TableSwitcherWidget::OnWidgetClicked(){
OnTableWidgetClicked.Broadcast(this);
}
void UPW_TableSwitcherWidget::OnWidgetHovered(){
OnHoverStateChange.Broadcast(this, true);
}
void UPW_TableSwitcherWidget::OnWidgetUnHovered(){
OnHoverStateChange.Broadcast(this, false);
}
void UPW_TableSwitcherWidget::SetHoveredState(bool bIsWidgetHovered){
if (this->bIsHovered == bIsWidgetHovered) return;
this->bIsHovered = bIsWidgetHovered;
OnWidgetStateChange(bIsHovered, bIsSelected);
}
void UPW_TableSwitcherWidget::SetSelectedState(bool bIsWidgetSelected) {
if (this->bIsSelected == bIsWidgetSelected) return;
this->bIsSelected = bIsWidgetSelected;
OnWidgetStateChange(bIsHovered, bIsSelected);
}
void UPW_TableSwitcherWidget::SetSwitcherTitle(const FText& Text){
SwitcherTitle->SetText(Text);
}
void UPW_TableSwitcherPage::SwitchIn(const FName& SwitcherName){
if (bIsShowing) return;
bIsShowing = true;
OnSwitchIn(SwitcherName);
}
void UPW_TableSwitcherPage::SwitchOut(const FName& SwitcherName){
if (!bIsShowing) return;
bIsShowing = false;
OnSwitchOut(SwitcherName);
}
void UPW_TableSwitcher::NativePreConstruct() {
Super::NativePreConstruct();
if (IsDesignTime()) {
RebuildSwitcher(SwicthersInfo);
}
}
void UPW_TableSwitcher::NativeOnInitialized(){
Super::NativeOnInitialized();
RebuildSwitcher(SwicthersInfo);
}
void UPW_TableSwitcher::RebuildSwitcher(const TMap<FName, FTableSwitcherInfo>& Infos){
UPW_TableSwitcherWidget* Widget;
TWeakObjectPtr<UPW_TableSwitcher> WeakThis(this);
SwitcherBar->ClearChildren();
for (auto It = Infos.CreateConstIterator(); It; ++It){
const FName& PageName= It->Key;
const FTableSwitcherInfo& Info = It->Value;
if (!Info.SwitcherWidget) continue;
Widget = CreateWidget<UPW_TableSwitcherWidget>(this, Info.SwitcherWidget);
UHorizontalBoxSlot *WidgetSlot = SwitcherBar->AddChildToHorizontalBox(Widget);
if (WidgetSlot) {
WidgetSlot->VerticalAlignment = VAlign_Fill;
}
Widget->SetSwitcherName(PageName);
Widget->SetSwitcherTitle(Info.TableSwitcherName);
SwitcherWidgets.Add(PageName, Widget);
if (IsDesignTime()) continue;
Widget->OnTableWidgetClicked.AddLambda([WeakThis](UPW_TableSwitcherWidget* SelectedWidget) {
if(WeakThis.IsValid())
WeakThis->SetSelectedSwitcher(SelectedWidget->GetSwitcherName());
});
Widget->OnHoverStateChange.AddLambda([WeakThis](UPW_TableSwitcherWidget* SelectedWidget, bool IsHover) {
UPW_TableSwitcherWidget* TableWidget;
if (!WeakThis.IsValid()) return;
for (UWidget* RawWidget : WeakThis->SwitcherBar->GetAllChildren()) {
if ((TableWidget = Cast<UPW_TableSwitcherWidget>(RawWidget))) {
TableWidget->SetHoveredState(false);
}
}
SelectedWidget->SetHoveredState(IsHover);
});
}
}
UPW_TableSwitcherPage* UPW_TableSwitcher::GetOrCreateSwitcherPage(const FName& SwitcherName){
UPW_TableSwitcherPage* Page;
TWeakObjectPtr<UPW_TableSwitcherPage>* FindResult = SwitcherPages.Find(SwitcherName);
if (FindResult != nullptr) {
return FindResult->Get();
}
FTableSwitcherInfo* SwitcherInfo = SwicthersInfo.Find(SwitcherName);
if (SwitcherInfo == nullptr || SwitcherInfo->PageWidget == nullptr) return nullptr;
Page = CreateWidget<UPW_TableSwitcherPage>(this, SwitcherInfo->PageWidget);
SwitcherPages.Add(SwitcherName, Page);
PanelOverlay->AddChildToOverlay(Page);
return Page;
}
void UPW_TableSwitcher::SetSelectedSwitcher(const FName& SwitcherName) {
UPW_TableSwitcherPage* Page = GetOrCreateSwitcherPage(SwitcherName);
if (Page == nullptr) return;
for (auto It = SwitcherWidgets.CreateConstIterator(); It; ++It) {
It->Value->SetSelectedState(It->Key == SwitcherName);
}
for (auto It = SwitcherPages.CreateConstIterator(); It; ++It) {
if (It->Key == SwitcherName) continue;
It->Value->SwitchOut(SwitcherName);
}
Page->SwitchIn(SwitcherName);
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Gas/BusyAbilitySystemComponent.h"

View File

@ -0,0 +1,78 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Gas/BusyAttributeSet.h"
#include "BusyGameInstance.h"
static FString GetPropertyNameInOwner(UObject *Attr){
UObject* Outer = Attr->GetOuter();
if (!Outer) return FString();
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FProperty* Property = nullptr;
for (TFieldIterator<FProperty> PropIt(Outer->GetClass()); PropIt; ++PropIt){
Property = *PropIt;
if (FObjectProperty* ObjectProperty = CastField<FObjectProperty>(Property)){
if (ObjectProperty->PropertyClass == Attr->GetClass()){
void* ValuePtr = Property->ContainerPtrToValuePtr<void>(Outer);
UObject* PropertyValue = ObjectProperty->GetObjectPropertyValue(ValuePtr);
if (PropertyValue == Attr){
return Property->GetName();
}
}
}
}
return FString();
}
static void CopyAttributeToTable(UObject* Attribute, slua::LuaVar& LuaTable) {
FProperty* Property = nullptr;
FGameplayAttributeData* Data = nullptr;
UClass* AttributeClass = Attribute->GetClass();
for (TFieldIterator<FProperty> PropIt(AttributeClass); PropIt; ++PropIt) {
Property = *PropIt;
if (Property->GetOwnerClass() != AttributeClass) continue; // ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><EFBFBD><E0A3A8><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>
FStructProperty* StructProperty = CastField<FStructProperty>(Property);
if (!StructProperty || StructProperty->Struct != FGameplayAttributeData::StaticStruct()) continue;
Data = StructProperty->ContainerPtrToValuePtr<FGameplayAttributeData>(Attribute);
if (!Data) continue;
LuaTable.setToTable(Property->GetName(),Data->GetBaseValue());
}
}
bool UPW_AttributeSet::RegisterCustomAttribute(){
ILuaOverriderInterface* Owner = Cast<ILuaOverriderInterface>(GetOwningActor());
if (!Owner) return false;
// <20><>ȡActor<6F><72>Lua<75><61><EFBFBD><EFBFBD>
slua::LuaVar SelfTable = Owner->GetSelfTable();
// <20><>ȡ LuaState
slua::lua_State * RawState = SelfTable.getState();
// <20><><EFBFBD><EFBFBD> Reactive ģ<><C4A3>
slua::LuaVar moduleTable = slua::LuaState::get(RawState)->requireModule("Core.Reactive");
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ReactiveProperty <20><><EFBFBD><EFBFBD>
LuaSideData = moduleTable.callField("ReactiveProperty");
// <20><>Attribute<74><65><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Lua Reactive Property
CopyAttributeToTable(this, LuaSideData);
// <20><><EFBFBD><EFBFBD>Lua Reactive Property
auto name = GetPropertyNameInOwner(this);
Owner->GetSelfTable().setToTable<FString, slua::LuaVar>(
TEXT("Lua") + name, LuaSideData, true
);
return true;
}
void UPW_AttributeSet::PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue){
FString AttributeName = Attribute.GetName();
LuaSideData.setToTable(AttributeName, NewValue);
OnAttributeChanged.Broadcast(AttributeName, OldValue, NewValue);
}

View File

@ -0,0 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Hud/BusyGameHud.h"
FString ABusyGameHud::GetLuaFilePath_Implementation() const{
return LuaFilePath;
}
//void ABusyGameHud::PushWidget(const FName& WidgetName){
// auto WidgetClass = UIClassMapping.Find(WidgetName);
// APlayerController* PC = GetOwningPlayerController();
// CreateWidget<UUserWidget>();
//}

View File

@ -0,0 +1,107 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Level/BusyLevelItem.h"
#include "Components/CapsuleComponent.h"
#include "Components/WidgetComponent.h"
#include "Gas/BusyAbilitySystemComponent.h"
#include "BusyGamePlayLibrary.h"
ABusyLevelItem::ABusyLevelItem(): CurrentItemID("100001") {
LuaFilePath = TEXT("GamePlay.LevelItem.LevelItem");
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("LevelItemCapsule"));
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
PickBar = CreateDefaultSubobject<UWidgetComponent>(TEXT("PickBar"));
LevelItemAttribute = CreateDefaultSubobject<UBusyLevelItemAttributeSet>("LevelItemAttribute");
AbilityComponent = CreateDefaultSubobject<UBusyAbilitySystemComponent>("RoleAbility");
InitSprite();
InitCapsule();
InitPickBar();
PickBar->SetupAttachment(CapsuleComp);
Sprite->SetupAttachment(CapsuleComp);
CapsuleComp->SetupAttachment(SceneComp);
this->RootComponent = SceneComp;
}
void ABusyLevelItem::OnConstruction(const FTransform& Transform){
Super::OnConstruction(Transform);
SetItemDisplay(CurrentItemID);
}
void ABusyLevelItem::BeginPlay(){
UClass* cls = UBusyGamePlayLibrary::GetGameUIClass("PickBar");
if (cls != nullptr) {
PickBar->SetWidgetClass(cls);
}
Super::BeginPlay();
}
void ABusyLevelItem::InitCapsule(){
CapsuleComp->SetCollisionProfileName(TEXT("Custom"));
CapsuleComp->SetNotifyRigidBodyCollision(false);
CapsuleComp->SetSimulatePhysics(false);
CapsuleComp->SetEnableGravity(false);
CapsuleComp->SetCollisionObjectType(ECC_WorldStatic); // 设置对象类型
// 逐个通道设置响应
CapsuleComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
//CapsuleComp->SetCollisionResponseToAllChannels(ECR_Ignore);
CapsuleComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
CapsuleComp->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Ignore);
CapsuleComp->SetCapsuleRadius(10);
}
void ABusyLevelItem::InitSprite(){
Sprite->SetRelativeRotation(FRotator(0.0, 0.0, -90.0));
}
void ABusyLevelItem::InitPickBar(){
PickBar->SetRelativeRotation(FRotator(90.0, 0.0, -90.0));
PickBar->SetRelativeLocation(FVector(0.0, -180.0, 0.0));
PickBar->SetGenerateOverlapEvents(false);
}
void ABusyLevelItem::SetItemDisplay(const FName& ItemID){
UDataTable* Resource = UBusyGamePlayLibrary::GetGameDataTable(TEXT("LevelItemResource"));
// 查物品信息
FBusyLevelItemResourceConfig* ResourceConfig = Resource->FindRow<FBusyLevelItemResourceConfig>(
ItemID, TEXT("ABusyLevelItem::SetLevelItemID"), true
);
// 设置资源
if (ResourceConfig != nullptr && ResourceConfig->StaticResource) {
this->Sprite->SetFlipbook(ResourceConfig->StaticResource);
this->CurrentItemID = ItemID;
}
}
void ABusyLevelItem::SetLevelItemID(const FName& ItemID){
// 取物品资源表
UDataTable* ConfigTable = UBusyGamePlayLibrary::GetGameDataTable(TEXT("LevelItems"));
// 查物品信息
FBusyLevelItemConfig* ItemConfig = ConfigTable->FindRow<FBusyLevelItemConfig>(
ItemID, TEXT("ABusyLevelItem::SetLevelItemID"), true
);
SetItemDisplay(ItemID);
// 设置配置属性
if (ItemConfig == nullptr) return;
// 初始化Attribute
LevelItemAttribute->InitHealth(ItemConfig->PickTimeCost);
LevelItemAttribute->RegisterCustomAttribute();
CurrentItemID = ItemID;
LevelItemConfig = *ItemConfig;
ReceiveLevelItemSetted(LevelItemConfig);
}

View File

@ -0,0 +1,33 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Level/LevelItemReward.h"
#include "Components/CapsuleComponent.h"
#include "Components/SceneComponent.h"
#include "PaperFlipbook.h"
#include "PaperFlipbookComponent.h"
#include "BusyGamePlayLibrary.h"
ALevelItemReward::ALevelItemReward(){
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RoleCapsule"));
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
CapsuleComp->SetupAttachment(SceneComp);
Sprite->SetupAttachment(CapsuleComp);
this->RootComponent = SceneComp;
}
void ALevelItemReward::OnConstruction(const FTransform& Transform){
SetRewardID(RewardID);
}
void ALevelItemReward::SetRewardID(const FName& CurrentRewardID){
bool bIsFind = false;
FBusyLevelItemDescription Desc;
if (CurrentRewardID.IsNone()) return;
bIsFind = UBusyGamePlayLibrary::GetLevelItemDescription(CurrentRewardID, Desc);
if (!bIsFind) return;
this->RewardID = CurrentRewardID;
this->Sprite->SetFlipbook(Desc.LevelResource.LoadSynchronous());
}

View File

@ -0,0 +1,111 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Role/BusyRole.h"
#include "GameFramework/SpringArmComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/SceneComponent.h"
#include "BusyCameraComponent.h"
#include "PaperFlipbookComponent.h"
#include "Role/BusyRoleMovement.h"
#include "Role/RoleAnimation.h"
#include "BusyGamePlayLibrary.h"
#include "Gas/BusyAbilitySystemComponent.h"
#include "Components/InventoryComponent.h"
#include "Core/PW_AbilitySystemComponent.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
ABusyRole::ABusyRole(){
SceneComp = CreateDefaultSubobject<USceneComponent>(TEXT("RootScene"));
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("RoleCapsule"));
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
CameraComp = CreateDefaultSubobject<UBusyCameraComponent>(TEXT("RoleCamera"));
Sprite = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("Sprite"));
Movement = CreateDefaultSubobject<UBusyRoleMovement>(TEXT("Movement"));
RoleAnimation = CreateDefaultSubobject<URoleAnimation>(TEXT("RoleAnimation"));
Inventory = CreateDefaultSubobject<UInventoryComponent>(TEXT("Inventory"));
RoleAbility = CreateDefaultSubobject<UPW_AbilitySystemComponent>("RoleAbility");
RoleAttribute = CreateDefaultSubobject<UBusyRoleAttributeSet>(TEXT("RoleAttributeSet"));
SpringArmComp->SetRelativeRotation(FRotator(-90.0, -90.0, 0.0));
this->InitCapsule();
Sprite->SetupAttachment(CapsuleComp);
CapsuleComp->SetupAttachment(SceneComp);
SpringArmComp->SetupAttachment(CapsuleComp);
CameraComp->SetupAttachment(SpringArmComp);
PrimaryActorTick.bCanEverTick = true;
this->RootComponent = SceneComp;
}
void ABusyRole::BeginPlay(){
Super::BeginPlay();
if (APlayerController* PlayerController = Cast<APlayerController>(GetController())) {
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer())) {
Subsystem->AddMappingContext(InputMapping, 0);
}
}
}
void ABusyRole::Tick(float InDeltaSeconds){
Super::Tick(InDeltaSeconds);
}
void ABusyRole::SetRole(const FName& Name){
UDataTable* Table = UBusyGamePlayLibrary::GetGameDataTable("RoleConfig");
if (Table == nullptr) {
return;
}
FBusyRoleConfig *Row = Table->FindRow<FBusyRoleConfig>(Name, TEXT("ABusyRole::SetRole"));
if (Row == nullptr) {
return;
}
RoleName = Name;
RoleConfig = *Row;
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (RoleAttribute) {
RoleAttribute->InitHealth(Row->Health);
RoleAttribute->InitHunger(Row->Hunger);
RoleAttribute->InitMoveSpeed(Row->MoveSpeed);
RoleAttribute->RegisterCustomAttribute();
}
// <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>
for (UClass* AbilityClass : Row->DefaultAbilities) {
if (AbilityClass) {
RoleAbility->GiveAbility(FGameplayAbilitySpec(AbilityClass));
}
}
ReceiveSetRole(RoleConfig);
}
void ABusyRole::TryActiveAbility(const FName& TagName,const FGameplayEventData& EventData){
RoleAbility->HandleGameplayEvent(FGameplayTag::RequestGameplayTag(TagName), &EventData);
}
void ABusyRole::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent){
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (UEnhancedInputComponent* EnhancedInput = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {
EnhancedInput->BindAction(TouchAction, ETriggerEvent::Triggered, this, FName("OnTouch"));
}
}
void ABusyRole::InitCapsule(){
FScriptDelegate OverlapDelegate;
CapsuleComp->SetCollisionProfileName(TEXT("Pawn"));
CapsuleComp->SetNotifyRigidBodyCollision(false);
OverlapDelegate.BindUFunction(this, "OnOverlapBegin");
CapsuleComp->OnComponentBeginOverlap.Add(OverlapDelegate);
CapsuleComp->SetCapsuleRadius(10);
}

View File

@ -0,0 +1,22 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Role/BusyRoleMovement.h"
#include "PaperFlipbookComponent.h"
UBusyRoleMovement::UBusyRoleMovement(){
LuaFilePath = TEXT("GamePlay/BusyRole/Movement");
this->PrimaryComponentTick.bCanEverTick = true;
}
void UBusyRoleMovement::BeginPlay(){
Super::BeginPlay();
ReceiveComponentBeginPlay();
}
void UBusyRoleMovement::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction){
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
this->ReceiveComponentTick(DeltaTime);
}

View File

@ -0,0 +1,117 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Role/RoleAnimation.h"
#include "Role/BusyRole.h"
#include "BusyGamePlayLibrary.h"
DEFINE_LOG_CATEGORY(LogRoleAnimation);
URoleAnimation::URoleAnimation(){
LuaFilePath = TEXT("GamePlay.BusyRole.Animation");
}
void URoleAnimation::SetMoveAnimation(ERoleMoveDirection direction){
FBusyRoleAnimationData* Config;
UPaperFlipbookComponent* Sprite;
if (!GetOwnerRoleInfo(Sprite, Config)) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetMoveAnimation, Can't get owner info"));
return;
}
SetRoleAnimation(Sprite, Config->MoveAnimations.Find(direction));
}
void URoleAnimation::SetIdleAnimation(ERoleMoveDirection direction){
FBusyRoleAnimationData* Config;
UPaperFlipbookComponent* Sprite;
if (!GetOwnerRoleInfo(Sprite, Config)) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetMoveAnimation, Can't get owner info"));
return;
}
SetRoleAnimation(Sprite, Config->IdleAnimations.Find(direction));
}
void URoleAnimation::PlayPickAnimation(const FName& ItemName, ERoleMoveDirection Direction, EBusyAnimationPhase Phase, float PlayRate){
FBusyRoleAnimationData* Config;
UPaperFlipbookComponent* Sprite;
if (!GetOwnerRoleInfo(Sprite, Config)) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get owner info"));
return;
}
FBusyRolePickingAnimationData *Directions = Config->PickingAnimations.Find(ItemName);
if (Directions == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get Directions Animation"));
return;
}
FBusyAnimationPhaseData *PhaseData = Directions->DirectionAnimations.Find(Direction);
if (PhaseData == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get PhaseData Animation"));
return;
}
UPaperFlipbook **Animation = PhaseData->PhaseAnimation.Find(Phase);
if (Animation == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetPickAnimation, Can't get Animation"));
return;
}
PlayAnimationOnce(Sprite, Animation, PlayRate);
}
bool URoleAnimation::GetOwnerRoleInfo(UPaperFlipbookComponent*& Sprite, FBusyRoleAnimationData*& AnimationData){
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>owner
ABusyRole* Role = Cast<ABusyRole>(this->GetOwner());
if (Role == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetPaperFilpBookComponent, Can't get Role"));
return false;
}
// <20><><EFBFBD><EFBFBD>owner<65><72><EFBFBD><EFBFBD>
UDataTable* DataTable = UBusyGamePlayLibrary::GetGameDataTable("RoleAnimation");
if (DataTable == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetOwnerRoleInfo, Can't get Animation DataTable"))
return false;
}
FBusyRoleAnimationData* Config = DataTable->FindRow<FBusyRoleAnimationData>(
Role->RoleName, TEXT("URoleAnimation::GetOwnerRoleInfo")
);
if (Config == nullptr) {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::GetOwnerRoleInfo, Can't get role info from table"))
return false;
}
Sprite = Role->Sprite;
AnimationData = Config;
return true;
}
void URoleAnimation::SetRoleAnimation(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim){
if (Anim && *Anim) {
Sprite->Stop();
Sprite->SetLooping(true);
Sprite->SetPlayRate(1.0);
Sprite->SetFlipbook(*Anim);
Sprite->PlayFromStart();
} else {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::SetRoleAnimation, Can't set role animation"));
}
}
void URoleAnimation::PlayAnimationOnce(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim, float PlayRate){
if (Anim && *Anim) {
Sprite->Stop();
Sprite->SetLooping(false);
Sprite->SetPlayRate(PlayRate);
Sprite->SetFlipbook(*Anim);
Sprite->PlayFromStart();
}
else {
UE_LOG(LogRoleAnimation, Error, TEXT("URoleAnimation::PlayAnimationOnce failed"));
}
}

View File

@ -0,0 +1,67 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Datatable.h"
#include "LuaOverriderInterface.h"
#include "Subsystems/WorldSubsystem.h"
#include "Level/BusyLevelItem.h"
#include "BusyActorManagerSubSystem.generated.h"
USTRUCT(BlueprintType)
struct FBusyLevelBaseConfig : public FTableRowBase {
GENERATED_BODY()
/* 第一个篝火的位置 */
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "初始篝火位置")
FVector2D FirstBonfirePosition;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "每次Tick的时间(MS)")
int TickInterval;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "一个物品生成周期包含的Tick次数")
int Period;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName ="关卡中存在的物品配置")
TMap<int32, FBusyLevelItemGenerateConfig> LevelItemIds;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyActorManagerSubSystem : public UWorldSubsystem, public ILuaOverriderInterface
{
GENERATED_BODY()
public:
// 初始化(关卡加载时调用)
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual void OnWorldBeginPlay(UWorld& InWorld)override;
// 销毁(关卡卸载时调用)
virtual void Deinitialize() override;
virtual FString GetLuaFilePath_Implementation() const override;
public: // 需要蓝图实现接口
UFUNCTION(BlueprintImplementableEvent)
void ReceiveSubSystemInitialize();
UFUNCTION(BlueprintImplementableEvent)
void ReceiveWorldBeginPlay();
public:
UFUNCTION(BlueprintPure)
bool GetLevelBaseConfig(FBusyLevelBaseConfig& config);
UFUNCTION(BlueprintCallable)
UWorld* K2_GetWorld();
UFUNCTION(BlueprintCallable)
static UBusyActorManagerSubSystem* Get(UObject* WorldContextObject);
};

View File

@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActor.h"
#include "BusyBonfire.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyBonfire : public ALuaActor
{
GENERATED_BODY()
public:
ABusyBonfire();
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UCapsuleComponent> CapsuleComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class USceneComponent> SceneComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UInventoryComponent> Inventory; // <20>ֿ<EFBFBD>
};

View File

@ -0,0 +1,21 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaOverriderInterface.h"
#include "Camera/CameraComponent.h"
#include "BusyCameraComponent.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyCameraComponent : public UCameraComponent, public ILuaOverriderInterface
{
GENERATED_BODY()
public:
UBusyCameraComponent();
};

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "slua.h"
#include "CoreMinimal.h"
#include "PaperZDCharacter.h"
#include "BusyCharacter.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyCharacter : public APaperZDCharacter, public ILuaOverriderInterface
{
GENERATED_BODY()
public:
virtual FString GetLuaFilePath_Implementation() const override;
//UFUNCTION(BlueprintNativeEvent)
//FString GetLuaFilePath()const;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
FString LuaFilePath;
};

View File

@ -0,0 +1,36 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "Blueprint/UserWidget.h"
#include "BusyDataAsset.generated.h"
UCLASS()
class BUSYRABBIT_API UBusyActorClassAsset: public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "Blueprint Mapping")
TMap<FString, TSubclassOf<AActor>> ClassPathConfig;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyDataAsset : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, Category = "DataTable Mapping")
TMap<FString, TObjectPtr<UDataTable>> DataTableMapping;
UPROPERTY(EditAnywhere, Category = "Actor Class Mapping")
TMap<FString, TSubclassOf<AActor>> ClassPathMapping;
UPROPERTY(EditAnywhere, Category = "UI Class Mapping")
TMap<FString, TSubclassOf<UUserWidget>> UIPathMapping;
};

View File

@ -0,0 +1,45 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "slua.h"
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "BusyGameInstance.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UBusyGameInstance();
public:
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBusyOnEndFrameDelegate);
public:
virtual void Init()override;
virtual void Shutdown() override;
public:
void CreateLuaState();
void CloseLuaState();
void LuaStateInitCallback(NS_SLUA::lua_State* L);
public:
NS_SLUA::LuaState* state;
protected:
UPROPERTY(BlueprintAssignable)
FBusyOnEndFrameDelegate OnEndFrameDelegate;
void OnEndFrame();
protected: // luaside
NS_SLUA::LuaVar LuaGameInstance;
NS_SLUA::LuaVar OnLuaEndFrame;
};

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaGameMode.h"
#include "BusyGameMode.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyGameMode : public ALuaGameMode
{
GENERATED_BODY()
};

View File

@ -0,0 +1,51 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "slua.h"
#include "Role/BusyRole.h"
#include "Engine/World.h"
#include "Level/BusyLevelItem.h"
#include "Engine/DataTable.h"
#include "BusyActorManagerSubSystem.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GameAsset/BusyItem.h"
#include "BusyGamePlayLibrary.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyGamePlayLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
static UDataTable* GetGameDataTable(const FString& TableName);
UFUNCTION(BlueprintCallable)
static UClass* GetGameClass(const FString& ClassName);
UFUNCTION(BlueprintCallable)
static UClass* GetGameUIClass(const FString& ClassName);
UFUNCTION(BlueprintPure)
static UWorld* K2_GetWorld(UObject* obj);
UFUNCTION(BlueprintPure)
static bool GetLevelBaseConfig(const FName& RowName, FBusyLevelBaseConfig& RowData);
UFUNCTION(BlueprintPure)
static bool GetLevelItemConfig(const FName& RowName, FBusyLevelItemConfig& RowData);
UFUNCTION(BlueprintPure)
static bool GetRoleConfig(const FName& RowName, FBusyRoleConfig& RowData);
UFUNCTION(BlueprintPure)
static bool GetItemResourceConfig(const FName& RowName, FBusyLevelItemResourceConfig& RowData);
UFUNCTION(BlueprintPure)
static bool GetLevelItemDescription(const FName& RowName, FBusyLevelItemDescription& RowData);
};

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaGameState.h"
#include "BusyGameState.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyGameState : public ALuaGameState
{
GENERATED_BODY()
};

View File

@ -0,0 +1,51 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaOverriderInterface.h"
#include "Subsystems/WorldSubsystem.h"
#include "BusyLevelLogicSubSystem.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyLevelLogicSubSystem : public UTickableWorldSubsystem, public ILuaOverriderInterface
{
GENERATED_BODY()
public:
UBusyLevelLogicSubSystem();
public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual void Tick(float DeltaTime) override;
virtual FString GetLuaFilePath_Implementation() const override;
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ã<EFBFBD>
virtual void OnWorldBeginPlay(UWorld& InWorld)override;
// <20><><EFBFBD>٣<EFBFBD><D9A3>ؿ<EFBFBD>ж<EFBFBD><D0B6>ʱ<EFBFBD><CAB1><EFBFBD>ã<EFBFBD>
virtual void Deinitialize() override;
virtual TStatId GetStatId() const override;
public: // <20><>Ҫ<EFBFBD><D2AA>ͼʵ<CDBC>ֽӿ<D6BD>
UFUNCTION(BlueprintImplementableEvent)
void ReceiveSubSystemInitialize();
UFUNCTION(BlueprintImplementableEvent)
void ReceiveWorldBeginPlay();
UFUNCTION(BlueprintImplementableEvent)
void ReceiveSubSystemTick(float DeltaTime);
};

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaPlayerController.h"
#include "BusyPlayerController.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyPlayerController : public ALuaPlayerController
{
GENERATED_BODY()
virtual void BeginPlay()override;
};

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaPlayerState.h"
#include "BusyPlayerState.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyPlayerState : public ALuaPlayerState
{
GENERATED_BODY()
public:
ABusyPlayerState();
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UInventoryComponent> Inventory; // <20>ֿ<EFBFBD>
};

View File

@ -0,0 +1,90 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActorComponent.h"
#include "InventoryComponent.generated.h"
USTRUCT(BlueprintType)
struct FInventoryGrid {
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, DisplayName = "物品ID")
int32 ItemID;
UPROPERTY(BlueprintReadWrite, DisplayName = "当前的数量")
int32 CurrentCount;
UPROPERTY(BlueprintReadWrite, DisplayName = "最大堆叠限制")
int32 MaxCount;
UPROPERTY(BlueprintReadWrite, DisplayName = "优先级")
int32 Priority;
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryCapacityChanged);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnInventoryChanged, int32, ItemID);
DECLARE_DYNAMIC_DELEGATE_TwoParams(FVisitInventoryGridDelegate, int32, Index, const FInventoryGrid&, Grid); // 定义蓝图可用的遍历委托
UCLASS()
class BUSYRABBIT_API UInventoryComponent : public ULuaActorComponent {
GENERATED_BODY()
public:
UInventoryComponent();
public: // get
UFUNCTION(BlueprintCallable)
bool IsCanContain(int32 ItemID, int32 Count);
UFUNCTION(BlueprintCallable)
bool IsEnough(int32 ItemID, int32 Count);
UFUNCTION(BlueprintCallable)
FInventoryGrid GetGridWithIndex(int32 Index);
// 遍历所有库存格子
UFUNCTION(BlueprintCallable, Category = "Inventory")
void ForEach(const FVisitInventoryGridDelegate& VisitDelegate);
public: // set
UFUNCTION(BlueprintCallable)
bool DepositItems(int32 ItemID, int32 ItemCnt);
UFUNCTION(BlueprintCallable)
bool WithdrawItems(int32 ItemID, int32 ItemCnt);
UFUNCTION(BlueprintCallable)
bool ConsumeItems(int32 Index, int32 ItemCnt);
UFUNCTION(BlueprintCallable)
void SetInventoryCapacity(int Capacity);
UFUNCTION(BlueprintCallable)
void ReSortAllItem();
public:
UFUNCTION(BlueprintNativeEvent)
void InitItemGrid(FInventoryGrid& Grid);
// 物品变动事件(添加/移除物品时触发)
UPROPERTY(BlueprintAssignable, Category = "Inventory")
FOnInventoryChanged OnInventoryChanged;
// 容量变化事件(设置新容量时触发)
UPROPERTY(BlueprintAssignable, Category = "Inventory")
FOnInventoryCapacityChanged OnInventoryCapacityChanged;
private:
FInventoryGrid& GetOrCreateGrid(int32 ItemID);
protected:
UPROPERTY(BlueprintReadOnly)
int32 Capacity;
protected:
UPROPERTY(BlueprintReadOnly)
TArray<FInventoryGrid> InventoryList;
};

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActorComponent.h"
#include "BusyLuaActorComponent.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyLuaActorComponent : public ULuaActorComponent
{
GENERATED_BODY()
public: // <20><>д<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
virtual void BeginPlay()override;
public: // Lua<75><61>Ҫʵ<D2AA>ֵĺ<D6B5><C4BA><EFBFBD>
UFUNCTION(BlueprintImplementableEvent)
void ReceiveLuaBeginPlay();
};

View File

@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaUserWidget.h"
#include "BusyLuaUserWidget.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyLuaUserWidget : public ULuaUserWidget{
GENERATED_BODY()
};

View File

@ -0,0 +1,39 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaOverriderInterface.h"
#include "Abilities/GameplayAbility.h"
#include "PW_Ability.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_Ability : public UGameplayAbility, public ILuaOverriderInterface{
GENERATED_BODY()
public:
UPW_Ability();
public:
virtual FString GetLuaFilePath_Implementation() const override;
virtual void ApplyCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) const override;
UFUNCTION(BlueprintNativeEvent)
void BP_ApplyCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo)const;
public:
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName = "默认的Effect配置")
TSubclassOf<UGameplayEffect> DefaultEffectConfig;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName = "技能的Effect配置")
TMap<FGameplayTag, TSubclassOf<UGameplayEffect>> EffectConfigs;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName = "技能的Effect配置")
TMap<FName, TSubclassOf<UGameplayEffect>> AbilityEffectConfigs;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
FString LuaFilePath;
};

View File

@ -0,0 +1,20 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "PW_AbilitySystemComponent.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_AbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName = "技能的Effect配置")
TMap<FName, TSubclassOf<UGameplayEffect>> AbilityEffectConfigs;
};

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaUserWidget.h"
#include "Blueprint/IUserObjectListEntry.h"
#include "PW_ListViewEntry.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_ListViewEntry : public ULuaUserWidget, public IUserObjectListEntry{
GENERATED_BODY()
};

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaOverriderInterface.h"
#include "UObject/NoExportTypes.h"
#include "PW_Object.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_Object : public UObject, public ILuaOverriderInterface{
GENERATED_BODY()
public:
UPW_Object();
public:
virtual FString GetLuaFilePath_Implementation() const override;
protected:
FString LuaFilePath;
};

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "slua.h"
#include "CoreMinimal.h"
#include "Engine/TimerHandle.h"
#include "UObject/NoExportTypes.h"
#include "PW_TimerModule.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_TimerModule : public UObject
{
GENERATED_BODY()
public:
//UFUNCTION(BlueprintCallable)
//int SetTimer(slua::LuaVar cb);
protected:
TArray<FTimerHandle> Timers;
};

View File

@ -0,0 +1,55 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaUserWidget.h"
#include "PW_UserWidget.generated.h"
UENUM(BlueprintType)
enum class EWidgetLayoutType: uint8 {
MainLayer,
PopupLayer,
FloatLayer,
TopLayer,
LayerTypeMax
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_SimpleWidget : public ULuaUserWidget
{
GENERATED_BODY()
public:
UPW_SimpleWidget();
virtual bool Initialize() override;
public:
UPROPERTY(BlueprintReadOnly)
bool bVisible;
public:
UFUNCTION(BlueprintCallable)
void SetVisible(bool Visible);
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_UserWidget : public UPW_SimpleWidget
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, DisplayName="是否全局唯一")
bool bSingletonInstance;
public:
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
EWidgetLayoutType LayoutType;
};

View File

@ -0,0 +1,155 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaUserWidget.h"
#include "Blueprint/UserWidget.h"
#include "Core/PW_UserWidget.h"
#include "PW_TableSwitcher.generated.h"
DECLARE_MULTICAST_DELEGATE_OneParam (FTableSwitcherWidgetClicked, class UPW_TableSwitcherWidget*)
DECLARE_MULTICAST_DELEGATE_TwoParams(FTableSwitcherWidgetHoverChange, class UPW_TableSwitcherWidget*, bool)
USTRUCT(BlueprintType)
struct FTableSwitcherInfo {
GENERATED_BODY()
UPROPERTY(EditAnyWhere, DisplayName="是否延迟加载")
bool bIsLazyCreate;
UPROPERTY(EditAnyWhere, DisplayName = "是否复用面板")
bool bIsReusePanel;
UPROPERTY(EditAnyWhere, DisplayName = "复用的切换页的名称", meta = (EditCondition = "bIsReusePanel"))
FName ReusePanelName;
UPROPERTY(EditAnyWhere, DisplayName = "切换页签的类配置")
TSubclassOf <class UPW_TableSwitcherWidget > SwitcherWidget;
UPROPERTY(EditAnyWhere, DisplayName = "切换页签的的显示名称")
FText TableSwitcherName;
UPROPERTY(EditAnyWhere, DisplayName = "切换页的类配置")
TSubclassOf <class UPW_TableSwitcherPage> PageWidget;
};
UCLASS()
class BUSYRABBIT_API UPW_TableSwitcherWidget: public ULuaUserWidget{
GENERATED_BODY()
public:
FName GetSwitcherName() { return SwitcherName; }
public:
void SetHoveredState(bool bIsHover);
void SetSelectedState(bool bIsSelect);
void SetSwitcherTitle(const FText& Text);
void SetSwitcherName(const FName& SwitcherWidgetName) { SwitcherName = SwitcherWidgetName; }
public:
virtual void NativeOnInitialized()override;
virtual void NativeConstruct()override;
virtual void NativeDestruct()override;
protected:
UFUNCTION()
void OnWidgetClicked();
UFUNCTION()
void OnWidgetHovered();
UFUNCTION()
void OnWidgetUnHovered();
protected:
UFUNCTION(BlueprintImplementableEvent)
void OnWidgetStateChange(bool bIsWidgetHovered, bool bIsWidgetSelected);
public:
// 必须绑定的控件
UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
TObjectPtr<class UButton> BtnMain;
UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
TObjectPtr<class UTextBlock> SwitcherTitle;
FTableSwitcherWidgetClicked OnTableWidgetClicked;
FTableSwitcherWidgetHoverChange OnHoverStateChange;
protected:
UPROPERTY(BlueprintReadOnly)
bool bIsHovered;
UPROPERTY(BlueprintReadOnly)
bool bIsSelected;
FName SwitcherName;
};
UCLASS()
class BUSYRABBIT_API UPW_TableSwitcherPage : public UPW_SimpleWidget {
GENERATED_BODY()
public:
UPW_TableSwitcherPage() :bIsShowing(false) {}
public:
void SwitchIn(const FName& SwitcherName);
void SwitchOut(const FName& SwitcherName);
protected:
UFUNCTION(BlueprintImplementableEvent)
void OnSwitchIn(const FName& SwitcherName);
UFUNCTION(BlueprintImplementableEvent)
void OnSwitchOut(const FName& SwitcherName);
protected:
UPROPERTY(BlueprintReadOnly)
bool bIsShowing;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_TableSwitcher : public UUserWidget
{
GENERATED_BODY()
public:
virtual void NativePreConstruct()override;
virtual void NativeOnInitialized()override;
public:
UFUNCTION(BlueprintCallable)
void SetSelectedSwitcher(const FName& SwitcherName);
public:
void RebuildSwitcher(const TMap<FName, FTableSwitcherInfo>& infos);
void RefreshSwitcher();
protected:
UPW_TableSwitcherPage* GetOrCreateSwitcherPage(const FName& SwitcherName);
public:
// 必须绑定的控件
UPROPERTY(BlueprintReadOnly, meta = (BindWidget, DisplayName = "盛放标签的容器"))
TObjectPtr<class UHorizontalBox> SwitcherBar;
UPROPERTY(BlueprintReadOnly, meta = (BindWidget, DisplayName = "盛放页签的容器"))
TObjectPtr<class UOverlay> PanelOverlay;
public:
UPROPERTY(EditAnyWhere, BlueprintReadOnly, DisplayName="控件切换器配置")
TMap<FName, FTableSwitcherInfo> SwicthersInfo;
protected:
UPROPERTY()
TMap<FName, TWeakObjectPtr<UPW_TableSwitcherPage>> SwitcherPages;
UPROPERTY()
TMap<FName, TWeakObjectPtr<UPW_TableSwitcherWidget>> SwitcherWidgets;
};

View File

@ -0,0 +1,61 @@
#pragma once
#include "CoreMinimal.h"
#include "BusyItem.generated.h"
USTRUCT(BlueprintType)
struct FBusyLevelCollectionDropRate {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "掉落数量")
int Count;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "掉落概率")
float Rate;
};
USTRUCT(BlueprintType)
struct FBusyLevelCollectionDropConfig {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "掉落物ID")
FName ItemID;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "掉落物概率")
TArray<FBusyLevelCollectionDropRate> configs;
};
USTRUCT(BlueprintType)
struct FBusyLevelItemConfig : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "道具备注")
FString Comment;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "采集需要花费的饥饿值")
int PickHungerCost;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "采集需要花费的时间,(单位MS)")
int PickTimeCost;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品标签列表")
FGameplayTagContainer TypeTagContainer;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "采集后能带来的效果")
TMap<FGameplayTag, float> GameplayEffects;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "采集后的掉落物配置")
TArray<FBusyLevelCollectionDropConfig> DropConfigs;
};
USTRUCT()
struct FBusyLevelItemDescription : public FTableRowBase { // 物品描述表头
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "道具名称")
FName Name;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "道具描述")
FText Desc;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品UI图标资源")
TSoftObjectPtr<UObject> IconResource;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品关卡内资源")
TSoftObjectPtr<UPaperFlipbook> LevelResource;
};

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "BusyAbilitySystemComponent.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyAbilitySystemComponent : public UAbilitySystemComponent
{
GENERATED_BODY()
};

View File

@ -0,0 +1,65 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "LuaOverriderInterface.h"
#include "BusyAttributeSet.generated.h"
#define MY_ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FPW_OnAttributeChanged, FString, Name, float, OldValue, float, NewValue);
/**
*
*/
UCLASS()
class BUSYRABBIT_API UPW_AttributeSet: public UAttributeSet{
GENERATED_BODY()
public:
virtual bool RegisterCustomAttribute();
virtual void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue)override;
public:
FPW_OnAttributeChanged OnAttributeChanged;
protected:
slua::LuaVar LuaSideData;
};
UCLASS()
class BUSYRABBIT_API UBusyRoleAttributeSet : public UPW_AttributeSet {
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes")
FGameplayAttributeData Health;
MY_ATTRIBUTE_ACCESSORS(UBusyRoleAttributeSet, Health);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes")
FGameplayAttributeData Hunger;
MY_ATTRIBUTE_ACCESSORS(UBusyRoleAttributeSet, Hunger);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes")
FGameplayAttributeData MoveSpeed;
MY_ATTRIBUTE_ACCESSORS(UBusyRoleAttributeSet, MoveSpeed);
};
UCLASS()
class BUSYRABBIT_API UBusyLevelItemAttributeSet : public UPW_AttributeSet {
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Attributes")
FGameplayAttributeData Health;
MY_ATTRIBUTE_ACCESSORS(UBusyRoleAttributeSet, Health);
};

View File

@ -0,0 +1,28 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "LuaOverriderInterface.h"
#include "BusyGameHud.generated.h"
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyGameHud : public AHUD, public ILuaOverriderInterface{
GENERATED_BODY()
virtual FString GetLuaFilePath_Implementation() const override;
public:
//UFUNCTION(BlueprintCallable)
//void PushWidget(const FName& WidgetName);
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
FString LuaFilePath;
UPROPERTY(EditAnywhere, Category = "UI Class Mapping")
TMap<FName, TSubclassOf<UUserWidget>> UIClassMapping;
};

View File

@ -0,0 +1,109 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActor.h"
#include "Engine/Datatable.h"
#include "PaperFlipbookComponent.h"
#include "Gas/BusyAttributeSet.h"
#include "GameplayTagContainer.h"
#include "GameAsset/BusyItem.h"
#include "BusyLevelItem.generated.h"
UENUM(BlueprintType)
enum class EBusyItemEffectType: uint8 {
Health = 0,
Hunger = 1,
Speed = 2,
};
UENUM(BlueprintType)
enum class EBusyLevelItemType : uint8 {
None = 0,
Collection = 1,
Building = 2,
Reward= 3,
};
USTRUCT(BlueprintType)
struct FBusyLevelItemResourceConfig : public FTableRowBase { // 物品资源表
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品图标资源")
TObjectPtr<UTexture2D> IconResource;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品静态资源")
TObjectPtr<UPaperFlipbook> StaticResource;
};
USTRUCT(BlueprintType)
struct FBusyLevelItemGenerateConfig {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "每个周期生成物品的数量")
int CountOfPeriod;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyLevelItem : public ALuaActor
{
GENERATED_BODY()
public:
ABusyLevelItem();
public:
virtual void OnConstruction(const FTransform& Transform) override;
virtual void BeginPlay() override;
protected:
void InitCapsule();
void InitSprite();
void InitPickBar();
void SetItemDisplay(const FName &ItemID);
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UCapsuleComponent> CapsuleComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class USceneComponent> SceneComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UPaperFlipbookComponent> Sprite;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UBusyAbilitySystemComponent> AbilityComponent; // 技能组件
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UWidgetComponent> PickBar;
public:
UPROPERTY(EditAnyWhere, BlueprintReadOnly)
FName CurrentItemID;
public: // 提供给蓝图的接口
UFUNCTION(BlueprintCallable)
void SetLevelItemID(const FName& ItemID);
protected:
UPROPERTY(BlueprintReadOnly)
FBusyLevelItemConfig LevelItemConfig;
UPROPERTY()
TObjectPtr<UBusyLevelItemAttributeSet> LevelItemAttribute;
public: // 需要蓝图实现的函数
// LevelItem被设置时的回调
UFUNCTION(BlueprintImplementableEvent)
void ReceiveLevelItemSetted(const FBusyLevelItemConfig& Config);
};

View File

@ -0,0 +1,57 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActor.h"
#include "Engine/Datatable.h"
#include "GameplayTagContainer.h"
#include "Core/BusyLuaActorComponent.h"
#include "LevelItemReward.generated.h"
USTRUCT(BlueprintType)
struct FLevelItemRewardConfig : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "道具备注")
FString Comment;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "物品标签列表")
FGameplayTagContainer TypeTagContainer;
UPROPERTY(EditAnywhere, BlueprintReadOnly, DisplayName = "使用后能带来的效果")
TMap<FGameplayTag, float> GameplayEffects;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API ALevelItemReward : public ALuaActor
{
GENERATED_BODY()
public:
ALevelItemReward();
public:
virtual void OnConstruction(const FTransform& Transform) override;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UCapsuleComponent> CapsuleComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class USceneComponent> SceneComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UPaperFlipbookComponent> Sprite;
public:
UFUNCTION(BlueprintCallable)
void SetRewardID(const FName& CurrentRewardID);
public:
UPROPERTY(EditAnyWhere, BlueprintReadOnly)
FName RewardID;
};

View File

@ -0,0 +1,148 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "slua.h"
#include "CoreMinimal.h"
#include "LuaPawn.h"
#include "Engine/Datatable.h"
#include "Gas/BusyAttributeSet.h"
#include "AbilitySystemComponent.h"
#include "BusyRole.generated.h"
UENUM(BlueprintType)
enum class EBusyRoleState : uint8{
BonfireIdle, // 篝火旁闲置
Searching, // 外出搜索物品
Picking, // 正在与物品交互
PickFinished, // 与物品交互完毕
BackBonfire, // 返回篝火
};
USTRUCT(BlueprintType)
struct FBusyRoleConfig : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的生命值")
int32 Health;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的饥饿值")
int32 Hunger;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色饥饿值消耗速度")
int HungerConsumeSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色生命值消耗速度")
int HealthConsumeSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的采集效率")
int PickEffect;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的移动速度")
int MoveSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色的技能列表")
TArray<TSubclassOf<UGameplayAbility>> DefaultAbilities;
};
USTRUCT(BlueprintType)
struct FBusyRoleResourceConfig : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "角色头像图标")
int32 Health;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API ABusyRole : public ALuaPawn{
GENERATED_BODY()
public:
ABusyRole();
virtual void BeginPlay()override;
virtual void Tick(float InDeltaSeconds)override;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class USceneComponent> SceneComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class USpringArmComponent> SpringArmComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UCapsuleComponent> CapsuleComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UBusyCameraComponent> CameraComp;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UPaperFlipbookComponent> Sprite;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UBusyRoleMovement> Movement; // 移动组件
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UPW_AbilitySystemComponent> RoleAbility; // 技能组件
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TObjectPtr<class UInventoryComponent> Inventory; // 仓库组件
UPROPERTY(BlueprintReadWrite)
TObjectPtr<class URoleAnimation> RoleAnimation;
public: // 蓝图接口
UFUNCTION(BlueprintCallable)
void SetRole(const FName& Name);
UFUNCTION(BlueprintCallable)
void TryActiveAbility(const FName& TagName, const FGameplayEventData& EventData);
public:
// 输入相关
UPROPERTY(EditDefaultsOnly, Category = "Input")
TObjectPtr<class UInputMappingContext> InputMapping;
UPROPERTY(EditDefaultsOnly, Category = "Input")
TObjectPtr<class UInputAction> TouchAction;
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)override;
protected:
void InitCapsule();
public: // 蓝图实现
UFUNCTION(BlueprintImplementableEvent)
void OnTouch(const FInputActionValue& Value) const;
UFUNCTION(BlueprintImplementableEvent)
void OnOverlapBegin(
UPrimitiveComponent* OverlappedComp,
AActor* OtherActor,
UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex,
bool bFromSweep,
const FHitResult& SweepResult
);
UFUNCTION(BlueprintImplementableEvent)
void ReceiveSetRole(const FBusyRoleConfig& RoleTableConfig);
protected:
FTimerHandle TimerHandle;
public: // 角色属性
UPROPERTY(BlueprintReadOnly)
FName RoleName;
UPROPERTY(BlueprintReadOnly, Category = "Value")
FBusyRoleConfig RoleConfig;
private:
UPROPERTY()
TObjectPtr<UBusyRoleAttributeSet> RoleAttribute;
public: // 不暴露给蓝图的属性
};

View File

@ -0,0 +1,40 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaOverriderInterface.h"
#include "LuaActorComponent.h"
#include "GameFramework/MovementComponent.h"
#include "BusyRoleMovement.generated.h"
UENUM(BlueprintType)
enum class ERoleMoveDirection: uint8 {
Move_Right, // <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
Move_Left, // <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
Move_All_Cnt // ö<><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API UBusyRoleMovement : public ULuaActorComponent
//class BUSYRABBIT_API UBusyRoleMovement : public UObject, public ILuaOverriderInterface
{
GENERATED_BODY()
public:
UBusyRoleMovement();
public:
virtual void BeginPlay()override;
UFUNCTION(BlueprintImplementableEvent)
void ReceiveComponentTick(float DeltaTime);
UFUNCTION(BlueprintImplementableEvent)
void ReceiveComponentBeginPlay();
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)override;
};

View File

@ -0,0 +1,77 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "LuaActorComponent.h"
#include "Engine/Datatable.h"
#include "PaperFlipbookComponent.h"
#include "BusyRoleMovement.h"
#include "../Core/BusyLuaActorComponent.h"
#include "RoleAnimation.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(LogRoleAnimation, Log, All);
UENUM(BlueprintType)
enum class EBusyAnimationPhase : uint8{
PrepareCast, // 动作前摇阶段
Casting, // 动作释放阶段
PostCast, // 动作后摇阶段
};
USTRUCT(BlueprintType)
struct FBusyAnimationPhaseData : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "各个阶段的动作")
TMap<EBusyAnimationPhase, UPaperFlipbook*> PhaseAnimation;
};
USTRUCT(BlueprintType)
struct FBusyRolePickingAnimationData : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "各个方向的采集动作")
TMap<ERoleMoveDirection, FBusyAnimationPhaseData> DirectionAnimations;
};
USTRUCT(BlueprintType)
struct FBusyRoleAnimationData : public FTableRowBase {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "移动时的动作")
TMap<ERoleMoveDirection, UPaperFlipbook*> MoveAnimations;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "静止时的动作")
TMap<ERoleMoveDirection, UPaperFlipbook*> IdleAnimations;
UPROPERTY(EditAnywhere, BlueprintReadWrite, DisplayName = "采集物品时的动作")
TMap<FName, FBusyRolePickingAnimationData> PickingAnimations;
};
/**
*
*/
UCLASS()
class BUSYRABBIT_API URoleAnimation : public UBusyLuaActorComponent
{
GENERATED_BODY()
public:
URoleAnimation();
public:
UFUNCTION(BlueprintCallable)
void SetMoveAnimation(ERoleMoveDirection direction);
UFUNCTION(BlueprintCallable)
void SetIdleAnimation(ERoleMoveDirection direction);
UFUNCTION(BlueprintCallable)
void PlayPickAnimation(const FName& ItemName, ERoleMoveDirection Direction, EBusyAnimationPhase Phase, float PlayRate);
protected:
bool GetOwnerRoleInfo(UPaperFlipbookComponent* &Sprite, FBusyRoleAnimationData* &AnimationData);
// 设置表格里面的动作
void SetRoleAnimation(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim);
void PlayAnimationOnce(UPaperFlipbookComponent* Sprite, UPaperFlipbook** Anim, float PlayRate);
};

View File

@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class BusyRabbitEditorTarget : TargetRules
{
public BusyRabbitEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.Add("BusyRabbit");
}
}