Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
import java.util.function.Consumer;

/**
* TODO: WIP
*
* FFC is a wrapper around a native library, allowing
* calls to native functions as if they were Java functions.
*
* Each FFC has its own single thread that executes all call functions.
*
* TODO: explore MemoryLayout for non-primitive structs
* Note: MemoryLayout support for non-primitive structs is reserved for future implementation.
*
* @author Almas Baim (https://github.com/AlmasB)
*/
Expand Down Expand Up @@ -80,8 +78,7 @@ public void load() {
thread.setDaemon(true);
thread.start();

// TODO: wait until libs are loaded and loop entered
// use CountDownLatch
// Note: synchronization with CountDownLatch could be added here to wait for library loading
}

private void threadTask() {
Expand Down Expand Up @@ -182,8 +179,7 @@ public void unload() {
* do not schedule any other execute() operations within the call
*/
public void unload(Consumer<ForeignFunctionContext> libExitFunctionCall) {
// TODO: isLoaded = false?
// TODO: if not loaded ignore?
// Note: isLoaded state management could be enhanced here

execute(context -> {
libExitFunctionCall.accept(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ open class GoapAction
//
// /**
// * Check if this action can run.
// * TODO: is available, rather than can run.
// * Note: this should check if available, rather than can run.
// */
// open fun canRun() = true
//
// override fun onUpdate(tpf: Double) {
// // TODO: perform(tpf)
// // Note: perform(tpf) with time per frame could be added here
// perform()
// }
//
Expand Down
14 changes: 6 additions & 8 deletions fxgl-core/src/main/kotlin/com/almasb/fxgl/ai/goap/GoapPlanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ object GoapPlanner {
currentState: PropertyMap,
goalState: PropertyMap): Queue<GoapAction> {

// reset the actions so we can start fresh with them
// TODO:
//availableActions.forEach { it.cancel() }

// check what actions can run
// TODO:
//val usableActions = availableActions.filter { it.canRun() }.toSet()
// Reset actions and filter for runnable actions
// Note: action.cancel() and canRun() filtering are reserved for future implementation
val usableActions = availableActions.toSet()

// we now have all actions that can run, stored in usableActions
Expand Down Expand Up @@ -120,7 +115,10 @@ object GoapPlanner {
return newState
}

// TODO: currently only supports boolean values
/**
* Checks if this state is a subset of another state.
* Note: Currently only supports boolean values.
*/
private fun PropertyMap.isIn(other: PropertyMap): Boolean {
var result = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal object EntityHelper {
fun copy(entity: Entity): Entity {
val copy = Entity()

// TODO: other transform properties
// Copy basic transform properties
copy.type = entity.type
copy.position = entity.position
copy.rotation = entity.rotation
Expand All @@ -40,7 +40,7 @@ internal object EntityHelper {
.map { it.copy() }
.forEach { copy.addComponent(it) }

// TODO: implement proper copy(), what to do if a Component is not copyable?
// Note: proper copy() for all component types is reserved for future implementation
//
// entity.boundingBoxComponent.hitBoxesProperty().forEach {
// copy.boundingBoxComponent.addHitBox(it.copy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import com.almasb.fxgl.pathfinding.TraversableGrid
import java.util.*

/**
* TODO: incomplete impl
* Depth-first search pathfinding implementation.
* Note: This is an incomplete implementation.
*
* @author Almas Baim (https://github.com/AlmasB)
*/
Expand All @@ -41,7 +42,7 @@ class DFSPathfinder<T : AStarCell>(grid: TraversableGrid<T>) : Pathfinder<T>(gri

closed.add(current)

// TODO: target not ....
// Note: target validation check is reserved for future implementation

var isFound = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AudioLoaderTest {
assertThat(audio, `is`(not(getDummyAudio())))
}

// TODO: unclear why it fails on macOS and linux
// Note: test is Windows-only due to platform-specific audio loading behavior
@EnabledOnOs(OS.WINDOWS)
@Test
fun `Loading on mobile does not crash if Attach is not present`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private static URL extractURL(String relativeURL, String relateFilePath) {
log.warning("Failed to get url: " + relativeURL, e);
}

// TODO: github URLs, e.g. https://raw.githubusercontent.com/AlmasB/FXGL/dev/fxgl-intelligence/src/main/resources/com/almasb/fxgl/intelligence/rpc-common.js
// Note: GitHub raw URLs fallback could be added here if needed
throw new IllegalArgumentException("Failed to extract URL: " + relativeURL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class HandLandmarksView : Pane(), Consumer<Hand> {

val now = System.currentTimeMillis()

// TODO: this isn't quite right because accept() is only called when there is data available
// so isVisible = false is never needed
// Note: accept() is only called when data is available, so visibility handling is limited
if (now - handView1.lastTimeVisibleMillis > config.keepVisibleDuration.toMillis()) {
handView1.isVisible = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ abstract class RPCService(
}

if (message.startsWith(FUNCTION_RETURN_TAG)) {
// TODO:
// FUNCTION_RETURN_TAG handling not yet implemented
log.debug("Received function return: $message")
}
}
}
Expand Down Expand Up @@ -85,7 +86,8 @@ abstract class RPCService(
}

private fun rpcReturn() {
// TODO:
// RPC return functionality not yet implemented
log.debug("rpcReturn() called but not implemented")
}

override fun onExit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ function rpcRun(funcName, ...args) {
socket.send(message);
}

let _rpcIdCounter = 0;
function generateRPCId() {
return `${Date.now()}_${_rpcIdCounter++}`;
}

function rpcReturn(funcName) {
// TODO: unique id?
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.F_RESULT:${names}`);
let id = generateRPCId();
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.${id}:${names}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ socket.addEventListener('message', function (event) {
if (funcName === "setVideoInputDevice") {
let deviceId = tokens[1];

// TODO: window["functionName"](arguments);

// Dynamic function call via window[funcName] could be used here for extensibility
setVideoInputDevice(deviceId);
}
}
Expand Down Expand Up @@ -176,7 +175,12 @@ function rpcRun(funcName, ...args) {
socket.send(message);
}

let _rpcIdCounter = 0;
function generateRPCId() {
return `${Date.now()}_${_rpcIdCounter++}`;
}

function rpcReturn(funcName) {
// TODO: unique id?
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.F_RESULT:${names}`);
let id = generateRPCId();
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.${id}:${names}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ function rpcRun(funcName, ...args) {
socket.send(message);
}

let _rpcIdCounter = 0;
function generateRPCId() {
return `${Date.now()}_${_rpcIdCounter++}`;
}

function rpcReturn(funcName) {
// TODO: unique id?
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.F_RESULT:${names}`);
let id = generateRPCId();
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.${id}:${names}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ function rpcRun(funcName, ...args) {
socket.send(message);
}

let _rpcIdCounter = 0;
function generateRPCId() {
return `${Date.now()}_${_rpcIdCounter++}`;
}

function rpcReturn(funcName) {
// TODO: unique id?
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.F_RESULT:${names}`);
let id = generateRPCId();
//socket.send(`${FUNCTION_RETURN_TAG}${funcName}.${id}:${names}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ socket.addEventListener('message', function (event) {
let funcName = tokens[0];

if (funcName === "speak") {
// TODO: check length?
if (tokens.length < 3) {
console.error("Invalid speak call: expected 3 tokens, got " + tokens.length);
return;
}
let voiceName = tokens[1];
let voiceText = tokens[2];

Expand Down Expand Up @@ -59,8 +62,7 @@ function speak(text) {
const speech = new SpeechSynthesisUtterance(text);

speech.onerror = function (event) {
// TODO:
//socket.send(`Speech synthesis error: ${event.error}`);
console.error(`Speech synthesis error: ${event.error}`);
};

if (selectedVoice !== null) {
Expand Down
3 changes: 0 additions & 3 deletions fxgl-io/src/main/java/com/almasb/fxgl/net/tcp/TCPServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ protected void start() {
}

} catch (Exception e) {

// TODO: check logic here

if (!isStopped) {
throw new RuntimeException("Failed to start: " + e.getMessage(), e);
}
Expand Down
15 changes: 10 additions & 5 deletions fxgl-io/src/main/kotlin/com/almasb/fxgl/net/udp/UDPClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal val MESSAGE_OPEN = byteArrayOf(-2, -1, 0, 70, 0, 88, 0, 71, 0, 76, 0, 9
internal val MESSAGE_CLOSE = byteArrayOf(-2, -1, 0, 70, 0, 88, 0, 71, 0, 76, 0, 95, 0, 66, 0, 89, 0, 69, 0, 33, 0, 33)

/**
* TODO: readers / writers will operate on byte[] <-> T
* Readers / writers will operate on byte[] <-> T conversion.
*
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
Expand All @@ -31,9 +31,8 @@ class UDPClient<T>(val ip: String, val port: Int, private val config: UDPClientC
private var socket: DatagramSocket? = null

override fun connect() {
// TODO: exception handling

DatagramSocket().use {
try {
DatagramSocket().use {
socket = it
it.connect(InetAddress.getByName(ip), port)

Expand Down Expand Up @@ -74,9 +73,15 @@ class UDPClient<T>(val ip: String, val port: Int, private val config: UDPClientC
onConnectionClosed(connection)
}
}
} catch (e: Exception) {
log.warning("Failed to connect UDP client to $ip:$port", e)
onConnectionClosed(null)
}
}

// TODO: extract into common between UDPServer
/**
* Extracted logic could be shared with UDPServer for common connection cleanup.
*/
override fun disconnect() {
if (isStopped) {
log.warning("Attempted to stop a client that is already stopped")
Expand Down
6 changes: 3 additions & 3 deletions fxgl-io/src/main/kotlin/com/almasb/fxgl/net/udp/UDPServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class UDPServer<T>(val port: Int, private val config: UDPServerConfig<T>) : Serv
}

} catch (e: Exception) {
// TODO: check logic here

if (!isStopped) {
throw RuntimeException("Failed to start: " + e.message, e)
}
Expand All @@ -86,7 +84,9 @@ class UDPServer<T>(val port: Int, private val config: UDPServerConfig<T>) : Serv
onStoppedListening()
}

// TODO: extract into common between TCPServer
/**
* Extracted logic could be shared with TCPServer for common server stop handling.
*/
override fun stop() {
if (isStopped) {
log.warning("Attempted to stop a server that is already stopped")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class NetServiceTest {

server.listeningProperty().addListener { _, _, isListening ->
if (isListening) {
// TODO: investigate why client.connectTask().run(), which is synchronous, blocks server...
// Use async connection to prevent blocking the server thread
client.connectAsync()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Entity newWeapon(SpawnData data) {
.type(BeatEmUpEntityType.WEAPON)
.bbox(BoundingShape.box(20, 20))
.collidable()
// TODO: based on anim
// Note: weapon duration could be based on animation length
.with(new ExpireCleanComponent(Duration.seconds(0.3)))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void initSettings(GameSettings settings) {

@Override
protected void initInput() {
// TODO: spawn, on animation finish?
// Note: spawn on animation finish could be added here
onBtnDownPrimary(() -> {
player.call("attack");

Expand Down
5 changes: 3 additions & 2 deletions fxgl-samples/src/main/java/sandbox/net/MultiplayerSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
import static javafx.scene.input.KeyCode.*;

/**
* TODO: graceful exit (via API)
* Sample demonstrating multiplayer networking.
* Note: graceful exit API is reserved for future implementation.
*
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
Expand Down Expand Up @@ -115,7 +116,7 @@ protected void initGame() {
isServer = answer;

if (isServer) {
// TODO: have only server init and only client init code to override
// Note: separate server-only and client-only init hooks could be added here

runOnce(() -> {
set("newVar", 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/**
* Sample for collisions in 3D space.
* TODO: not implemented
* Note: implementation is incomplete.
*
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import javafx.scene.layout.HBox;

/**
* // TODO: read-only version?
*
* @author Almas Baimagambetov (almaslvl@gmail.com)
*/
public class Point2DPropertyViewFactory implements PropertyViewFactory<Point2D, HBox> {
Expand Down
Loading