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

Difficult to work with Area2D/PhysicsBody2D in C# due to duplicated code in Godot Engine #26680

Closed
Tracked by #45334
JarLowrey opened this issue Mar 6, 2019 · 1 comment · Fixed by #42770
Closed
Tracked by #45334

Comments

@JarLowrey
Copy link

JarLowrey commented Mar 6, 2019

Godot version:

3.0.6

Issue description:

I have a situation where a node could be an Area2D or a PhysicsBody2D. These two classes each individually implement collision_layer and collision_mask, even though they are the only children of their direct parent, CollisionLayer2D. This is fine for GDScript, but causes issues in a compiled language like C#.

Looking at the code for Area2D and PhysicsBody2D, it looks like the getters/setters are pretty much identical. Can this logic be refactored out to their shared parent? Removing duplicated code would also improve the maintainability of the engine.

@JarLowrey JarLowrey changed the title Difficult to work with Area2D/PhysicsBody2D in C# due to duplicated code Difficult to work with Area2D/PhysicsBody2D in C# due to duplicated code in Godot Engine Mar 6, 2019
@neikeq
Copy link
Contributor

neikeq commented Mar 9, 2019

Removing the topic:mono label as this is an issue with the Godot API. What is proposed here is for CollisionLayer2D to declare collision_layer and collision_mask, instead of doing that in their two derived classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants