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

Signals? #4

Open
Violet-Scarelli opened this issue Mar 13, 2024 · 2 comments
Open

Signals? #4

Violet-Scarelli opened this issue Mar 13, 2024 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@Violet-Scarelli
Copy link

Any chance we could get a native implementation of signals/chain signals?

@moonbench
Copy link
Owner

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 🤔

@moonbench moonbench added this to the Signals milestone Mar 13, 2024
@moonbench moonbench added the enhancement New feature or request label Mar 14, 2024
@red15
Copy link

red15 commented Oct 29, 2024

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

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

No branches or pull requests

3 participants