Quick C# question that I'm pretty sure I know the answer to.
I'm trying to make some of the functions in my game a little bit more generic so they can be used across multiple game modes. As it stands now, I've only been working on the 'standard' mode, but the other modes in the game will all act similarly.
I've got a function now that does collision checking, and it's got a signature that looks like this:
Code:
List<Ball> balls; //defined for the whole class
List<Layer> layers; //defined for the whole class
private void CheckForCollision(int index){}
And that function basically checks if
ball[index] possibly collides with any of the
layers. Everything works just dandy now.
However, in two-player mode, there's going to be two lists of balls, and two lists of layers. The way this function works, the code will be fine, so long as it knows which list of balls and which list of layers to check with.
What I'm wondering is this (and I likely already know the answer, due to how C# works):
If I pass the list of balls, as well as the list of layers into the function, I'm only passing a reference in, right? I don't have to worry about it copying everything and doing it by value, even though the List class uses an underlying array, right?
I know I'm just over-thinking this. List is a class, and it should then automatically be a reference type, so there's nothing I've got to worry about, right?