diff --git a/.idea/.idea.InventorySystem/.idea/workspace.xml b/.idea/.idea.InventorySystem/.idea/workspace.xml
index ff320e2..42bfff6 100644
--- a/.idea/.idea.InventorySystem/.idea/workspace.xml
+++ b/.idea/.idea.InventorySystem/.idea/workspace.xml
@@ -11,20 +11,16 @@
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
@@ -36,8 +32,6 @@
-
-
@@ -323,6 +317,13 @@
+
+
+
+
+
+
+
@@ -338,6 +339,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Content/Assets/Characters/Mannequins/Animations/ABP_Manny.uasset b/Content/Assets/Characters/Mannequins/Animations/ABP_Manny.uasset
index e8ee280..3510b06 100644
Binary files a/Content/Assets/Characters/Mannequins/Animations/ABP_Manny.uasset and b/Content/Assets/Characters/Mannequins/Animations/ABP_Manny.uasset differ
diff --git a/Content/Assets/Characters/Mannequins/Meshes/SK_Mannequin.uasset b/Content/Assets/Characters/Mannequins/Meshes/SK_Mannequin.uasset
index eaf22ce..2dd2469 100644
Binary files a/Content/Assets/Characters/Mannequins/Meshes/SK_Mannequin.uasset and b/Content/Assets/Characters/Mannequins/Meshes/SK_Mannequin.uasset differ
diff --git a/Content/InventorySystem/Blueprints/BP_Sword.uasset b/Content/InventorySystem/Blueprints/BP_Sword.uasset
new file mode 100644
index 0000000..d6fca0f
Binary files /dev/null and b/Content/InventorySystem/Blueprints/BP_Sword.uasset differ
diff --git a/Content/InventorySystem/Blueprints/BP_Tablet.uasset b/Content/InventorySystem/Blueprints/BP_Tablet.uasset
index 6d5e8a0..e4f7102 100644
Binary files a/Content/InventorySystem/Blueprints/BP_Tablet.uasset and b/Content/InventorySystem/Blueprints/BP_Tablet.uasset differ
diff --git a/Content/InventorySystem/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset b/Content/InventorySystem/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset
index 2a43255..b995557 100644
Binary files a/Content/InventorySystem/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset and b/Content/InventorySystem/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset differ
diff --git a/Content/InventorySystem/ThirdPerson/Maps/LVL_MainMap.umap b/Content/InventorySystem/ThirdPerson/Maps/LVL_MainMap.umap
index 939a500..60c5073 100644
Binary files a/Content/InventorySystem/ThirdPerson/Maps/LVL_MainMap.umap and b/Content/InventorySystem/ThirdPerson/Maps/LVL_MainMap.umap differ
diff --git a/Content/InventorySystem/UI/WBP_CharacterDisplayWidget.uasset b/Content/InventorySystem/UI/WBP_CharacterDisplayWidget.uasset
new file mode 100644
index 0000000..9574ed3
Binary files /dev/null and b/Content/InventorySystem/UI/WBP_CharacterDisplayWidget.uasset differ
diff --git a/Content/InventorySystem/UI/WBP_InventoryWidget.uasset b/Content/InventorySystem/UI/WBP_InventoryWidget.uasset
index 9bab16b..74b664d 100644
Binary files a/Content/InventorySystem/UI/WBP_InventoryWidget.uasset and b/Content/InventorySystem/UI/WBP_InventoryWidget.uasset differ
diff --git a/Content/Materials/M_RenderTargetDisplay.uasset b/Content/Materials/M_RenderTargetDisplay.uasset
new file mode 100644
index 0000000..f8fe7cf
Binary files /dev/null and b/Content/Materials/M_RenderTargetDisplay.uasset differ
diff --git a/Content/Materials/RT_PlayerRenderTarget.uasset b/Content/Materials/RT_PlayerRenderTarget.uasset
new file mode 100644
index 0000000..0aaa832
Binary files /dev/null and b/Content/Materials/RT_PlayerRenderTarget.uasset differ
diff --git a/InventorySystem.sln.DotSettings.user b/InventorySystem.sln.DotSettings.user
new file mode 100644
index 0000000..77011d8
--- /dev/null
+++ b/InventorySystem.sln.DotSettings.user
@@ -0,0 +1,5 @@
+
+
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Solution />
+</SessionState>
\ No newline at end of file
diff --git a/Source/InventorySystem/InventorySystemCharacter.cpp b/Source/InventorySystem/InventorySystemCharacter.cpp
index 5853c77..7f50a4f 100644
--- a/Source/InventorySystem/InventorySystemCharacter.cpp
+++ b/Source/InventorySystem/InventorySystemCharacter.cpp
@@ -12,10 +12,13 @@
#include "InputActionValue.h"
#include "DrawDebugHelpers.h"
#include "Actors/Pickup.h"
+#include "Actors/Sword.h"
#include "Actors/Tablet.h"
#include "Blueprint/UserWidget.h"
#include "Components/InventoryComponent.h"
+#include "Components/SceneCaptureComponent2D.h"
#include "Components/WidgetInteractionComponent.h"
+#include "Engine/TextureRenderTarget2D.h"
#include "UserInterface/InventorySystemHUD.h"
#include "UserInterface/Inventory/DragItemVisual.h"
#include "UserInterface/Inventory/InventoryTooltip.h"
@@ -69,6 +72,11 @@ AInventorySystemCharacter::AInventorySystemCharacter()
PlayerInventory->SetSlotsCapacity(40);
PlayerInventory->SetWeightCapacity(60);
+ SceneCaptureComponent = CreateDefaultSubobject(TEXT("Scene Capture Component"));
+ SceneCaptureComponent->SetupAttachment(RootComponent);
+ SceneCaptureComponent->bCaptureEveryFrame = true;
+ SceneCaptureComponent->TextureTarget = PlayerRenderTarget;
+
InteractionCheckFrequency = 0.1;
InteractionCheckDistance = 225.f;
@@ -423,4 +431,31 @@ void AInventorySystemCharacter::DropItem(UItemBase* ItemToDrop, const int32 Quan
}
}
+void AInventorySystemCharacter::EquipWeapon(UItemBase* WeaponItem)
+{
+ if (WeaponItem)
+ {
+
+ if (SwordClass)
+ {
+ if (SwordWeapon)
+ {
+ SwordWeapon->Destroy();
+ }
+
+ FActorSpawnParameters SpawnParams;
+ SpawnParams.Owner = this;
+ SpawnParams.bNoFail = true;
+ SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
+
+ // weapon spawn transform and location
+ FTransform SpawnTransform = GetMesh()->GetSocketTransform("WeaponSocket");
+ SwordWeapon = GetWorld()->SpawnActor(SwordClass, SpawnTransform, SpawnParams);
+ SwordWeapon->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName("WeaponSocket"));
+ PlayerInventory->RemoveSingleInstanceOfItem(WeaponItem);
+ PlayerInventory->OnInventoryUpdated.Broadcast();
+ }
+ }
+}
+
diff --git a/Source/InventorySystem/InventorySystemCharacter.h b/Source/InventorySystem/InventorySystemCharacter.h
index 766e642..e50577e 100644
--- a/Source/InventorySystem/InventorySystemCharacter.h
+++ b/Source/InventorySystem/InventorySystemCharacter.h
@@ -10,6 +10,7 @@
#include "InventorySystemCharacter.generated.h"
+class ASword;
class UDragItemVisual;
class UInventoryTooltip;
class ATablet;
@@ -71,12 +72,17 @@ class AInventorySystemCharacter : public ACharacter
AInventorySystemCharacter();
FORCEINLINE bool IsInteracting() const { return GetWorldTimerManager().IsTimerActive(TimerHandleInteraction); }
- FORCEINLINE UInventoryComponent* GetInventory() const { return PlayerInventory; }
+ FORCEINLINE UInventoryComponent* GetInventory() const { return PlayerInventory; }
void UpdateInteractionWidget() const;
void DropItem(UItemBase* ItemToDrop, const int32 QuantityToDrop);
+ void EquipWeapon(UItemBase* WeaponItem);
+
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Rendering")
+ UTextureRenderTarget2D* PlayerRenderTarget;
+
protected:
//=============================================================================
@@ -86,6 +92,9 @@ class AInventorySystemCharacter : public ACharacter
UPROPERTY()
AInventorySystemHUD* HUDRef;
+ UPROPERTY()
+ ASword* SwordWeapon;
+
/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* CameraBoom;
@@ -146,6 +155,12 @@ class AInventorySystemCharacter : public ACharacter
UPROPERTY(EditDefaultsOnly, Category = "Character | Tablet")
TSubclassOf TabletClass;
+
+ UPROPERTY(EditDefaultsOnly, Category = "Character | Tablet")
+ TSubclassOf SwordClass;
+
+ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
+ USceneCaptureComponent2D* SceneCaptureComponent;
float InteractionCheckFrequency;
diff --git a/Source/InventorySystem/Private/Actors/Pickup.cpp b/Source/InventorySystem/Private/Actors/Pickup.cpp
index 31c0384..b9604b6 100644
--- a/Source/InventorySystem/Private/Actors/Pickup.cpp
+++ b/Source/InventorySystem/Private/Actors/Pickup.cpp
@@ -9,7 +9,7 @@ APickup::APickup()
PrimaryActorTick.bCanEverTick = false;
PickupStaticMesh = CreateDefaultSubobject("PickUp Actor Mesh");
- PickupStaticMesh->SetSimulatePhysics(false);
+ PickupStaticMesh->SetSimulatePhysics(true);
SetRootComponent(PickupStaticMesh);
}
diff --git a/Source/InventorySystem/Private/Actors/Sword.cpp b/Source/InventorySystem/Private/Actors/Sword.cpp
new file mode 100644
index 0000000..2d7c202
--- /dev/null
+++ b/Source/InventorySystem/Private/Actors/Sword.cpp
@@ -0,0 +1,15 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+
+#include "Actors/Sword.h"
+
+
+// Sets default values
+ASword::ASword()
+{
+ PrimaryActorTick.bCanEverTick = false;
+
+ WeaponMesh = CreateDefaultSubobject(TEXT("Tablet Mesh"));
+ SetRootComponent(WeaponMesh);
+ WeaponMesh->SetCollisionEnabled(ECollisionEnabled::Type::NoCollision);
+}
diff --git a/Source/InventorySystem/Private/UserInterface/Actors/CharacterDisplayWidget.cpp b/Source/InventorySystem/Private/UserInterface/Actors/CharacterDisplayWidget.cpp
new file mode 100644
index 0000000..3c39c7c
--- /dev/null
+++ b/Source/InventorySystem/Private/UserInterface/Actors/CharacterDisplayWidget.cpp
@@ -0,0 +1,36 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+
+#include "UserInterface/Actors/CharacterDisplayWidget.h"
+
+#include "Components/Image.h"
+#include "Engine/TextureRenderTarget2D.h"
+#include "InventorySystem/InventorySystemCharacter.h"
+#include "InventorySystem/DataStructure/ItemDataStructs.h"
+#include "Items/ItemBase.h"
+#include "UserInterface/Inventory/ItemDragDropOperation.h"
+
+void UCharacterDisplayWidget::NativeConstruct()
+{
+ Super::NativeConstruct();
+
+ PlayerCharacter = Cast(GetOwningPlayerPawn());
+}
+
+bool UCharacterDisplayWidget::NativeOnDrop(const FGeometry& InGeometry, const FDragDropEvent& InDragDropEvent,
+ UDragDropOperation* InOperation)
+{
+ const UItemDragDropOperation* ItemDragDrop = Cast(InOperation);
+
+ if(PlayerCharacter && ItemDragDrop->SourceItem)
+ {
+ if (ItemDragDrop->SourceItem->ItemType == EItemType::Weapons)
+ {
+ PlayerCharacter->EquipWeapon(ItemDragDrop->SourceItem);
+ return true;
+ }
+ }
+ return false;
+
+
+}
diff --git a/Source/InventorySystem/Public/Actors/Sword.h b/Source/InventorySystem/Public/Actors/Sword.h
new file mode 100644
index 0000000..e27f07d
--- /dev/null
+++ b/Source/InventorySystem/Public/Actors/Sword.h
@@ -0,0 +1,20 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+#pragma once
+
+#include "CoreMinimal.h"
+#include "GameFramework/Actor.h"
+#include "Sword.generated.h"
+
+UCLASS()
+class INVENTORYSYSTEM_API ASword : public AActor
+{
+ GENERATED_BODY()
+
+public:
+ // Sets default values for this actor's properties
+ ASword();
+
+ UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
+ UStaticMeshComponent* WeaponMesh;
+};
diff --git a/Source/InventorySystem/Public/Items/ItemBase.h b/Source/InventorySystem/Public/Items/ItemBase.h
index e072ed6..af12e20 100644
--- a/Source/InventorySystem/Public/Items/ItemBase.h
+++ b/Source/InventorySystem/Public/Items/ItemBase.h
@@ -3,6 +3,7 @@
#pragma once
#include "CoreMinimal.h"
+#include "Actors/Sword.h"
#include "UObject/Object.h"
#include "InventorySystem/DataStructure/ItemDataStructs.h"
#include "ItemBase.generated.h"
@@ -52,6 +53,7 @@ class INVENTORYSYSTEM_API UItemBase : public UObject
bool bIsPickup;
void ResetItemFlags();
+ TSubclassOf GetWeaponClass() const { return this->GetClass(); }
// Constructor
UItemBase();
diff --git a/Source/InventorySystem/Public/UserInterface/Actors/CharacterDisplayWidget.h b/Source/InventorySystem/Public/UserInterface/Actors/CharacterDisplayWidget.h
new file mode 100644
index 0000000..7fa871d
--- /dev/null
+++ b/Source/InventorySystem/Public/UserInterface/Actors/CharacterDisplayWidget.h
@@ -0,0 +1,35 @@
+// Fill out your copyright notice in the Description page of Project Settings.
+
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Blueprint/UserWidget.h"
+#include "CharacterDisplayWidget.generated.h"
+
+class AInventorySystemCharacter;
+class UImage;
+/**
+ *
+ */
+UCLASS()
+class INVENTORYSYSTEM_API UCharacterDisplayWidget : public UUserWidget
+{
+ GENERATED_BODY()
+
+public:
+
+ virtual void NativeConstruct() override;
+
+protected:
+
+ virtual bool NativeOnDrop(const FGeometry& InGeometry, const FDragDropEvent& InDragDropEvent,
+ UDragDropOperation* InOperation) override;
+
+ UPROPERTY(meta=(BindWidget))
+ UImage* CharacterImage;
+
+ UPROPERTY()
+ AInventorySystemCharacter* PlayerCharacter;
+
+
+};
diff --git a/Source/InventorySystem/Public/UserInterface/InventorySystemHUD.h b/Source/InventorySystem/Public/UserInterface/InventorySystemHUD.h
index f43b92f..037cfac 100644
--- a/Source/InventorySystem/Public/UserInterface/InventorySystemHUD.h
+++ b/Source/InventorySystem/Public/UserInterface/InventorySystemHUD.h
@@ -37,7 +37,9 @@ class INVENTORYSYSTEM_API AInventorySystemHUD : public AHUD
// Sets default values for this actor's properties
AInventorySystemHUD();
-
+
+ //void HideMenu();
+ //void ToggleMenu();
void ShowInteractionWidget();
void HideInteractionWidget();
void UpdateInteractionWidget(const FInteractableData* InteractableData) const;
@@ -59,4 +61,5 @@ class INVENTORYSYSTEM_API AInventorySystemHUD : public AHUD
// Called when the game starts or when spawned
virtual void BeginPlay() override;
+ //void DisplayMenu();
};