Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
lucoiso committed Mar 15, 2024
1 parent 8f6112c commit 7720894
Show file tree
Hide file tree
Showing 32 changed files with 2,407 additions and 2,499 deletions.
32 changes: 16 additions & 16 deletions Config/DefaultElementusInventory.ini
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[CoreRedirects]
+ClassRedirects=(OldName="/Script/ElementusInventory.InventoryItemData",NewName="/Script/ElementusInventory.ElementusItemData")
+ClassRedirects = (OldName="/Script/ElementusInventory.InventoryItemData",NewName="/Script/ElementusInventory.ElementusItemData")

+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareElementusItems",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareItemInfo")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareElementusItemDatas",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareItemData")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetElementusItemDataById",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetSingleItemDataById")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetElementusItemDataArrayById",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemDataArrayById")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.SearchElementusItemData",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.SearchItemData")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CanStackItem",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.IsItemStackable")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemTagsFromParent",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemTagsWithParentTag")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareElementusItems",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareItemInfo")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareElementusItemDatas",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.CompareItemData")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetElementusItemDataById",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetSingleItemDataById")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetElementusItemDataArrayById",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemDataArrayById")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.SearchElementusItemData",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.SearchItemData")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.CanStackItem",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.IsItemStackable")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemTagsFromParent",NewName="/Script/ElementusInventory.ElementusInventoryFunctions.GetItemTagsWithParentTag")

+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.GetItemStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.GetItemsArray")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.FindElementusItemInStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.FindFirstItemIndexWithInfo")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.FindElementusItemInStackWithTags",NewName="/Script/ElementusInventory.ElementusInventoryComponent.FindFirstItemIndexWithTags")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.ContainItemInStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.ContainsItem")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.DebugInventoryStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.DebugInventory")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.GetItemStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.GetItemsArray")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.FindElementusItemInStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.FindFirstItemIndexWithInfo")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.FindElementusItemInStackWithTags",NewName="/Script/ElementusInventory.ElementusInventoryComponent.FindFirstItemIndexWithTags")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.ContainItemInStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.ContainsItem")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.DebugInventoryStack",NewName="/Script/ElementusInventory.ElementusInventoryComponent.DebugInventory")

+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.AddElementusItem",NewName="/Script/ElementusInventory.ElementusInventoryComponent.AddElementusItems")
+FunctionRedirects=(OldName="/Script/ElementusInventory.ElementusInventoryComponent.RemoveElementusItem",NewName="/Script/ElementusInventory.ElementusInventoryComponent.RemoveElementusItems")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.AddElementusItem",NewName="/Script/ElementusInventory.ElementusInventoryComponent.AddElementusItems")
+FunctionRedirects = (OldName="/Script/ElementusInventory.ElementusInventoryComponent.RemoveElementusItem",NewName="/Script/ElementusInventory.ElementusInventoryComponent.RemoveElementusItems")

+FunctionRedirects=(OldName="/Script/ElementusInventory.UElementusInventoryFunctions.SearchItemData",NewName="/Script/ElementusInventory.UElementusInventoryFunctions.SearchElementusItemData")
+FunctionRedirects = (OldName="/Script/ElementusInventory.UElementusInventoryFunctions.SearchItemData",NewName="/Script/ElementusInventory.UElementusInventoryFunctions.SearchElementusItemData")
78 changes: 39 additions & 39 deletions ElementusInventory.uplugin
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"FileVersion": 3,
"Version": 7,
"VersionName": "1.1.9",
"FriendlyName": "Elementus Inventory",
"Description": "Plugin that provides a Data-Driven Inventory & Items system based on FPrimaryAssetIds and the Asset Manager.",
"Category": "Game Features",
"CreatedBy": "Lucas Vilas-Boas",
"CreatedByURL": "https://github.com/lucoiso",
"DocsURL": "https://github.com/lucoiso/UEElementusInventory/wiki",
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ed47993a6b8a49bdb04dfe83939b6361",
"SupportURL": "https://github.com/lucoiso/UEElementusInventory/issues",
"CanContainContent": false,
"IsBetaVersion": true,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "ElementusInventory",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
"Mac",
"Linux",
"IOS",
"Android"
]
},
{
"Name": "ElementusInventoryEditor",
"Type": "Editor",
"LoadingPhase": "Default",
"PlatformAllowList": [
"Win64",
"Mac",
"Linux"
]
}
]
"FileVersion": 3,
"Version": 8,
"VersionName": "1.1.10",
"FriendlyName": "Elementus Inventory",
"Description": "Plugin that provides a Data-Driven Inventory & Items system based on FPrimaryAssetIds and the Asset Manager.",
"Category": "Game Features",
"CreatedBy": "Lucas Vilas-Boas",
"CreatedByURL": "https://github.com/lucoiso",
"DocsURL": "https://github.com/lucoiso/UEElementusInventory/wiki",
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ed47993a6b8a49bdb04dfe83939b6361",
"SupportURL": "https://github.com/lucoiso/UEElementusInventory/issues",
"CanContainContent": false,
"IsBetaVersion": true,
"IsExperimentalVersion": false,
"Installed": false,
"Modules": [
{
"Name": "ElementusInventory",
"Type": "Runtime",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
"Mac",
"Linux",
"IOS",
"Android"
]
},
{
"Name": "ElementusInventoryEditor",
"Type": "Editor",
"LoadingPhase": "Default",
"PlatformAllowList": [
"Win64",
"Mac",
"Linux"
]
}
]
}
34 changes: 17 additions & 17 deletions Source/ElementusInventory/ElementusInventory.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

public class ElementusInventory : ModuleRules
{
public ElementusInventory(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
CppStandard = CppStandardVersion.Cpp17;
public ElementusInventory(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
CppStandard = CppStandardVersion.Cpp17;

PublicDependencyModuleNames.AddRange(new[]
{
"Core"
});
PublicDependencyModuleNames.AddRange(new[]
{
"Core"
});

PrivateDependencyModuleNames.AddRange(new[]
{
"Engine",
"NetCore",
"CoreUObject",
"GameplayTags",
"DeveloperSettings"
});
}
PrivateDependencyModuleNames.AddRange(new[]
{
"Engine",
"NetCore",
"CoreUObject",
"GameplayTags",
"DeveloperSettings"
});
}
}
109 changes: 56 additions & 53 deletions Source/ElementusInventory/Private/Actors/ElementusInventoryPackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,92 +17,95 @@

AElementusInventoryPackage::AElementusInventoryPackage(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
bNetStartup = false;
bNetLoadOnClient = false;
bReplicates = true;
bNetStartup = false;
bNetLoadOnClient = false;
bReplicates = true;

PrimaryActorTick.bCanEverTick = false;
PrimaryActorTick.bStartWithTickEnabled = false;
PrimaryActorTick.bCanEverTick = false;
PrimaryActorTick.bStartWithTickEnabled = false;

RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));

PackageInventory = CreateDefaultSubobject<UElementusInventoryComponent>(TEXT("PackageInventory"));
PackageInventory->SetIsReplicated(true);
PackageInventory = CreateDefaultSubobject<UElementusInventoryComponent>(TEXT("PackageInventory"));
PackageInventory->SetIsReplicated(true);

if (const UElementusInventorySettings* const Settings = UElementusInventorySettings::Get())
{
bDestroyWhenInventoryIsEmpty = Settings->bDestroyWhenInventoryIsEmpty;
}
if (const UElementusInventorySettings* const Settings = UElementusInventorySettings::Get())
{
bDestroyWhenInventoryIsEmpty = Settings->bDestroyWhenInventoryIsEmpty;
}
}

void AElementusInventoryPackage::BeginPlay()
{
Super::BeginPlay();
Super::BeginPlay();

SetDestroyOnEmpty(bDestroyWhenInventoryIsEmpty);
SetDestroyOnEmpty(bDestroyWhenInventoryIsEmpty);

if (bDestroyWhenInventoryIsEmpty && UElementusInventoryFunctions::HasEmptyParam(PackageInventory->GetItemsArray()))
{
Destroy();
}
if (bDestroyWhenInventoryIsEmpty && UElementusInventoryFunctions::HasEmptyParam(PackageInventory->GetItemsArray()))
{
Destroy();
}
}

void AElementusInventoryPackage::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
Super::GetLifetimeReplicatedProps(OutLifetimeProps);

FDoRepLifetimeParams SharedParams;
SharedParams.bIsPushBased = true;
FDoRepLifetimeParams SharedParams;
SharedParams.bIsPushBased = true;

DOREPLIFETIME_WITH_PARAMS_FAST(AElementusInventoryPackage, PackageInventory, SharedParams);
DOREPLIFETIME_WITH_PARAMS_FAST(AElementusInventoryPackage, PackageInventory, SharedParams);
}

void AElementusInventoryPackage::PutItemIntoPackage(const TArray<FElementusItemInfo> ItemInfo, UElementusInventoryComponent* FromInventory)
{
UElementusInventoryFunctions::TradeElementusItem(ItemInfo, FromInventory, PackageInventory);
MARK_PROPERTY_DIRTY_FROM_NAME(AElementusInventoryPackage, PackageInventory, this);
UElementusInventoryFunctions::TradeElementusItem(ItemInfo, FromInventory, PackageInventory);
MARK_PROPERTY_DIRTY_FROM_NAME(AElementusInventoryPackage, PackageInventory, this);
}

void AElementusInventoryPackage::GetItemFromPackage(const TArray<FElementusItemInfo> ItemInfo, UElementusInventoryComponent* ToInventory)
{
UElementusInventoryFunctions::TradeElementusItem(ItemInfo, PackageInventory, ToInventory);
MARK_PROPERTY_DIRTY_FROM_NAME(AElementusInventoryPackage, PackageInventory, this);
UElementusInventoryFunctions::TradeElementusItem(ItemInfo, PackageInventory, ToInventory);
MARK_PROPERTY_DIRTY_FROM_NAME(AElementusInventoryPackage, PackageInventory, this);
}

void AElementusInventoryPackage::SetDestroyOnEmpty(const bool bDestroy)
{
if (bDestroyWhenInventoryIsEmpty == bDestroy)
{
return;
}

bDestroyWhenInventoryIsEmpty = bDestroy;
FElementusInventoryEmpty Delegate = PackageInventory->OnInventoryEmpty;

if (const bool bIsAlreadyBound = Delegate.IsAlreadyBound(this, &AElementusInventoryPackage::BeginPackageDestruction); bDestroy && !bIsAlreadyBound)
{
Delegate.AddDynamic(this, &AElementusInventoryPackage::BeginPackageDestruction);
}
else if (!bDestroy && bIsAlreadyBound)
{
Delegate.RemoveDynamic(this, &AElementusInventoryPackage::BeginPackageDestruction);
}
if (bDestroyWhenInventoryIsEmpty == bDestroy)
{
return;
}

bDestroyWhenInventoryIsEmpty = bDestroy;
FElementusInventoryEmpty Delegate = PackageInventory->OnInventoryEmpty;

if (const bool bIsAlreadyBound = Delegate.IsAlreadyBound(this, &AElementusInventoryPackage::BeginPackageDestruction); bDestroy && !
bIsAlreadyBound)
{
Delegate.AddDynamic(this, &AElementusInventoryPackage::BeginPackageDestruction);
}
else if (!bDestroy && bIsAlreadyBound)
{
Delegate.RemoveDynamic(this, &AElementusInventoryPackage::BeginPackageDestruction);
}
}

bool AElementusInventoryPackage::GetDestroyOnEmpty() const
{
return bDestroyWhenInventoryIsEmpty;
return bDestroyWhenInventoryIsEmpty;
}

void AElementusInventoryPackage::BeginPackageDestruction_Implementation()
{
// Check if this option is still active before the destruction
if (bDestroyWhenInventoryIsEmpty)
{
Destroy();
}
else
{
UE_LOG(LogElementusInventory_Internal, Warning, TEXT("ElementusInventory - %s: Package %s was not destroyed because the " "option 'bDestroyWhenInventoryIsEmpty' was disabled"), *FString(__func__), *GetName());
}
}
// Check if this option is still active before the destruction
if (bDestroyWhenInventoryIsEmpty)
{
Destroy();
}
else
{
UE_LOG(LogElementusInventory_Internal, Warning,
TEXT("ElementusInventory - %s: Package %s was not destroyed because the " "option 'bDestroyWhenInventoryIsEmpty' was disabled"),
*FString(__func__), *GetName());
}
}
Loading

0 comments on commit 7720894

Please sign in to comment.