KoBeWi / Metroidvania-System

General-purpose framework for creating metroidvania games in Godot.
https://godotengine.org/asset-library/asset/2301
MIT License
1.09k stars 53 forks source link

Persist assigned scene after map edit #36

Open poohcom1 opened 9 months ago

poohcom1 commented 9 months ago

As mentioned in the README, currently any modifications to rooms in the Map Editor will remove assigned scenes. I think having some basic scene persistence will be a good QOL improvement, especially for devs who edits their room often.

Since there's a lot of ambiguity of how to maintain assigned scene when editing cells, I have an outline for how the assign scene can be determined after a map edit. The gist of it is to try to maintain assigned scene even when there is ambiguity based on a few factors, to make it as seamless as possible.

Cells Removed

Cells Moved

Cells Added

An alternative, simpler to implement system could also be to only maintain assigned scene when there is no ambiguity, and clear the scene otherwise. I haven't looked into the Map Editor code yet, so that could be a factor on how difficult this is to implement.

Let me know what you think.

KoBeWi commented 9 months ago

The reason scene is removed is a technical one. The rooms need to maintain consistency, that is a room may have a single scene assigned and each scene can be assigned only to up to one room.

If any room is split into multiple parts, have a consistent logic to determine how to keep the assigned scene (like always favor the assigned scene of the top-left-most cells).

I'd first need to determine that new rooms were created, which currently is not tracked.

Cells Moved

If you mean drag and drop, it should already retain the scenes. It's impossible to change room composition by dragging them, so there are no problems here.

If any room is expanded, keep the assigned scene.

Like in the first case, I'd have to detect that a room is being expanded and it does not interest with any other room.

if you start drawing a line from Room A to Room B into a single large room, the logic will assume that the combined new room is Room A.

That sounds complicated to do >_>

I may look into what you suggested, but no promises here. The code for assign management is already complex, and I didn't want to complicate it even more.

poohcom1 commented 9 months ago

Thanks for the clarification, I was also wondering if there were other technical reasons for this limitation. Wasn't aware rooms are retained when cells are dragged; that was one of the main things I wanted since I was planning on moving a large chunk of my map, so that should already address half of this.