Create and expose the method `get_collider_rid` in `RayCast2D` and `Raycast3D`.
This method returns the `RID` of the first object that the ray intersects, or an empty `RID` if no object is intersecting the fay (i.e. `is_colliding` returns `false`).
- Moves interop functions to UnmanagedCallbacks struct that
contains the function pointers and is passed to C#.
- Implements UnmanagedCallbacksGenerator, a C# source generator that
generates the UnmanagedCallbacks struct in C# and the body for the
NativeFuncs methods (their implementation just calls the function
pointer in the UnmanagedCallbacks). The generated methods are needed
because .NET pins byref parameters of native calls, even if they are
'ref struct's, which don't need pinning. The generated methods use
`Unsafe.AsPointer` so that we can benefit from byref parameters
without suffering overhead of pinning.
Co-authored-by: Raul Santos <raulsntos@gmail.com>
We were using it to workaround a limitation of `Unsafe.AsPointer` and
`ref struct`s. However, we can get the same result with some tricks,
since we have control over the declaration of these structs.
The setting is initially assigned the name of the Godot project,
but it's kept freezed to prevent issues when renaming the Godot
project.
The user can always rename the C# project and solution manually and
change the setting to the new name.
This new version does not support the following type arguments:
- Generic types
- Array of Godot Object (Godot.Object[]) or derived types
The new implementation uses delegate pointers to call the Variant
conversion methods. We do type checking only once in the static
constructor to get the conversion delegates.
Now, we no longer need to do type checking every time, and we no
longer have to box value types.
This is the best implementation I could come up with, as C# generics
don't support anything similar to C++ template specializations.
- Array and Dictionary now store `Variant` instead of `System.Object`.
- Removed generic Array and Dictionary.
They cause too much issues, heavily relying on reflection and
very limited by the lack of a generic specialization.
- Removed support for non-Godot collections.
Support for them also relied heavily on reflection for marshaling.
Support for them will likely be re-introduced in the future, but
it will have to rely on source generators instead of reflection.
- Reduced our use of reflection.
The remaining usages will be moved to source generators soon.
The only usage that I'm not sure yet how to replace is dynamic
invocation of delegates.
Changed the signal declaration signal to:
```
// The following generates a MySignal event
[Signal] public delegate void MySignalEventHandler(int param);
```