Hi everyone!
I have a class called UItemsDB that extends UDataAsset. This class has five arrays:
/**This array contains all the items available in the game.*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Arrays")
TArray<FItem> itemsDBArr;
/**This array contains all the bullets that are available in the game.*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Arrays")
TArray<FBulletInfo> bulletsDBArr;
/**This array contains all the wearables that are available in the game.*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Arrays")
TArray<FWearable> wearablesDBArr;
/**This array contains all the weapon mags that are available in the game.*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Arrays")
TArray<FWeaponMag> weaponMagsDBArr;
/**This array contains all the weapons that are available in the game.*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Arrays")
TArray<FWeaponInfo> weaponsDBArr;
The struct FItem has a field called itemIDinOtherDB and it is used to access the item’s specific info. For example: I have an item that is weapon in itemsDBArr, but itemsDBArr only stores basic information from the item (like name, description, icon, etc) so to get the weapon’s info (fire rate, caliber, etc) I access the item (referred to an array item, not game item) of index equal to itemIDinOtherDB in weaponsDBArr. If I have an item that is a bullet I would do the same for the weapon, but instead of accessing an item in weaponsDBArr I would access an item in bulletsDBArr. It is a little confusing, I know (sorry :p) but this is the best I can do to explain.
I use this class (UItemsDB) to create a DataAsset blueprint that will store all my game’s items.
The problem:
I have a variable in an item ® in array A that stores an item’s index in array B.
I have a item © in array B (lets say © is in the index of 10).
The variable in ® stores ©’s index in array B.
If I remove an item from B before ©’s index (lets say we remove the item at index 8) then ©’s index would change (to 9)
If ©’s index changed (to 9) then the variable in ® in array A would be pointing to a completely different item.
An image to explain it a little better:
How would I go around that?
Thanks in advance!
PS: I was trying to make a UE4 plugin to manage this Data Asset but it didn’t work.