News for hackers. Stuff that matters.
Re:Introducing C# in Godot by Arnavion on Saturday October 21, 2017 @10:26PM (#15524816)
Note to the author: Since you specifically point out that C# 7.0 is supported, this example:

    if (ev is InputEventMouse)
    {
        var mouseEvent = (InputEventMouse)ev;
        Vector2 mousePos = mouseEvent.Position;
    }
    else if (ev is InputEventKey)
    {
        var keyEvent = (InputEventKey)ev;
        bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
    }
would be better written as:

    switch (ev)
    {
        case InputEventMouse mouseEvent:
            Vector2 mousePos = mouseEvent.Position;
            break;

        case InputEventKey keyEvent:
            bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
            break;
    }
Re:Introducing C# in Godot by tonyedgecombe on Sunday October 22, 2017 @06:56AM (#15526152)
Or:

    if (ev is InputEventMouse mouseEvent)
    {
        Vector2 mousePos = mouseEvent.Position;
    }
    else if (ev is InputEventKey keyEvent)
    {
        bool aPressed = keyEvent.Pressed && keyEvent.Scancode == GD.KEY_A;
    }
Re:Introducing C# in Godot by knocte on Sunday October 22, 2017 @04:21AM (#15525740)
I think switch blocks are only worth it when you have 2 or more `else if`, otherwise a normal `if` is more readable IMHO.
Re:Introducing C# in Godot by n4r9 on Sunday October 22, 2017 @04:44AM (#15525780)
Normally I'd agree, but I really like the concise but readable way this handles the casting for you.
Re:Introducing C# in Godot by andybak on Sunday October 22, 2017 @06:02AM (#15525968)
It might be if they used the One True Brace style ;)
Re:Introducing C# in Godot by apk-d on Sunday October 22, 2017 @03:54AM (#15525680)
This is fantastic! This actually puts the engine ahead of Unity in terms of scripting since those guys target a rather outdated version of C#/Mono. Now I can't wait to play around with Godot.

(Modern) C# is my favorite language, but I've been looking into F# recently. Wonder if someday that might be an option in Godot as well. Given how both languages compile to the same binary format, there have been workarounds to use it in Unity even though it's not officially supported.

Re:Introducing C# in Godot by sebazzz on Sunday October 22, 2017 @04:46AM (#15525786)
I believe Unity was investigating embedding the .NET Core runtime instead, for performance gains due to a better GC and better JIT.

Therefore I find it very odd they chose to use the Mono runtime. It sounds to me the .NET Core runtime is a much better choice, since the underlying CLR is in the basis the same as the .NET Framework CLR, including the Ryujit and all the other goodies.

Re:Introducing C# in Godot by pjmlp on Sunday October 22, 2017 @09:34AM (#15526752)
Unity targets many systems where .NET Core doesn't exist, e.g. games console.

Mono is only used in some targets, they actually compile to native code via IL2CPP for production deployment.

Re:Introducing C# in Godot by pjmlp on Sunday October 22, 2017 @09:33AM (#15526746)
Unity compiles C# to actual native code via IL2CPP, Godot doesn't do it, as far as I can understand it.

The Unity is already supporting 4.6 on its beta version.

Re:Introducing C# in Godot by SugoiDev on Sunday October 22, 2017 @10:28AM (#15526977)
4.6 is supported on all versions after 2017.1, but it is still labeled as experimental and not enabled by default.
Re:Introducing C# in Godot by j_s on Saturday October 21, 2017 @11:06PM (#15524960)
There was a lot of excitement about C# support coming in v3.0 back in last month's discussion:

Godot Engine – Free and open-source 2D and 3D game engine | https://news.ycombinator.com/item?id=15523416 (Sep 2017, 131 comments)

Re:Introducing C# in Godot by Yuioup on Sunday October 22, 2017 @02:47AM (#15525496)
I think your links goes to this post.
Re:Introducing C# in Godot by j_s on Sunday October 22, 2017 @01:49PM (#15527975)
Doh! Thanks for letting me know.

https://news.ycombinator.com/item?id=15309989

Re:Introducing C# in Godot by Rapzid on Saturday October 21, 2017 @10:36PM (#15524846)
Nuget support would be amazing..
Re:Introducing C# in Godot by crudfactory on Saturday October 21, 2017 @11:33PM (#15525039)
Can I build/use future Godot releases without any mono/microsoft dependencies?

I notice the post reveals ms has funded the project now. I hope Godot doesn't owe ms any favours..

Re:Introducing C# in Godot by giancarlostoro on Saturday October 21, 2017 @11:50PM (#15525074)
You don't have to use the C# features of Godot. You can still use GDScript to code your game in, or GDNative with any extending language like D, Go, or Rust, so long as you find bindings for them. I wouldn't worry about Microsoft being owed favors, I'd worry more about actual licensing, and if it wasn't for Microsoft (or so I suspect) Mono would still not be as openly licensed as it is now[0].

[0]: http://www.mono-project.com/news/2016/03/31/mono-relicensed-...

Note how Microsoft was mentioned for their license change (why would that be if Microsoft had nothing to do with the change, wondering if buying out Xamarin gave them power over making Mono more open), and it was announced at the annual big Microsoft event no less. I'm all for yelling at Microsoft when they screw up, but they're doing good things with .NET and C#.

Re:Introducing C# in Godot by Mikeb85 on Sunday October 22, 2017 @12:02AM (#15525102)
> Can I build/use future Godot releases without any mono/microsoft dependencies?

Yes, the standard build doesn't make use of the C# module.

Re:Introducing C# in Godot by mappu on Saturday October 21, 2017 @10:30PM (#15524828)
>As of alpha2, Godot is using Mono 5.2 and C# 7.0 is supported.

This is an explicit dig at Unity, which is still(?) on Mono 2.x and C# 3.5 owing to their custom IL2CPP toolchain (with Mono 4.x / C# 6 in beta for the editor only).

Re:Introducing C# in Godot by WillPostForFood on Saturday October 21, 2017 @10:43PM (#15524871)
It is a valid bragging point for Godot that probably doesn't have much to do with Unity which had been trapped in an old version of mono for licensing reasons (not because of the toolchain - it was the other way around). Unity has been able to start updating now that Microsoft opened up and bought Xamarin), and is now offering Mono/.Net 4.6 and C#6 and I assume will continue to modernize.
Re:Introducing C# in Godot by pjmlp on Sunday October 22, 2017 @09:36AM (#15526756)
It wasn't licensing reasons but monetary ones, rather Unity did not want to pay Xamarin what they asked for.
Re:Introducing C# in Godot by WillPostForFood on Monday October 23, 2017 @04:43AM (#15531672)
Same difference - they had a license for an old version and didn't want to pay to upgrade.
Re:Introducing C# in Godot by jasonkostempski on Saturday October 21, 2017 @10:27PM (#15524820)
Is Mono not dying due to .NET core? It seems to be popping up in a few new places but I would have thought new projects would be avoiding it.

The last thing I want is any dependency on MS tooling as they've shown everything they release will include telemetry. I'm just getting started with game dev and I really like Godot, but if the future is going to require MS anything, I'm going to jump ship.

Re:Introducing C# in Godot by kevingadd on Saturday October 21, 2017 @10:50PM (#15524893)
Mono is still supported. .NET core and Mono solve different problems - for example (this surprised me), unlike Mono and the windows .NET Framework, .NET core can't just run random .NET executables you download off the internet. You have to build a core-targeted project from source. Mono also handles cross-platform scenarios like mobile & mac frontend apps right now that .NET core won't be a good fit for in the near future.
Re:Introducing C# in Godot by cptskippy on Sunday October 22, 2017 @01:47AM (#15525348)
Mono, .NET Framework, .NET Core, Xamarin.<Platform>, etc are all just different implementations of .NET Standard. I believe .NET Framework is a superset of Core.

They can all run code targeted at Standard but all have slightly different libraries on top of Standard. Mono was originally was intended to be a cross platform stand-in for .NET Framework which is why they can mostly run the same code. I believe Mono and Framework are slowly merging together.

Re:Introducing C# in Godot by AdeptusAquinas on Sunday October 22, 2017 @03:59AM (#15525689)
I don't think this is true. Framework for example can only reference standard libraries as of 4.6.2. Up until dotnet core 2.0, core was very much an incompatibile subset of framework - even with 2.0 it would be better characterised as a cross platform rewrite of the net framework.
Re:Introducing C# in Godot by pjmlp on Sunday October 22, 2017 @09:37AM (#15526760)
Actually .NET Standard 2.0 requires .NET 4.6.1.

.NET 4.6.2 was only for .NET Standard 1.0, but they realised basing on 4.6.1 would be a more sensible decision and fixed it in version 2.0.

Re:Introducing C# in Godot by Rapzid on Saturday October 21, 2017 @10:34PM (#15524841)
I have bad news for you; Mono 5.0 launched with Roslyn which I believe is what brings C#7 support. Roslyn is of course a MS project. Ditto for MSBUILD.
Re:Introducing C# in Godot by jasonkostempski on Sunday October 22, 2017 @09:47AM (#15526805)
So will installing a version of Godot that supports C# get me something reporting back to MS out of the box?