So I am building a mix of a 2d survival / action rpg (more towards the action rpg) and something that I am going to need to be able to keep track of is loot. I am going to have hundreds of base items I need to keep track of and then also each "entity" that can drop items will have a loot table of what items it can drop that I need to keep track of and I am trying to figure out an efficent way of doing this. I have an initial idea but what to get input on it.
NOTE: I am doing this in C# (Unity to be more specific).
I want to have 1 main class that would store an array of all possible items that can drop which would probably be read in from some sort of data file. Each of these items would have a unique string identifier so I would want to also store a dictionary<string, int> which would allow to easy access to the item by the identifier like this:
Item item = Items[itemDictionary[id]];
I assume this would be more efficent than using a List and doing something like filtering especically if the list of items gets really large.
Then each entity would have an array of all the possible items it can drop by storing the string identifiers. Then when the entity needs to drop a piece of loot, I can just pick a random index from that array which will lead me to the item from the main class storing all the items to know which item to drop.
Obviously this is a very high level overview of what I am think of implementing and I am sure as I expand thing, stuff might have to change but as a general concept, anyone have any feedback on this?
↧