C
C#13mo ago
triplemocha

❔ Should procedural 2d maps be with structs or instantiated with 'new'?

I am creating a game that can sometimes have a 1000x1000 interior grids in width and height. Exteriors will likely be larger, maybe a 5000x5000 2d array. Each grid square is called a Cell. A Cell class includes an enumerated type, two Lists (can hold up to 20 ints), and a float and boolean variable. My assumption is only a few maps will be loaded at a time, but I'm open to the idea of saving procedurally generated maps in a Dictionary key/value later. Should each Cell object be of a struct or class type?
5 Replies
Angius
Angius13mo ago
I'd say a class, since it contains a List and it's a reference type
triplemocha
triplemocha13mo ago
Okay. To add, my intentions is to generate these in Unity and hope using classes won't cause a performance issue.
Angius
Angius13mo ago
Benchmark
Google
Google13mo ago
Don’t worry about it until it’s an issue.
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts