Just a couple of general API design comments I wanted to make. It is probably too late to do anything about these comments now, but I consider them serious design flaws so I wanted to say something just in case.
1. Generics. The API uses raw Collection objects without specifying what they are collections of. This means the compiler can't do any type checking for us to make sure we are passing the values the API expects. Passing the wrong type results in a CTD.
2. Stop the List madness! Please (please please) do not use Java Lists as a replacement for SQF lists. If you must, use arrays of primitive types, or better yet "unroll" the list contents into separate function parameters.
Consider a typical SQF function:
Code:
light setLightColor [0.3, 0.0, 0.0];
In Java this becomes RVEngine.setLightColor(GameObject, List)
Code:
List red = new ArrayList();
red.add(new Float(0.3));
red.add(new Float(0.0));
red.add(new Float(0.0));
RVEngine.setLightColor(light, red);
Ok, we would actually write something like:
Code:
RVEngine.setLightColor(light, Arrays.asList(0.3f, 0.0f, 0.0f));
But the JVM still has to execute the same sequence of instructions. First it has to create a new list object, then it needs to add three floats to the list, but Java collections can't store primitive types like float, so the JVM has to create a java.lang.Float object for each of the numbers.
That is alot of work for what should be:
Code:
RVEngine.setLightColor(light, 0.3, 0, 0);
With the above we don't have to create a bunch of unnecessary objects simply to pass three values to the game engine, the compiler is able to do type checking for us again, and the compiler is able to coerce values when needed (i.e. int to float).
Having said all that, I get the sense that the user facing part of the Java API is machine generated, so I am hoping these are things that might be fixed "relatively" easily. Adding Generics is something that has to be done ASAP as adding it later will break all existing code. Getting rid of Lists can be done over time by overriding methods with their listless counterparts, but it's still code bloat that should go ASAP.