ReplicaIsland ported to the KotlinIsland.

33 views
Skip to first unread message

Jim Andreas

unread,
Sep 6, 2020, 11:30:59 AM9/6/20
to ReplicaIsland Coding Community
Hi All,
I have completed a preliminary port of ReplicaIsland to the Island of Kotlin.

Link:

Still working on getting the last few Lint errors worked out.   But the game builds and plays just fine.
Jim A

Chris Pruett

unread,
Sep 6, 2020, 12:39:55 PM9/6/20
to replica-island-...@googlegroups.com
Hi Jim,

This is awesome, thanks for sharing!

I don’t know a ton about Kotlin beyond that it is intended to be interoperable with Java and comparatively concise.  What was the port work like?  Mostly syntactical or did you need to change the way things worked anywhere?

Cheers,
Chris


--
You received this message because you are subscribed to the Google Groups "ReplicaIsland Coding Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to replica-island-coding...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/replica-island-coding-community/04557d1e-7df4-4631-8cf2-1a9e40a764c7n%40googlegroups.com.

Jim Andreas

unread,
Sep 7, 2020, 1:40:14 AM9/7/20
to ReplicaIsland Coding Community
Hi Chris,

First of all - Thank *you* and the Islanders for creating ReplicaIsland and sharing the code with the world.   And for explaining its design and function in numerous talks and posts.   It is a great volume of work to study.

The port of the Java code to Kotlin was relatively straightforward.  It involved a lot of "Control-Alt-Shift-K" certainly, fixing up minor confusions from the conversion process and play-testing.   The last part was fun!   There was one tricky bit in the ObjectManager module - the findByClass() type-casting operation needed a bit of help.  My solution is shown below.   And there were some unusual differences in byte processing that needed workarounds.   In terms of time, I estimate that I spent about equal hours cleaning up lint complaints and play testing.   The structure of the Java code was "resilient" - in other words I didn't break it too often :-).

ObjectManager.kt:
/**
 * Finds a child object by its type. Note that this may invoke the class loader and therefore
 * may be slow.
 * @param classObject The class type to search for (e.g. BaseObject.class).
 */
fun <T> findByClass(classObject: Class<T>): T? {
  val count = mObjects.count
  for (i in 0 until count) {
    val currentObject = mObjects[i]
    if (currentObject!!.javaClass == classObject) {
       return currentObject as T
    }
  }
  return null
}

 
Reply all
Reply to author
Forward
0 new messages