Hi,
I have a class drived from the empty class and I get to errors which I can’t fixe:
may be you could help me in some way is my question is unclear or I didn’t provieded enought info please give me feed back.
Thanks a lot for any help : D
here is my sorce code:
.h
#pragma once
#include "CoreMinimal.h"
struct FItem
{
public:
FItem();
int GetType();
bool Valid();
TArray<uint32> stats;
};
class ERUNE_API Inventory
{
public:
Inventory();
~Inventory();
// set the size of array only once
//void SetSizeInv(int size);
void SetSizeInv(int size);
// add a item to the list
int AddItemInv(FItem item);
// delets a itme at the index
void DeleteItemInv(int index);
// get item at position
FItem GetItemInv(int index);
private:
TArray<FItem> inv;
int size;
};
.cpp
#include "Inventory.h"
#include "erune.h"
FItem::FItem()
{
stats.Add(0);
}
int FItem::GetType()
{
if (stats.Num() > 0)
{
return stats[0] % 10;
}
return 0;
}
bool FItem::Valid()
{
return GetType() == 0;
}
Inventory::Inventory(){ }
Inventory::~Inventory(){ }
int Inventory::AddItemInv(FItem item)
{
for (int32 i = 0; i != inv.Num(); i++)
{
if (inv[i].GetType())
{
return 0;
}
}
return 1;
}
void Inventory::SetSizeInv(int size)
{
if (this->size == 0)
{
this->size = size;
//inv.AddDefaulted(size);
}
}
void Inventory::DeleteItemInv(int index)
{
inv.InsertDefaulted(index);
}
FItem Inventory::GetItemInv(int index)
{
if (index < inv.Num())
{
return inv[index];
}
return FItem();
}