-
Notifications
You must be signed in to change notification settings - Fork 6
/
Inventory.h
101 lines (72 loc) · 3.81 KB
/
Inventory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Object.h"
#include "MasterItemActor.h"
#include "Inventory.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct FInventoryStructure
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "InventoryStructure")
int32 bCount;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "InventoryStructure")
TSubclassOf<class AMasterItemActor> bClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "InventoryStructure")
FString bID;
//Constructor
FInventoryStructure()
{
bClass = NULL;
bCount = -1;
bID = "";
}
FInventoryStructure(TSubclassOf<class AMasterItemActor> inClass, int32 inCount, FString inID) {
bClass = inClass;
bCount = inCount;
bID = inID;
}
};
UCLASS()
class REPLICATION_API UInventory : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetStackByIndex(int32 inIndex, TArray<FInventoryStructure> inInventory, FInventoryStructure & outStructure);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetStackByID(FString inID, TArray<FInventoryStructure> inInventory, FInventoryStructure & outStructure, int32 & FoundIndex);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetItemInfo(TSubclassOf<AMasterItemActor> bItemClass, FItemInfo & bIteminfo);
UFUNCTION(BlueprintPure, Category = "Inventory|Helper")
static void GetUniqueID(FString & bUniqueID);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool Initialize(int32 inSlots, TArray<FInventoryStructure> & inInventory);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetStackByClass(TSubclassOf<class AMasterItemActor> inClass, bool bReturnFullStacks, TArray<FInventoryStructure> inInventory, FInventoryStructure & outStructure, int32 & FoundIndex);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetItemCount(TSubclassOf<class AMasterItemActor> inClass, TArray<FInventoryStructure> inInventory, int32 & ItemCount);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetItemStackCount(TSubclassOf<class AMasterItemActor> inClass, TArray<FInventoryStructure> inInventory, int32 & StackCount);
UFUNCTION(BlueprintPure, Category = "Inventory")
static int32 StacksFromAmount(TSubclassOf<class AMasterItemActor> inClass, int32 inAmount);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetFreeInventorySpace(TSubclassOf<class AMasterItemActor> inClass, TArray<FInventoryStructure> inInventory, int32 & outCount);
UFUNCTION(BlueprintPure, Category = "Inventory")
static bool GetFreeInventorySlots(TArray<FInventoryStructure> inInventory, int32 & outCount);
UFUNCTION(BlueprintCallable, Category = "Inventory")
static bool AddToInventory(TSubclassOf<class AMasterItemActor> inClass, UPARAM(ref) TArray<FInventoryStructure> & inInventory, int32 Amount, bool AddNewStack);
UFUNCTION(BlueprintCallable, Category = "Inventory")
static bool RemoveFromInventory(TSubclassOf<class AMasterItemActor> inClass, UPARAM(ref) TArray<FInventoryStructure>& inInventory, int32 Amount);
UFUNCTION(BluePrintCallable, Category = "Inventory")
static bool RemoveFromStack(int32 inIndex, UPARAM(ref) TArray<FInventoryStructure> & inInventory, int32 Amount, bool RemoveWholeStack = false);
UFUNCTION(BlueprintCallable, Category = "Inventory")
static bool SwapInventoryPosition(UPARAM(ref) TArray<FInventoryStructure> & inInventory, int32 inIndexA, int32 inIndexB);
UFUNCTION(BlueprintCallable, Category = "Inventory")
static bool SplitStack(UPARAM(ref) TArray<FInventoryStructure> & inInventory, int32 inIndex, int32 inSplit);
UFUNCTION(BlueprintCallable, Category = "Inventory")
static bool MergeStacks(UPARAM(ref) TArray<FInventoryStructure> & inInventory, int32 inIndexA, int32 inIndexB);
};