cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
696 stars 272 forks source link

Allow both ends of jumper cables to connect to #1189

Open chaosvolt opened 2 years ago

chaosvolt commented 2 years ago

Is your feature request related to a problem? Please describe.

One minor hiccup to connecting the power grid of two separate mapgens is that the use action for jumper cables only allows connecting to a jumper cable connector on the second use.

That is, the first activation to attach the first end only permits attaching to vehicles, attempting to connect it to a jumper cable connector only gives you "there's no vehicle there" and does nothing. Instead you can only attach it to a connector via the second activation of the cable, to connect the other end.

The net consequence of this is that connecting two areas requires two jumper cable connectors plus a vehicle, instead of just the two connectors.

Describe the solution you'd like

Changing the first activation to consider jumper cable connectors as valid attachment points, like the second activation does, would hopefully fix this. Assuming there aren't any weird behaviors making it so it always has to be clamped onto a vehicle first, I've yet to look at the code for it to see for myself.

Describe alternatives you've considered

  1. Adding a construction that can automatically create a grid connection might technically be a better option than using jumper cable connectors at all, and allow for an additional way to have locations start with connections without having to be a city_building and without an entire overmap special being gridified, but I have no idea how complex that'd be to implement.
  2. Increasingly aggressive use of the grid flag for just about every overmap special that has anything with a roof might also reduce the need for this, but no idea what the performance impact would be. Especially for big enough places like labs, military bases, industrial centers, the refugee center...
Coolthulhu commented 2 years ago

The reason a vehicle is required is mostly due to cable target handling. The connector doesn't have any knowledge of the cable used to connect it to the vehicle, but the vehicle has the whole item. The other, easier to fix part is that the connector currently uses a very dirty hack: it finds its first vehicle and then has the first vehicle start the actual vehicle+grid graph traversal.

Adding a construction that can automatically create a grid connection

I'd rather go this way first. Ideally, the cost would depend on things like number of tiles in the grid and whether the tile is "wired up" in some way, but a static cost of say, 30 copper wire + 1 power connector per overmap tile connection (paid once for two neighbors, not twice) would be fine.

Say, you want to connect a tile adjacent to house at ground level:

The biggest problem is UI. Grids are very "opaque" to the player right now. I have some ideas, like asking the player to confirm building the first grid-requiring tile on an overmap tile with no connections, having the overmap tile + connected neighbors "blink" when in some grid-detecting-mode, giving the player a whole summary of a given grid and so on, but nothing of it is implemented. At the moment, only @olanti-p 's debug UI and voltimeter are available. Plus player metagame knowledge.

no idea what the performance impact would be

Per turn cost depends on number of grid elements, not counting overmap tiles. Empty grids with only idle stuff only have on-load cost, but that is paid every time map shifts, so every time player changes a submap.

chaosvolt commented 2 years ago

Makes sense then, so trying to implement the alternative might be a better start. Whichever seems more appropriate, and whenever time is available for such. Plenty to work on as it is lately.