Update Dialogue for Adding Items to Inventory
This commit is contained in:
parent
aa23ea1223
commit
8c550dfbe9
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube1.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube1.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/Dialogue/UI/BP_DialogueUI.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Dialogue/UI/BP_DialogueUI.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_MainCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_MainCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/Inventory/Items/Favour/InvItem_ApartmentPartyInvitation.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Inventory/Items/Favour/InvItem_ApartmentPartyInvitation.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/D/7L/KUWJ50Q9H612B3SWHC7ZMP.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/D/7L/KUWJ50Q9H612B3SWHC7ZMP.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/E/3W/EFD3Z49R81R9HF96BWZZKX.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/__ExternalActors__/Levels/MovementTest/E/3W/EFD3Z49R81R9HF96BWZZKX.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -3,6 +3,7 @@
|
||||
|
||||
#include "AC_PlayerDialogueInterpreter.h"
|
||||
|
||||
#include "DialogueAddItemNode.h"
|
||||
#include "EndlessVendetta/EndlessVendettaCharacter.h"
|
||||
|
||||
|
||||
@ -68,25 +69,68 @@ void UAC_PlayerDialogueInterpreter::StartDialogue(UDialogueTree* DialogueTree)
|
||||
|
||||
void UAC_PlayerDialogueInterpreter::NextDialogue()
|
||||
{
|
||||
if (!IsValid(CurrentTextNode)) return;
|
||||
if (IsValid(CurrentChoiceNode)) return;
|
||||
if (CurrentTextNode->ChildrenNodes.Num() == 0)
|
||||
if (IsValid(CurrentTextNode))
|
||||
{
|
||||
EndDialogue();
|
||||
return;
|
||||
if (CurrentTextNode->ChildrenNodes.Num() == 0)
|
||||
{
|
||||
EndDialogue();
|
||||
return;
|
||||
}
|
||||
if (Cast<UDialogueChoiceNode>(CurrentTextNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentChoiceNode = Cast<UDialogueChoiceNode>(CurrentTextNode->ChildrenNodes[0]);
|
||||
OnChoiceDialogue.Broadcast(CurrentChoiceNode);
|
||||
CurrentTextNode = nullptr;
|
||||
CurrentAddItemNode = nullptr;
|
||||
}
|
||||
else if (Cast<UDialogueTextNode>(CurrentTextNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentTextNode = Cast<UDialogueTextNode>(CurrentTextNode->ChildrenNodes[0]);
|
||||
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
|
||||
OnNextDialogue.Broadcast(CurrentTextNode);
|
||||
CurrentChoiceNode = nullptr;
|
||||
CurrentAddItemNode = nullptr;
|
||||
}
|
||||
else if (Cast<UDialogueAddItemNode>(CurrentTextNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentAddItemNode = Cast<UDialogueAddItemNode>(CurrentTextNode->ChildrenNodes[0]);
|
||||
CurrentAddItemNode->AddItemsToInventory(GetWorld());
|
||||
CurrentTextNode = nullptr;
|
||||
CurrentChoiceNode = nullptr;
|
||||
NextDialogue();
|
||||
}
|
||||
}
|
||||
if (Cast<UDialogueChoiceNode>(CurrentTextNode->ChildrenNodes[0]))
|
||||
else if (IsValid(CurrentAddItemNode))
|
||||
{
|
||||
CurrentChoiceNode = Cast<UDialogueChoiceNode>(CurrentTextNode->ChildrenNodes[0]);
|
||||
OnChoiceDialogue.Broadcast(CurrentChoiceNode);
|
||||
CurrentTextNode = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentTextNode = Cast<UDialogueTextNode>(CurrentTextNode->ChildrenNodes[0]);
|
||||
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
|
||||
OnNextDialogue.Broadcast(CurrentTextNode);
|
||||
CurrentChoiceNode = nullptr;
|
||||
if (CurrentAddItemNode->ChildrenNodes.Num() == 0)
|
||||
{
|
||||
EndDialogue();
|
||||
return;
|
||||
}
|
||||
if (Cast<UDialogueChoiceNode>(CurrentAddItemNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentChoiceNode = Cast<UDialogueChoiceNode>(CurrentAddItemNode->ChildrenNodes[0]);
|
||||
OnChoiceDialogue.Broadcast(CurrentChoiceNode);
|
||||
CurrentTextNode = nullptr;
|
||||
CurrentAddItemNode = nullptr;
|
||||
}
|
||||
else if (Cast<UDialogueTextNode>(CurrentAddItemNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentTextNode = Cast<UDialogueTextNode>(CurrentAddItemNode->ChildrenNodes[0]);
|
||||
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
|
||||
OnNextDialogue.Broadcast(CurrentTextNode);
|
||||
CurrentChoiceNode = nullptr;
|
||||
CurrentAddItemNode = nullptr;
|
||||
}
|
||||
else if (Cast<UDialogueAddItemNode>(CurrentAddItemNode->ChildrenNodes[0]))
|
||||
{
|
||||
CurrentAddItemNode = Cast<UDialogueAddItemNode>(CurrentAddItemNode->ChildrenNodes[0]);
|
||||
CurrentAddItemNode->AddItemsToInventory(GetWorld());
|
||||
CurrentTextNode = nullptr;
|
||||
CurrentChoiceNode = nullptr;
|
||||
NextDialogue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,20 +143,27 @@ void UAC_PlayerDialogueInterpreter::MakeChoiceDialogue(const int Choice)
|
||||
OnChoiceDialogue.Broadcast(CurrentChoiceNode);
|
||||
CurrentTextNode = nullptr;
|
||||
}
|
||||
else
|
||||
else if (Cast<UDialogueTextNode>(CurrentChoiceNode->ChildrenNodes[Choice]))
|
||||
{
|
||||
CurrentTextNode = Cast<UDialogueTextNode>(CurrentChoiceNode->ChildrenNodes[Choice]);
|
||||
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
|
||||
OnNextDialogue.Broadcast(CurrentTextNode);
|
||||
CurrentChoiceNode = nullptr;
|
||||
}
|
||||
else if (Cast<UDialogueAddItemNode>(CurrentChoiceNode->ChildrenNodes[Choice]))
|
||||
{
|
||||
CurrentAddItemNode = Cast<UDialogueAddItemNode>(CurrentChoiceNode->ChildrenNodes[Choice]);
|
||||
CurrentAddItemNode->AddItemsToInventory(GetWorld());
|
||||
CurrentChoiceNode = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void UAC_PlayerDialogueInterpreter::EndDialogue()
|
||||
{
|
||||
OnEndDialogue.Broadcast(CurrentTextNode->Text);
|
||||
OnEndDialogue.Broadcast(FText::FromString("Dialogue Ended"));
|
||||
CurrentChoiceNode = nullptr;
|
||||
CurrentTextNode = nullptr;
|
||||
CurrentAddItemNode = nullptr;
|
||||
CurrentCharacterSpeaking = FDialogueCharacter();
|
||||
|
||||
if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController())
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "DialogueAddItemNode.h"
|
||||
#include "DialogueChoiceNode.h"
|
||||
#include "DialogueTextNode.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
@ -49,6 +50,8 @@ private:
|
||||
UDialogueTextNode* CurrentTextNode;
|
||||
UPROPERTY()
|
||||
UDialogueChoiceNode* CurrentChoiceNode;
|
||||
UPROPERTY()
|
||||
UDialogueAddItemNode* CurrentAddItemNode;
|
||||
FDialogueCharacter* GetCharacterSpeakingFromEnum(ECharacterSpeaking CharacterSpeakingEnum) const;
|
||||
|
||||
public:
|
||||
@ -63,4 +66,7 @@ public:
|
||||
void MakeChoiceDialogue(int Choice);
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue")
|
||||
void EndDialogue();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue")
|
||||
UWorld* GetWorldContext() const { return GetWorld(); }
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "DialogueAddItemNode.h"
|
||||
#include "DialogueTree.h"
|
||||
#include "EndlessVendetta/Inventory/InventoryComponent.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "UDialogueTextNode"
|
||||
|
||||
@ -12,16 +13,25 @@ UDialogueAddItemNode::UDialogueAddItemNode()
|
||||
#endif
|
||||
}
|
||||
|
||||
void UDialogueAddItemNode::AddItemsToInventory(UWorld* World)
|
||||
{
|
||||
UInventoryComponent* InventoryComponent = Cast<UInventoryComponent>(World->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UInventoryComponent::StaticClass()));
|
||||
if (InventoryComponent == nullptr) return;
|
||||
for (TSubclassOf<UBaseItem> ItemToAdd : ItemsToAdd)
|
||||
{
|
||||
InventoryComponent->AddItem(NewObject<UBaseItem>(World, ItemToAdd));
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
FText UDialogueAddItemNode::GetNodeTitle() const
|
||||
{
|
||||
return Bruh;
|
||||
return FText::FromString("Add Item Node");
|
||||
}
|
||||
|
||||
void UDialogueAddItemNode::SetNodeTitle(const FText& NewTitle)
|
||||
{
|
||||
Bruh = NewTitle;
|
||||
}
|
||||
|
||||
FLinearColor UDialogueAddItemNode::GetBackgroundColor() const
|
||||
@ -31,7 +41,7 @@ FLinearColor UDialogueAddItemNode::GetBackgroundColor() const
|
||||
if (DialogueTree == nullptr)
|
||||
return Super::GetBackgroundColor();
|
||||
|
||||
return FLinearColor::Black;
|
||||
return FLinearColor::Transparent;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2,17 +2,22 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GenericGraphNode.h"
|
||||
#include "EndlessVendetta/Inventory/BaseItem.h"
|
||||
#include "DialogueAddItemNode.generated.h"
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class UDialogueAddItemNode : public UGenericGraphNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UDialogueAddItemNode();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||
FText Bruh;
|
||||
TArray<TSubclassOf<UBaseItem>> ItemsToAdd;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue")
|
||||
void AddItemsToInventory(UWorld* World);
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual FText GetNodeTitle() const override;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "EndlessVendetta/Characters/BountyHunterCharacter.h"
|
||||
#include "EndlessVendetta/Inventory/InventoryComponent.h"
|
||||
|
||||
|
||||
#define LOCTEXT_NAMESPACE "UDialogueChoiceNode"
|
||||
|
||||
UDialogueChoiceNode::UDialogueChoiceNode()
|
||||
@ -18,16 +19,14 @@ UDialogueChoiceNode::UDialogueChoiceNode()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
bool UDialogueChoiceNode::ChoiceRequirementsMet(const int ChoiceID) const
|
||||
bool UDialogueChoiceNode::ChoiceRequirementsMet(const int ChoiceID, UWorld* World) const
|
||||
{
|
||||
if (ChoiceID < 0 || ChoiceID >= Choices.Num()) return false;
|
||||
if (ChildrenNodes.Num() == 0) return false;
|
||||
if (!Cast<UDialogueTextNode>(ChildrenNodes[ChoiceID])) return false;
|
||||
const UEVGameInstance* GameInstance = Cast<UEVGameInstance>(GetWorld()->GetGameInstance());
|
||||
const UInventoryComponent* InventoryComponent = Cast<UInventoryComponent>(GetWorld()->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UInventoryComponent::StaticClass()));
|
||||
const ABountyHunterCharacter* PlayerCharacter = Cast<ABountyHunterCharacter>(GetWorld()->GetFirstPlayerController()->GetPawn());
|
||||
const UEVGameInstance* GameInstance = Cast<UEVGameInstance>(World->GetGameInstance());
|
||||
const UInventoryComponent* InventoryComponent = Cast<UInventoryComponent>(World->GetFirstPlayerController()->GetPawn()->GetComponentByClass(UInventoryComponent::StaticClass()));
|
||||
const ABountyHunterCharacter* PlayerCharacter = Cast<ABountyHunterCharacter>(World->GetFirstPlayerController()->GetPawn());
|
||||
UDialogueTextNode* TextNode = Cast<UDialogueTextNode>(ChildrenNodes[ChoiceID]);
|
||||
for (const EDialogueFlag Flag : TextNode->RequiredFlags)
|
||||
{
|
||||
@ -42,6 +41,18 @@ bool UDialogueChoiceNode::ChoiceRequirementsMet(const int ChoiceID) const
|
||||
if (!InventoryComponent->HasItemByItemID(ItemID)) return false;
|
||||
}
|
||||
if (TextNode->RequiredFavours > PlayerCharacter->Favours) return false;
|
||||
for (const EDialogueFlag Flag : TextNode->LacksFlags)
|
||||
{
|
||||
if (GameInstance->HasDialogueFlag(Flag)) return false;
|
||||
}
|
||||
for (const EItem Item : TextNode->LacksItemsByEnumID)
|
||||
{
|
||||
if (!InventoryComponent->LacksItemByEnumID(Item)) return false;
|
||||
}
|
||||
for (const int ItemID : TextNode->LacksItemsByID)
|
||||
{
|
||||
if (!InventoryComponent->LacksItemByItemID(ItemID)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,6 +65,9 @@ FString UDialogueChoiceNode::GetChoicePreText(const int ChoiceID) const
|
||||
return TextNode->RequirementPreText.ToString();
|
||||
}
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
FText UDialogueChoiceNode::GetNodeTitle() const
|
||||
{
|
||||
bool bHasValidNumberOfChoices = false;
|
||||
|
@ -15,8 +15,8 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||
TArray<FString> Choices;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue")
|
||||
bool ChoiceRequirementsMet(int ChoiceID) const;
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue", meta = (WorldContext="WorldContextObject"))
|
||||
bool ChoiceRequirementsMet(int ChoiceID, UWorld* World) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Dialogue")
|
||||
FString GetChoicePreText(int ChoiceID) const;
|
||||
|
@ -13,6 +13,4 @@ UENUM(BlueprintType)
|
||||
enum class EDialogueFlag : uint8
|
||||
{
|
||||
None UMETA(DisplayName = "None"),
|
||||
TestFlag1 UMETA(DisplayName = "Test Flag DO NOT USE"),
|
||||
TestFlag2 UMETA(DisplayName = "Test Flag DO NOT USE"),
|
||||
};
|
||||
|
@ -38,6 +38,13 @@ public:
|
||||
TArray<int> RequiredItemsByID;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Choice Requirement")
|
||||
int RequiredFavours = 0;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Choice Requirement")
|
||||
TArray<EDialogueFlag> LacksFlags;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Choice Requirement")
|
||||
TArray<EItem> LacksItemsByEnumID;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Choice Requirement")
|
||||
TArray<int> LacksItemsByID;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Choice Requirement")
|
||||
FText RequirementPreText = FText::FromString("None");
|
||||
|
||||
|
@ -9,7 +9,7 @@ UDialogueTree::UDialogueTree()
|
||||
NodeType = UGenericGraphNode::StaticClass();
|
||||
EdgeType = UDialogueEdge::StaticClass();
|
||||
|
||||
// bCanBeCyclical = true;
|
||||
bCanBeCyclical = true;
|
||||
|
||||
Character1.CharacterName = "Character 1";
|
||||
Character2.CharacterName = "Character 2";
|
||||
|
@ -201,6 +201,16 @@ bool UInventoryComponent::HasItemByItemID(int ItemID) const
|
||||
return GameInstance->InventoryItems.ContainsByPredicate([ItemID](const UBaseItem* Item) { return IsValid(Item) && Item->ItemID == ItemID; });
|
||||
}
|
||||
|
||||
bool UInventoryComponent::LacksItemByEnumID(EItem ItemEnumID) const
|
||||
{
|
||||
return !HasItemByEnumID(ItemEnumID);
|
||||
}
|
||||
|
||||
bool UInventoryComponent::LacksItemByItemID(int ItemID) const
|
||||
{
|
||||
return !HasItemByItemID(ItemID);
|
||||
}
|
||||
|
||||
void UInventoryComponent::SetPrimaryWeapon(AActor* const _PrimaryWeapon)
|
||||
{
|
||||
PrimaryWeapon = _PrimaryWeapon;
|
||||
|
@ -72,6 +72,10 @@ public:
|
||||
bool HasItemByEnumID(EItem ItemEnumID) const;
|
||||
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
||||
bool HasItemByItemID(int ItemID) const;
|
||||
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
||||
bool LacksItemByEnumID(EItem ItemEnumID) const;
|
||||
UFUNCTION(BlueprintCallable, Category = "Inventory")
|
||||
bool LacksItemByItemID(int ItemID) const;
|
||||
|
||||
void SetPrimaryWeapon(AActor* const _PrimaryWeapon);
|
||||
AActor* GetPrimaryWeapon() const;
|
||||
|
Loading…
Reference in New Issue
Block a user