A C# update

Moderator: LukasPJ

5 posts Page 1 of 1
LukasPJ
Site Admin
Posts: 426
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Wed Oct 09, 2019 9:28 pm
Hello everyone,

Progress is slow, but I have made some updates to the C# stuff.

Where to try T3D.net
I have a spectatorGameplay implementation in C# at this repository: https://github.com/lukaspj/T3D.Net-BaseGame
The repository contains pre-compiled Torque3D as well as .sln and .csproj files which should work, but there might be some paths wrong etc.

The pre-compiled version of Torque3D uses the branch from this PR:
https://github.com/GarageGames/Torque3D/pull/2366


Quick intro
The repository has 3 folders:
  • BaseGame
  • GameCore
  • T3DNetFramework
The GameCore folder contains a typical Torque3D project, with scripts, assets, binaries.

The T3DNetFramework folder contains a library which is used for the interop layer between T3D and C#.

The BaseGame folder contains the C# game project, with a C# implementation of the SpectatorGameplay scripts.

The whole thing is unpolished, but I'm happy to answer any questions here or in Discord.

How can I help?
If anyone wants to help me on the project, please just download the C# project and muck about in it. Find bugs, or stuff you think has a weird syntax or functionalities that are missing.


What is the current feature set?
The C# implementation currently has:
  • The full ConsoleObject class-hierarchy generated as C# classes.
  • Full, statically typed interop on all function calls from C# to T3D
  • Full interoperability with TorqueScript
  • Stringly typed interop on all function calls from T3D to C#, with reflection-based conversion of parameters
  • Stringly typed property accessors
  • API documentation exported from the EngineAPI
Differences between TorqueScript and C#
The primary difference is type-safety, if the underlying T3D function requires a float, you have to pass a float. Not a string or int.

All Global ConsoleFunctions are prefixed with Global.

You have to "register" SimObjects (similar to how it's done on the C++ side). As an example see the VolumetricFog class:
https://github.com/lukaspj/T3D.Net-Base ... Fog.cs#L60

As an example this TorqueScript:
   if (isObject(LevelFilesList))
   {
      for ( %file = findFirstFile( "data/spectatorGameplay/levels/*.mis" );
            %file !$= "";
            %file = findNextFile( "data/spectatorGameplay/levels/*.mis" ))
      {
         LevelFilesList.add(%file);
      }
   }
Becomes this C#:
         if (Global.IsObject("LevelFilesList")) 
         {
            for (string file = Global.FindFirstFile("data/spectatorGameplay/levels/*.mis");
                        file != "";
                        file = Global.FindNextFile("data/spectatorGameplay/levels/*.mis")) 
            {
               Core.SimObjects.Collections.LevelFilesList.Add(file);
            }
         }
Global variables has to be accessed via a function instead of via the dollar-sign thingy:
Global.SetConsoleString("Game::DefaultCameraClass", "Camera");
Global.GetConsoleString("Game::DefaultCameraClass");
And dynamic fields has to be accessed via a method as well:
client.SetFieldValue("camera", camId.ToString());
client.GetFieldValue("camera");
noemen
Posts: 61
Joined: Tue May 29, 2018 3:46 pm
 
by noemen » Fri Oct 11, 2019 7:39 pm
Very good, I liked it. I don't know C #, but I support language diversification support. This makes the artist's life easier, continue with his wonderful work. Now I will learn C # because I have a reason. lol
LukasPJ
Site Admin
Posts: 426
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Tue Oct 15, 2019 1:45 pm
Thank you very much @ noemen :)

I hope that the C# project at the very least can serve as a template for how people can integrate external runtimes / languages to the engine. The principle techniques are actually very simple, so it should be a nice step forward!
LukasPJ
Site Admin
Posts: 426
Joined: Tue Feb 03, 2015 7:25 pm
 
by LukasPJ » Wed Oct 16, 2019 3:49 am
More updates!

The generator has been updated with a new templating engine and more edge-case handling:
https://github.com/lukaspj/T3DSharp

Should be much easier to get up-and-running with now for anyone who wants to look into it at some point.(Albeit still far from "pretty")

Code documentation!
I have extended the Generator with the capability to convert Torque3D's internal doxygen-based comments to C#'s XML comment language.

https://github.com/lukaspj/T3D.Net-Base ... #L628-L647

So now you can get that API documentation directly in your IDE!
noemen
Posts: 61
Joined: Tue May 29, 2018 3:46 pm
 
by noemen » Fri Oct 18, 2019 12:10 am
More updates!

The generator has been updated with a new templating engine and more edge-case handling:
https://github.com/lukaspj/T3DSharp

Should be much easier to get up-and-running with now for anyone who wants to look into it at some point.(Albeit still far from "pretty")

Code documentation!
I have extended the Generator with the capability to convert Torque3D's internal doxygen-based comments to C#'s XML comment language.

https://github.com/lukaspj/T3D.Net-Base ... #L628-L647

So now you can get that API documentation directly in your IDE!
I'm studying the c#, in the future I will support you in this wonderful project.
In 2 months or more I will be ready.
5 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 0 guests