Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# wrapper #286

Open
Renari opened this issue May 2, 2024 · 6 comments
Open

C# wrapper #286

Renari opened this issue May 2, 2024 · 6 comments
Labels
enhancement New feature or request phantom camera Related to PhantomCamera nodes

Comments

@Renari
Copy link

Renari commented May 2, 2024

Project Type

2D, 3D

Feature Description

It would be nice if phantom camera included a C# wrapper to ease use with C#.

Use Cases

Currently to call phantom camera methods in C# you have to do something like this:

var cameraActive = (bool)GetNode("PhantomCamera2D").Call("is_active");

This is prone to causing runtime issues, for example if phantom camera changed the is_active method to active this would still compile but cause runtime issues.

(Optional) Proposed Solution

Better terrain could ship a C# wrapper that would prevent the above from happening.

One such example:
https://github.com/Portponky/better-terrain/blob/main/addons/better-terrain/BetterTerrain.cs

The above example could then be changed to:

var cameraActive = GetNode<PhantomCamera>("PhantomCamera2D").is_active();

Upon such an update where is_active is changed to active this would then cause a compile error, this also integrates better with IDE.

@ramokz
Copy link
Owner

ramokz commented May 2, 2024

This was also mentioned in this issue, so am exploring adding that in.

@ramokz ramokz added enhancement New feature or request phantom camera Related to PhantomCamera nodes labels May 6, 2024
@imbeingme
Copy link

imbeingme commented May 30, 2024

Having a C# wrapper that's similar to the one provided in BetterTerrain would be amazing.

The way I see it, it's similar to shipping a TypeScript definition file (aka .d.ts) on a JavaScript project.

@ramokz ramokz moved this to 💬 Requires More Thought in PhantomCamera Jun 3, 2024
@sci-comp
Copy link

sci-comp commented Jul 2, 2024

+1 to this idea!

The sample implementations provided by other users seems fine to me, it sounds much nicer than using Call, Get, and Set with silly magic strings scattered around.

I'm following along, so I'll be around to help test the new feature when it's ready!

@sircodemane
Copy link

@ramokz I have already started implementing something similar to this for my use case and I'd be willing to try contributing this feature if you're open to PRs.

The criteria I've followed for my implementation so far:

  • Follow Godot's C# code style
  • Use C# properties with getter setters to simplify the API
  • Follow Godot conventions (eg- SignalNameEventHandler, Method and Property name constants, etc)

@ramokz
Copy link
Owner

ramokz commented Jul 16, 2024

@sircodemane If you've started making a C# implementation, and happy to make a PR, then you're more than welcome to! Your criteria all sound sensible to me.

Was meaning to start looking at this proper after finishing up another feature, but it is taking longer than I had hoped… So any help with getting this in would be greatly appreciated.

@ramokz ramokz added this to the 0.7.4 milestone Jul 16, 2024
@sircodemane
Copy link

@ramokz I've opened a draft PR with the start of my efforts so you can take a look. I'll probably aim for 90% case for now and keep things fairly simple for this first pass. It's only the start of PCam3D currently but should give a good idea of the direction I'm taking it, let me know if I need to re-align.

sircodemane added a commit to sircodemane/phantom-camera that referenced this issue Jul 20, 2024
sircodemane added a commit to sircodemane/phantom-camera that referenced this issue Jul 23, 2024
- added Engine singleton registration to PhantomCameraManager
- fixed incorrect LookAtMode signal (not available in 2d)
- added c# project files
- created basic test runner and added some tests (wip)
sircodemane added a commit to sircodemane/phantom-camera that referenced this issue Jul 24, 2024
- fix several bugs from invalid getter/setters, properties, and types
- added more tests
- added LimitTarget query result type for working with TileMaps and CollisionShape2Ds
- reorganized scripts since main script file had become quite large
sircodemane added a commit to sircodemane/phantom-camera that referenced this issue Jul 25, 2024
- added missing shared camera properties
- added missing phantom camera 2d properties
- added missing phantom camera 3d properties
@ramokz ramokz removed this from the 0.7.4 milestone Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request phantom camera Related to PhantomCamera nodes
Projects
Status: 💬 Requires More Thought
Development

No branches or pull requests

5 participants