I'm currently working on a simple database structure to store information on components for use in a games engine.
I have two classes that make up a database : DBEntry_Name - the class making up each entry in the database and NameDB which is the database itself.
I don't so much as have a problem, but a query as to how references to database entries are stored (in terms of memory usage) in variables. Some of my entries contain references to other entries in a completely different database. An example of a typical entry is below:
public class BuildingDB {
private static List<DBEntry_Building> AllBuildings = new List<DBEntry_Building>();
#region Towers
public static DBEntry_Building Tower = new DBEntry_Building {
ID = 1, // <== this is due to by replaced by a reference to the List index of the entry
Name = "Tower",
Prefab = Resources.Load("Prefabs/Tower") as GameObject,
Cost = 10,
BuildTime = 5.0f,
AttackSpeed = 1,
AttackDamage = 10,
AttackRange = 7,
ProjectileType = ProjectileDB.Rock, // <==== is this storing excess information? could we request the ID of the projectile and store that instead?
};
#endregion
}
I can replace the line I have the issue with by using a function to exchange the DBentry for an integer instead which could then be exchanged for the index of the database list, but is this necessary? My suspicion is that ProjectileType will take up much more memory than a simple int, hence why I'm asking this question.
How will ProjectileType be stored? Will all of it's values be stored too, or will they be retrieved from the projectile database?
Thanks.