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

Example Scene to use static typing #54

Closed
TheYellowArchitect opened this issue Dec 9, 2023 · 3 comments
Closed

Example Scene to use static typing #54

TheYellowArchitect opened this issue Dec 9, 2023 · 3 comments

Comments

@TheYellowArchitect
Copy link

I know there will be a new example scene in the future, but I was curious of the setup of current version. It's kinda hard to read for a first-time user (since all nodes have a script attached, even though the script has no logic), but what I want to mention in this issue is that there are function calls which do not point anywhere and are dynamically cast.

On the FSMState "TransformIntoGhost" there is the code

func _on_enter(actor: Node, _blackboard: Blackboard):
	# Make Transparent
	actor.set_modulate(Color(1, 1, 1, 0.5))
	actor.ghost_state_machine.fire_event("fully_transformed")

I cannot ctrl+click set_modulate either.

func _on_enter(actor: Node, _blackboard: Blackboard):
	# Make Transparent
	(actor as Actor).set_modulate(Color(1, 1, 1, 0.5))
	(actor as Actor).ghost_state_machine.fire_event("fully_transformed")

The above is more intuitive imo, and its a codestyle I suggest for the future example scene. After all, the example scene is what convinces a developer whether to use or not

@ThePat02
Copy link
Owner

ThePat02 commented Dec 9, 2023

It's kinda hard to read for a first-time user

Yes, I totally agree, that that the current example scene needs some work. It functions as some crude kind of testing and regression-catching device, as it uses most of the new nodes. I am hoping to get some simpler examples in for the next big release.

[...] but what I want to mention in this issue is that there are function calls which do not point anywhere and are dynamically cast. [...] I cannot ctrl+click set_modulate either.

This is a good point, however I think using something like (actor as Actor) can become really tiresome and exhausting to write and read. What do you think of something like this?

## Executes after the state is entered.
func _on_enter(actor: Node, _blackboard: Blackboard):
	# Cast to Actor
	actor = actor as Actor
	
	# Make Transparent
	actor.set_modulate(Color(1, 1, 1, 0.5))
	actor.ghost_state_machine.fire_event("fully_transformed")

@TheYellowArchitect
Copy link
Author

definitely cleaner, I feel dumb for not having thought of it hahaha

@ThePat02
Copy link
Owner

definitely cleaner, I feel dumb for not having thought of it hahaha

I will close this issue for now, even tho I won't update the current example scene, as there already is a new one on the way (#55). You are VERY WELCOME to contribute your own examples to the 2.0.0 branch if you find that your testing could help others understand the plugin in a better way!

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

No branches or pull requests

2 participants