From a87964e1197abfac00bc84074b86c9dd3d7ed128 Mon Sep 17 00:00:00 2001 From: koritsa Date: Mon, 1 Jun 2026 22:04:31 +0300 Subject: [PATCH] Added NPC logic --- Content/Blueprints/Data/Phone_Shimi.uasset | 3 ++ .../Blueprints/Data/StartingSaveData.uasset | 4 +-- Content/Blueprints/GI_NakedDesire.uasset | 4 +-- Content/Blueprints/NPC/ABP_TestNPC.uasset | 3 ++ .../NPC/AI/A_NPCTargetLocation.uasset | 3 ++ Content/Blueprints/NPC/AI/BB_NPC.uasset | 2 +- Content/Blueprints/NPC/AI/BTT_Destroy.uasset | 3 -- .../NPC/AI/BTT_StareAtPlayer.uasset | 3 -- Content/Blueprints/NPC/AI/BT_NPC.uasset | 4 +-- .../Decorators/BTD_ShouldStopToObserve.uasset | 3 ++ Content/Blueprints/NPC/AI/NPC_Stalker.uasset | 3 ++ Content/Blueprints/NPC/AI/NPC_Walker.uasset | 3 ++ .../NPC/AI/Tasks/BTT_PickDestination.uasset | 3 ++ .../AI/Tasks/BTT_ReleaseTargetLocation.uasset | 3 ++ .../Blueprints/NPC/A_NPCTargetLocation.uasset | 3 ++ Content/Blueprints/NPC/BPA_NPCSpawner.uasset | 3 -- .../Blueprints/NPC/BP_NPCController.uasset | 4 +-- .../NPC/BP_NPCTargetLocation.uasset | 3 -- Content/Blueprints/NPC/BP_NPC_Data.uasset | 3 -- Content/Blueprints/NPC/BP_NPC_Stalker.uasset | 3 ++ Content/Blueprints/NPC/BP_NPC_Walker.uasset | 3 ++ Content/Blueprints/NPC/BS_Move.uasset | 3 ++ Content/Blueprints/NPC/DA_NPC_Girl_1.uasset | 3 -- .../Blueprints/NPC/NPCDirectorConfig.uasset | 3 ++ Content/Blueprints/Player/BP_Player.uasset | 4 +-- Content/Test/Maps/TestLevel.umap | 4 +-- Content/Test/Materials/MI_DecalBlue.uasset | 3 ++ .../Test/Materials/MI_Decal_Grid_Blue.uasset | 3 ++ Content/Test/Materials/M_DecalColor.uasset | 3 ++ .../Materials/M_Decal_PrototypeGrid.uasset | 3 ++ PLAN.md | 2 +- Source/NakedDesire/NPC/NPC.cpp | 26 +++++++++++++--- Source/NakedDesire/NPC/NPC.h | 8 ++--- Source/NakedDesire/NPC/NPCAIController.cpp | 5 +++ Source/NakedDesire/NPC/NPCAIController.h | 1 + Source/NakedDesire/NPC/NPCTargetLocation.cpp | 29 +++++++++++++++++ Source/NakedDesire/NPC/NPCTargetLocation.h | 31 +++++++++++++++++++ 37 files changed, 156 insertions(+), 41 deletions(-) create mode 100644 Content/Blueprints/Data/Phone_Shimi.uasset create mode 100644 Content/Blueprints/NPC/ABP_TestNPC.uasset create mode 100644 Content/Blueprints/NPC/AI/A_NPCTargetLocation.uasset delete mode 100644 Content/Blueprints/NPC/AI/BTT_Destroy.uasset delete mode 100644 Content/Blueprints/NPC/AI/BTT_StareAtPlayer.uasset create mode 100644 Content/Blueprints/NPC/AI/Decorators/BTD_ShouldStopToObserve.uasset create mode 100644 Content/Blueprints/NPC/AI/NPC_Stalker.uasset create mode 100644 Content/Blueprints/NPC/AI/NPC_Walker.uasset create mode 100644 Content/Blueprints/NPC/AI/Tasks/BTT_PickDestination.uasset create mode 100644 Content/Blueprints/NPC/AI/Tasks/BTT_ReleaseTargetLocation.uasset create mode 100644 Content/Blueprints/NPC/A_NPCTargetLocation.uasset delete mode 100644 Content/Blueprints/NPC/BPA_NPCSpawner.uasset delete mode 100644 Content/Blueprints/NPC/BP_NPCTargetLocation.uasset delete mode 100644 Content/Blueprints/NPC/BP_NPC_Data.uasset create mode 100644 Content/Blueprints/NPC/BP_NPC_Stalker.uasset create mode 100644 Content/Blueprints/NPC/BP_NPC_Walker.uasset create mode 100644 Content/Blueprints/NPC/BS_Move.uasset delete mode 100644 Content/Blueprints/NPC/DA_NPC_Girl_1.uasset create mode 100644 Content/Blueprints/NPC/NPCDirectorConfig.uasset create mode 100644 Content/Test/Materials/MI_DecalBlue.uasset create mode 100644 Content/Test/Materials/MI_Decal_Grid_Blue.uasset create mode 100644 Content/Test/Materials/M_DecalColor.uasset create mode 100644 Content/Test/Materials/M_Decal_PrototypeGrid.uasset create mode 100644 Source/NakedDesire/NPC/NPCTargetLocation.cpp create mode 100644 Source/NakedDesire/NPC/NPCTargetLocation.h diff --git a/Content/Blueprints/Data/Phone_Shimi.uasset b/Content/Blueprints/Data/Phone_Shimi.uasset new file mode 100644 index 00000000..09728677 --- /dev/null +++ b/Content/Blueprints/Data/Phone_Shimi.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9db8256c5e9ae4fb6a07454c2280127aee554949dee0267ef512f0b4b9f19fcd +size 1561 diff --git a/Content/Blueprints/Data/StartingSaveData.uasset b/Content/Blueprints/Data/StartingSaveData.uasset index fe0bca14..0e6b1c21 100644 --- a/Content/Blueprints/Data/StartingSaveData.uasset +++ b/Content/Blueprints/Data/StartingSaveData.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f06f6e62fefe7bc7b5c96546f130e69e4c6c4caaab7155c3584afe8609f6bd6c -size 1590 +oid sha256:8cf2e670471c2ec17ef3706b658c488798e2647c2ef9b5958f2d659aea373547 +size 2785 diff --git a/Content/Blueprints/GI_NakedDesire.uasset b/Content/Blueprints/GI_NakedDesire.uasset index c71c2426..4bf40b4e 100644 --- a/Content/Blueprints/GI_NakedDesire.uasset +++ b/Content/Blueprints/GI_NakedDesire.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b45399cab4cd893a2c237801bba3ed505d89eafdb22164c633c7a91d8e3a4d35 -size 34867 +oid sha256:4a46f6ee026f0bd35510e70748431a68b4a814d30134226ec6f33d77226bdef2 +size 35284 diff --git a/Content/Blueprints/NPC/ABP_TestNPC.uasset b/Content/Blueprints/NPC/ABP_TestNPC.uasset new file mode 100644 index 00000000..2bd40c59 --- /dev/null +++ b/Content/Blueprints/NPC/ABP_TestNPC.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8fffde6d6bd91880d46790d3819259464d6439cd4cc62fd2ea8934e3da1ea7ec +size 95754 diff --git a/Content/Blueprints/NPC/AI/A_NPCTargetLocation.uasset b/Content/Blueprints/NPC/AI/A_NPCTargetLocation.uasset new file mode 100644 index 00000000..8fd62c73 --- /dev/null +++ b/Content/Blueprints/NPC/AI/A_NPCTargetLocation.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a33fb1b89fa35630632c1de58b8dbee07444fe0148ffb544dae125f76081895f +size 25164 diff --git a/Content/Blueprints/NPC/AI/BB_NPC.uasset b/Content/Blueprints/NPC/AI/BB_NPC.uasset index e18d101b..b42754ec 100644 --- a/Content/Blueprints/NPC/AI/BB_NPC.uasset +++ b/Content/Blueprints/NPC/AI/BB_NPC.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ea9d74aab697c0287b2deb55c4f0f04717a21c904941add9817450db55f1af7c +oid sha256:aeaf4e2a5040be217e9e9946f3f443cac6b8d5427974d762143a9f4fd0532211 size 3399 diff --git a/Content/Blueprints/NPC/AI/BTT_Destroy.uasset b/Content/Blueprints/NPC/AI/BTT_Destroy.uasset deleted file mode 100644 index a51a6d43..00000000 --- a/Content/Blueprints/NPC/AI/BTT_Destroy.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90a9151b744e8936cb204ba23611364a65160f980e6a98c008e57f1eea085426 -size 20178 diff --git a/Content/Blueprints/NPC/AI/BTT_StareAtPlayer.uasset b/Content/Blueprints/NPC/AI/BTT_StareAtPlayer.uasset deleted file mode 100644 index ba9578b0..00000000 --- a/Content/Blueprints/NPC/AI/BTT_StareAtPlayer.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9cf445126d193d6c57aaba525193f59a0ed9f238228cd2e13e5431bedae3ca64 -size 43018 diff --git a/Content/Blueprints/NPC/AI/BT_NPC.uasset b/Content/Blueprints/NPC/AI/BT_NPC.uasset index 0af67678..2bab3d84 100644 --- a/Content/Blueprints/NPC/AI/BT_NPC.uasset +++ b/Content/Blueprints/NPC/AI/BT_NPC.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c7f42c8b57869cddac2ceb44f211770ef3fd397483bc1a471a62f10eef271828 -size 19180 +oid sha256:2dc1c793dbddd708448c8c54a870a15bab0f3f4c86e016dffef3deb44ff06a59 +size 17654 diff --git a/Content/Blueprints/NPC/AI/Decorators/BTD_ShouldStopToObserve.uasset b/Content/Blueprints/NPC/AI/Decorators/BTD_ShouldStopToObserve.uasset new file mode 100644 index 00000000..55fe2cb2 --- /dev/null +++ b/Content/Blueprints/NPC/AI/Decorators/BTD_ShouldStopToObserve.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:707446af63ea231ff7b4508f6722387cff976a4cd8508b409f4f5e51f42301f4 +size 22130 diff --git a/Content/Blueprints/NPC/AI/NPC_Stalker.uasset b/Content/Blueprints/NPC/AI/NPC_Stalker.uasset new file mode 100644 index 00000000..b38154d5 --- /dev/null +++ b/Content/Blueprints/NPC/AI/NPC_Stalker.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ea142ae5327c522201af89677253e2910fe331ff34004e539ea2d69e327497a +size 1588 diff --git a/Content/Blueprints/NPC/AI/NPC_Walker.uasset b/Content/Blueprints/NPC/AI/NPC_Walker.uasset new file mode 100644 index 00000000..02426120 --- /dev/null +++ b/Content/Blueprints/NPC/AI/NPC_Walker.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:473f8d5189e6dcc09496c477b5f5f3d6e9d3ae1a1945f4475d236443a1722fd2 +size 1345 diff --git a/Content/Blueprints/NPC/AI/Tasks/BTT_PickDestination.uasset b/Content/Blueprints/NPC/AI/Tasks/BTT_PickDestination.uasset new file mode 100644 index 00000000..13cee26d --- /dev/null +++ b/Content/Blueprints/NPC/AI/Tasks/BTT_PickDestination.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b871dec1e14a6fbbf521582bbf05040f1cc85e678b9deec720ff25220db136c +size 98846 diff --git a/Content/Blueprints/NPC/AI/Tasks/BTT_ReleaseTargetLocation.uasset b/Content/Blueprints/NPC/AI/Tasks/BTT_ReleaseTargetLocation.uasset new file mode 100644 index 00000000..ecdcc82d --- /dev/null +++ b/Content/Blueprints/NPC/AI/Tasks/BTT_ReleaseTargetLocation.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85293686dbd23dc3b3490cab6fbab885e16653a2164f5da33d6beadcf061a5b1 +size 30141 diff --git a/Content/Blueprints/NPC/A_NPCTargetLocation.uasset b/Content/Blueprints/NPC/A_NPCTargetLocation.uasset new file mode 100644 index 00000000..780ff148 --- /dev/null +++ b/Content/Blueprints/NPC/A_NPCTargetLocation.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5302566ec008a6b0813ad59707dc77b1d140a3de702e40c35e5052249276a19a +size 2414 diff --git a/Content/Blueprints/NPC/BPA_NPCSpawner.uasset b/Content/Blueprints/NPC/BPA_NPCSpawner.uasset deleted file mode 100644 index 78980b13..00000000 --- a/Content/Blueprints/NPC/BPA_NPCSpawner.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:93e08707749168a53d46e8013c5b0e2de2378c4161d04266de67d82a905d9aec -size 24514 diff --git a/Content/Blueprints/NPC/BP_NPCController.uasset b/Content/Blueprints/NPC/BP_NPCController.uasset index 56edd0b6..13ff847d 100644 --- a/Content/Blueprints/NPC/BP_NPCController.uasset +++ b/Content/Blueprints/NPC/BP_NPCController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ecad4de77688b22b267a826f54624d5780e96c0b7e0b16080245c0f845c5eaf -size 20886 +oid sha256:8a8eb23860a4116089d056d989e6b0683c91c66fae34750a0f00ad1ce783c658 +size 15554 diff --git a/Content/Blueprints/NPC/BP_NPCTargetLocation.uasset b/Content/Blueprints/NPC/BP_NPCTargetLocation.uasset deleted file mode 100644 index 98220095..00000000 --- a/Content/Blueprints/NPC/BP_NPCTargetLocation.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:30381ec5182108758e31e6b7c7d00a64dae04b27ee9ff54882ecaac15c73abb4 -size 24706 diff --git a/Content/Blueprints/NPC/BP_NPC_Data.uasset b/Content/Blueprints/NPC/BP_NPC_Data.uasset deleted file mode 100644 index 9dadfc06..00000000 --- a/Content/Blueprints/NPC/BP_NPC_Data.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:28a2d91919c5fa3ab4b21473beabcc05ecd2313445062d2b99d7b8cfd5972bbf -size 22675 diff --git a/Content/Blueprints/NPC/BP_NPC_Stalker.uasset b/Content/Blueprints/NPC/BP_NPC_Stalker.uasset new file mode 100644 index 00000000..463d72b3 --- /dev/null +++ b/Content/Blueprints/NPC/BP_NPC_Stalker.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f1e8a34dd7636ad695915d0f72a608847a8de9b5cd855b0a11f63f21d7d0833 +size 26861 diff --git a/Content/Blueprints/NPC/BP_NPC_Walker.uasset b/Content/Blueprints/NPC/BP_NPC_Walker.uasset new file mode 100644 index 00000000..f21603a8 --- /dev/null +++ b/Content/Blueprints/NPC/BP_NPC_Walker.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d7e5356e8fed0e602c4504da73fbecd70d1796648a439563d8c569d59f896c2 +size 27249 diff --git a/Content/Blueprints/NPC/BS_Move.uasset b/Content/Blueprints/NPC/BS_Move.uasset new file mode 100644 index 00000000..cdc468f1 --- /dev/null +++ b/Content/Blueprints/NPC/BS_Move.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1111b5979ce89ef6979ebd4ce9d61a9090c367ac0161c0bb7fe4f328e020411 +size 8314 diff --git a/Content/Blueprints/NPC/DA_NPC_Girl_1.uasset b/Content/Blueprints/NPC/DA_NPC_Girl_1.uasset deleted file mode 100644 index 9a65df6b..00000000 --- a/Content/Blueprints/NPC/DA_NPC_Girl_1.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b0d31959abcd1c1dfc78dcc1f1d5923a487c92d8362002f7b6e3f109f8377633 -size 6938 diff --git a/Content/Blueprints/NPC/NPCDirectorConfig.uasset b/Content/Blueprints/NPC/NPCDirectorConfig.uasset new file mode 100644 index 00000000..354bc8f6 --- /dev/null +++ b/Content/Blueprints/NPC/NPCDirectorConfig.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5426c6ffa5bed281697e10e0e76c4d914f2338f13f5a47af3ecf3bf8c5ec5455 +size 2041 diff --git a/Content/Blueprints/Player/BP_Player.uasset b/Content/Blueprints/Player/BP_Player.uasset index 95b1f55e..20de698e 100644 --- a/Content/Blueprints/Player/BP_Player.uasset +++ b/Content/Blueprints/Player/BP_Player.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0303659a667d62f2f298a9bda9d7aeadc29e38d805f513336cfd0d0d5d9d44b -size 72288 +oid sha256:e933f3784a16d6dc4889a4114aa73acac750b7da5d4a651ddb80cfd313a08f2d +size 71937 diff --git a/Content/Test/Maps/TestLevel.umap b/Content/Test/Maps/TestLevel.umap index 48cbf08c..6b04377f 100644 --- a/Content/Test/Maps/TestLevel.umap +++ b/Content/Test/Maps/TestLevel.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f8b7f453570c2d869f6da438384698746dce88eb1ea10025ddcac1b336d39a8 -size 148528 +oid sha256:e00e09b2ed68d643785e15577bbfaf128a35ee9d2fb274c6f03fda51e3b4cf54 +size 217653 diff --git a/Content/Test/Materials/MI_DecalBlue.uasset b/Content/Test/Materials/MI_DecalBlue.uasset new file mode 100644 index 00000000..041ce644 --- /dev/null +++ b/Content/Test/Materials/MI_DecalBlue.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ba1d88325debbc449780b311a9039dfe7bc5fdeb566b20689e2187fe86468e49 +size 8779 diff --git a/Content/Test/Materials/MI_Decal_Grid_Blue.uasset b/Content/Test/Materials/MI_Decal_Grid_Blue.uasset new file mode 100644 index 00000000..51788573 --- /dev/null +++ b/Content/Test/Materials/MI_Decal_Grid_Blue.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c079d46284a4b0610697e98b6df60f0f48715cb2ba464f913b9a0b111017d22 +size 12227 diff --git a/Content/Test/Materials/M_DecalColor.uasset b/Content/Test/Materials/M_DecalColor.uasset new file mode 100644 index 00000000..53ec7d1f --- /dev/null +++ b/Content/Test/Materials/M_DecalColor.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40aac0badb8aa26a0d335f5aaa917b5006557bcf7b87bf36c851a98c137cef65 +size 16069 diff --git a/Content/Test/Materials/M_Decal_PrototypeGrid.uasset b/Content/Test/Materials/M_Decal_PrototypeGrid.uasset new file mode 100644 index 00000000..666437b1 --- /dev/null +++ b/Content/Test/Materials/M_Decal_PrototypeGrid.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49cbc9194beeffd60b2e0ba8c00fdebac6814c5b00564abd2f53d8dea76056fb +size 45822 diff --git a/PLAN.md b/PLAN.md index bb4357ad..37ef9e21 100644 --- a/PLAN.md +++ b/PLAN.md @@ -1,4 +1,4 @@ -# Development Plan + # Development Plan Working document for Naked Desire implementation. Tracks current state vs. the GDD (README.md) and the phased roadmap. Update this file as state changes — code is the source of truth, this file is the navigation chart. diff --git a/Source/NakedDesire/NPC/NPC.cpp b/Source/NakedDesire/NPC/NPC.cpp index 437a7c9c..6c26e805 100644 --- a/Source/NakedDesire/NPC/NPC.cpp +++ b/Source/NakedDesire/NPC/NPC.cpp @@ -2,8 +2,12 @@ #include "NPC.h" + +#include "BrainComponent.h" #include "NPCTypeDefinition.h" #include "NPCAIController.h" +#include "NPCTargetLocation.h" +#include "BehaviorTree/BlackboardComponent.h" #include "Components/SkeletalMeshComponent.h" #include "GameFramework/CharacterMovementComponent.h" @@ -58,15 +62,26 @@ void ANPC::ActivateFromPool(const FVector& Location, const FRotator& Rotation) Move->SetComponentTickEnabled(true); Move->SetMovementMode(MOVE_Walking); } - - OnActivatedFromPool(); + + if (ANPCAIController* NPCController = Cast(GetController())) + { + NPCController->RunCustomBehaviorTree(); + NPCController->GetBlackboardComponent()->SetValueAsBool(TEXT("bHasReacted"), false); + } } void ANPC::DeactivateToPool() { // Drop any active observation so a pooled-out NPC stops contributing to the player's embarrassment. if (ANPCAIController* NPCController = Cast(GetController())) + { NPCController->ClearObservation(); + if (UBrainComponent* Brain = NPCController->GetBrainComponent()) + { + Brain->StopLogic(TEXT("Moved to pool")); + } + NPCController->ClearFocus(EAIFocusPriority::Default); + } if (UCharacterMovementComponent* Move = GetCharacterMovement()) { @@ -74,9 +89,12 @@ void ANPC::DeactivateToPool() Move->DisableMovement(); Move->SetComponentTickEnabled(false); } + + if (TargetLocationActor) + { + TargetLocationActor->Release(this); + } SetActorHiddenInGame(true); SetActorEnableCollision(false); - - OnDeactivatedToPool(); } \ No newline at end of file diff --git a/Source/NakedDesire/NPC/NPC.h b/Source/NakedDesire/NPC/NPC.h index 625eb1cd..ad449c7c 100644 --- a/Source/NakedDesire/NPC/NPC.h +++ b/Source/NakedDesire/NPC/NPC.h @@ -7,6 +7,7 @@ #include "NPCType.h" #include "NPC.generated.h" +class ANPCTargetLocation; class UNPCTypeDefinition; UCLASS() @@ -44,9 +45,6 @@ public: void DeactivateToPool(); protected: - UFUNCTION(BlueprintImplementableEvent, Category = "NPC") - void OnActivatedFromPool(); - - UFUNCTION(BlueprintImplementableEvent, Category = "NPC") - void OnDeactivatedToPool(); + UPROPERTY(BlueprintReadWrite, Category = "NPC") + TObjectPtr TargetLocationActor; }; \ No newline at end of file diff --git a/Source/NakedDesire/NPC/NPCAIController.cpp b/Source/NakedDesire/NPC/NPCAIController.cpp index 8dd71684..8e54c7d2 100644 --- a/Source/NakedDesire/NPC/NPCAIController.cpp +++ b/Source/NakedDesire/NPC/NPCAIController.cpp @@ -45,6 +45,11 @@ void ANPCAIController::ClearObservation() } } +void ANPCAIController::RunCustomBehaviorTree() +{ + RunBehaviorTree(BehaviorTreeAsset); +} + float ANPCAIController::GetObservationWeight() const { if (const ANPC* NPC = Cast(GetPawn())) diff --git a/Source/NakedDesire/NPC/NPCAIController.h b/Source/NakedDesire/NPC/NPCAIController.h index 3229045e..2157f6bf 100644 --- a/Source/NakedDesire/NPC/NPCAIController.h +++ b/Source/NakedDesire/NPC/NPCAIController.h @@ -27,6 +27,7 @@ public: // Clears any active observation of the player (used on un-possess and when the NPC is pooled out). void ClearObservation(); + void RunCustomBehaviorTree(); protected: UFUNCTION() diff --git a/Source/NakedDesire/NPC/NPCTargetLocation.cpp b/Source/NakedDesire/NPC/NPCTargetLocation.cpp new file mode 100644 index 00000000..1220731d --- /dev/null +++ b/Source/NakedDesire/NPC/NPCTargetLocation.cpp @@ -0,0 +1,29 @@ +// © 2025 Naked People Team. All Rights Reserved. + + +#include "NPCTargetLocation.h" +#include "NPC.h" + + +ANPCTargetLocation::ANPCTargetLocation() +{ + PrimaryActorTick.bCanEverTick = false; +} + +bool ANPCTargetLocation::TryClaim(ANPC* InClaimant) +{ + if (Claimant.IsValid() && Claimant.Get() != InClaimant) + return false; + + Claimant = InClaimant; + return true; +} + +void ANPCTargetLocation::Release(ANPC* Requester) +{ + if (!Claimant.IsValid() || Claimant.Get() != Requester) + return; + + Claimant = nullptr; +} + diff --git a/Source/NakedDesire/NPC/NPCTargetLocation.h b/Source/NakedDesire/NPC/NPCTargetLocation.h new file mode 100644 index 00000000..952023d1 --- /dev/null +++ b/Source/NakedDesire/NPC/NPCTargetLocation.h @@ -0,0 +1,31 @@ +// © 2025 Naked People Team. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "NPCTargetLocation.generated.h" + +class ANPC; + +UCLASS() +class NAKEDDESIRE_API ANPCTargetLocation : public AActor +{ + GENERATED_BODY() + +public: + ANPCTargetLocation(); + + UFUNCTION(BlueprintCallable) + bool TryClaim(ANPC* InClaimant); + + UFUNCTION(BlueprintPure) + bool IsClaimed() const { return Claimant.IsValid(); } + + UFUNCTION(BlueprintCallable) + void Release(ANPC* Requester); + +private: + UPROPERTY() + TWeakObjectPtr Claimant = nullptr; +};