simple-godot-train
simple-godot-train copied to clipboard
Signals?
Any chance we could get a native implementation of signals/chain signals?
I'd support that idea. Honestly, it sounds like a lot of fun!
Hm, I think it'd be required to first implement multiple trains being able to exist on the same rail network (I've never really tested that with this project). Then there would need to be some sort of concept of "blocks" of track, and the ability to determine if there's a train within a block. Then signals could probably be added to have effects :thinking:
Then there would need to be some sort of concept of "blocks" of track, and the ability to determine if there's a train within a block.
Each track object already is a block, only when 2 "simple" tracks are linked without a switch would it mean you need to handle some special "joining" the two (or more) paths into a single block. Each switch would separate (at least) two blocks.
- Iterate Tracks
- Call method
Track.add_to_block(None)
- If track has block: return
- Create new block if argument was None
- Add current track to array inside of block
- Check if head has track or switch
- if a switch, skip
- if track call `Track.add_to_block(self.block)
- same for tail connection
As for finding if a train is inside a block: From switch -> head/left_track/right_track -> block -> loop tracks -> track.get_children() (like you do in _has_bogies_on))
Edit: quick and dirty implementation: https://github.com/red15/simple-godot-train/tree/track_block