Well, what i'm trying to do is determine if objects in a list are still "connected" to one another.
What i'm doing is allowing players to connect objects together in game, example: someone builds a wall 10 tiles long, every object in that wall is now in each others "ANCHOR_GROUP" to form a list of all the tiles that make up that particular wall, or whatever structure they are building.
Now if the center of the wall gets destroyed, how would i determine how to rebuild the remaining objects ANCHOR_GROUP lists based on what objects are still connected to each other ?
I hope that's not too confusing haha, i'm really bad at describing things.
ID:2344009
Feb 7 2018, 8:09 pm
|
|
Feb 7 2018, 8:37 pm
|
|
Since lists are passed by reference (they're objects), you can give every wall a reference to the same list of tiles. You don't need to rebuild the list; simply remove the destroyed structure from the list, and every structure connected to it will see that it's gone (because they're all seeing the same list). The list doesn't live on any single structure.
|
Hey thanks for the reply, that's actually almost exactly how i was building the list (connecting), i tried what you laid out for disconnecting but it doesn't accomplish what I'm trying to do. If i break the middle tile of a row of 10 tiles, the end tiles still register as being in each others connections lists. Example, if i break the middle (5th) tile out of the row of 10 tiles, the end tiles are still in each others connections list even though there is no tile connecting them anymore, basically i want the wall to become two walls, is that possible to do?
|
In response to MightyMonte88
|
|
Oh, okay. You should probably look into flood-fill algorithms, then, as I'm not sure of a simple way to tell if a single wall tile is a bridge between two otherwise disconnected groups.
Here's one library that uses flood-fill to give you connected regions: http://www.byond.com/developer/Theodis/Region |
Hey thanks for all the help man , i really appreciate it. I very rarely use the forum, I've actually been a byond member since 2001 but have since then lost access to my original key names, the project i'm working on is one I've been working on for years now, and i believe i'm finally close to a playable state but this has been something that's stumped me for the longest time.
|