Space Plunder
Loading...
Searching...
No Matches
InventoryComponent.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "InventoryComponent.generated.h"
9
10
11UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent))
12class INTERACTION_API UInventoryComponent : public UCharacterComponent
13{
14 GENERATED_BODY()
15
16public:
17 UInventoryComponent();
18
19 UFUNCTION(BlueprintCallable, Category="Inventory")
20 virtual bool CanItemBePickedUp(const FPickupItemData& Item) const;
21 UFUNCTION(BlueprintCallable, Category="Inventory")
22 virtual void PickupItem();
23
24 UFUNCTION(BlueprintCallable, Category="Inventory")
25 virtual void DropItem();
26
27 UFUNCTION(BlueprintCallable, Category="Inventory")
28 int32 GetMaxNumberOfItems() const {return MaxNumberOfItems;}
29 UFUNCTION(BlueprintCallable, Category="Inventory")
30 int32 GetMaxWeight() const {return MaxWeight;}
31
32 UFUNCTION(BlueprintCallable, Category="Inventory")
33 int32 GetTotalWeight() const;
34
35 // void SetThrowPoint(USceneComponent* ThrowPointComponent){ThrowPoint = ThrowPointComponent;};
36 // void SetThrowStrength(const float Strength){PickupThrowIntensity = Strength;};
37
38protected:
39 virtual void BeginPlay() override;
40
41 //~ ISaveLoad ~//
42 virtual bool SaveGame() override;
43 virtual bool LoadGame() override;
44 //~ ISaveLoad ~//
45
46
47 //- Overriden Functions //
48 virtual void ComponentSetupComplete() override;
49 virtual void OwnerDeath() override;
50
51 void SetupInventoryWidget();
52
53
54 UFUNCTION(Server, Reliable)
55 void ServerPickupItem();
56 UFUNCTION(Server, Reliable)
57 void ServerThrowItem();
58
59 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Inventory")
60 TArray<FPickupItemData>& GetInventory() {return Inventory;};
61
62 void AddItemToInventory(const FPickupItemData& NewItem);
63 void RemoveItemFromInventory(const int32 ItemToRemove);
64 UFUNCTION(Server, Reliable, WithValidation)
65 void ServerAddItemToInventory(const FPickupItemData& NewItem);
66 UFUNCTION(Server, Reliable, WithValidation)
67 void ServerRemoveItemFromInventory(const int32 ItemToRemove);
68
69
70 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Inventory|Widget")
71 TSoftClassPtr<UUserWidget> InventoryWidgetClass;
72
73private:
74 class IInventoryHUD* InventoryHUD = nullptr;
75
76 UPROPERTY(ReplicatedUsing=OnRep_Inventory)
77 TArray<FPickupItemData> Inventory;
78 UFUNCTION()
79 void OnRep_Inventory();
80
81 UPROPERTY(ReplicatedUsing=OnRep_CurrentItemIndex)
82 int32 CurrentItemIndex = 0;
83 UFUNCTION()
84 void OnRep_CurrentItemIndex();
85
86 UPROPERTY(EditAnywhere, Category="Inventory|General")
87 int32 MaxNumberOfItems = 5;
88 UPROPERTY(EditAnywhere, Category="Inventory|General")
89 int32 MaxWeight = 50;
90
91
92 UPROPERTY(EditDefaultsOnly, Category = "Inventory")
93 TSubclassOf<AActor> ItemToSpawn;
94 UPROPERTY(EditDefaultsOnly, Category = "Inventory")
95 float PickupThrowIntensity = 500.0f;
96 UPROPERTY(VisibleAnywhere)
97 USceneComponent* ThrowPoint = nullptr;
98
99
100};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition InventoryHUD.h:21
Represents a character component that can be added to an actor.
Definition InteractionData.h:127