superpowers / superpowers-game

:video_game: Make 2D and 3D games in live collaboration with Superpowers
http://superpowers-html5.com/
Other
402 stars 93 forks source link

Adding Behavior To Actor and then Changing Name of Behavior Script Causes Errors #134

Open rtizzy opened 8 years ago

rtizzy commented 8 years ago

As described:

  1. Create an actor
  2. create a class
  3. add a behavior to the actor and assign the class
  4. Change the name of the class.
  5. Run the game and it will error out.

Removing the behavior and re-adding it will properly update the name of the class under the behavior tab. .

elisee commented 8 years ago

Hi and thanks for the report!

There can be multiple behavior classes per script so there's no reliable way to know that some text change in a script was a rename of a particular class.

In the long run, it would be nice to have support for intelligent TypeScript refactoring (press F2 to rename a class, etc.) and in that case, we could detect that the class is being renamed and update behavior components accordingly.

Another thing we've wanted to add at some point is to report errors such as a missing behavior class before running the game in an error pane, so that you don't have to discover those at runtime.

rtizzy commented 8 years ago

@elisee

Possible solution for at least this problem:

Make the panel where you assign behavior automatically refresh it's entire list (as if it was removed and re-added).

  1. On click determine if any files were changed.
  2. If files were changed check if there are new names and if all old names exist.
  3. Add new names remove old names that no longer exist.
elisee commented 8 years ago

The issue is not with the UI, we just can't equate a change in a script's text with a rename of a class. I've outlined a couple avenues for fixing this: either we could make an exception for scripts with a single behavior class in them, or we should implement TypeScript refactoring support.