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

Shielded cables : Add Shielded LV cables and Shielded APC that only powers objects on top of them #2025

Closed

Conversation

spacedwarf14
Copy link
Contributor

@spacedwarf14 spacedwarf14 commented Sep 17, 2024

About the PR

(90% finished, so this is the bulk of the PR and I think ready for feedback. See TODO)

This PR introduces shielded LV cables and a shielded APC. Normal LV cables power objects up to 3 tiles away from the cable. shielded LV cables only power the objects on top of them. The Shielded APCs will not power any neighboring entities, either.

To make this work flexibly, I decided to introduce the Shielded LV cables as a separate network from the normal LV cables. This way, they don't connect to each other, and they can both be laid on the same tile. As a result, I made modification to the power monitor and some components (electrified, powerprovider) to accommodate using the new cable network.

Since LV and Shielded LV cables can be placed on the same tile, I added a rule to the provider selection mechanism to prioritize selecting the shielded cable if it is underneath, regardless of any other LV cables in the vicinity. This lets the player de-select objects from normal LV networks by placing the shielded lv cable underneath it. A separate circuit can then be made that only powers airlocks, for instance, without the airlock being affected by LV cables that are routed underneath them for other reasons. Turning off science should no longer affect your ability to move around!

This PR introduces the following specific changes:

  • Shielded LV cables as a separate network (they will not connect to normal LV cables)
  • Shielded APCs specialized for shielded lv cables. like the shielded cables, shielded APCs do not provide power at a distance
  • Power Monitor modifications to draw the Shielded LV network
  • art (WIP)
  • random spawn, supply and recipe prototypes
  • Component modifications to electrifiable and powerswitchable to support shielded cables

I tried to make the code changes as minimal as necessary. I also avoided, to my knowledge so far, changing the default rules for provider and receiver selection; I did append one rule that I mentioned above that should only affect networks where shielded LV cables are explicitly laid down.

In order to treat the Shielded LV networks as a separate power network, it had to be mapped as its own "voltage" which in-turn has a matching nodeGroupID. This enables setting up a shielded APC prototype to provide power to a shielded cable and prevents the shielded cables from connecting to any other network. These are mostly field / enum additions and adding cases to handle the new cables (identically to LV cables, basically).

The ExtensionCableSystem is modified slightly so that receivers prioritize shielded cables placed underneath, regardless of the presence of normal LV cables.

The power monitor allocates another line array for selecting and drawing the shielded APC network, sizes and enums adjusted accordingly.

Cases to handle Shielded APC have been added to ElectrocutionSystem, and PowerSwitchable systems.

I still need to tweak a few things, TODO:

  • sprites need to be re-aligned, there are gaps after shifting their XY positions (so that they show on the tiles w/ normal LV cables) (probably just copy the pixels to the gaps)
  • power monitor line alignment
  • guidebook entry
  • Shielded APC sprite (magenta stripes?)
  • stretch goal: Maybe some way to make it clear which networks power receivers are connected to
  • maybe change materials used for insulated wire
  • maybe make a recipe to turn insulated cable into normal cable and back

Why / Balance

There's are at least two distinct ways to look at an APC:

  • The APCs are /spatially oriented/: they will turn off everything in the vicinity, defaulting to 3 tiles away
  • The APC are /functionally oriented/: they will turn off everything related to a function

Extended range for power systems made sense in vanilla SS14, where gameplay takes place in large space. Corridors >= 3 tiles wide, big rooms that corresponded to their functions (science, engineering, bar, etc). This means that it was easy to have the function of the power systems that the APC affect map to the space in-which they occupied. That is, because rooms were separated enough from each-other, it wasn't really much of a thought about whether APCs were functionally oriented or spatially oriented -- the space was the function, allowed for the functions to coexist with the ranges that are expected by power receivers and providers.

FS14 typically takes place in smaller spaces, which means it is more difficult to make the APCs functional. There are tradeoffs between the ship layout and the functions an APC affects. In an example situation, that means that if you want to turn off science, you end up turning off airlocks and occasionally some thrusters. Almost every ship I've played on has an issue like this -- and if you /try/ to make the APCs functional, you end up with ridiculous wiring schemes and room extensions just to prevent entities from connecting to things 2 tiles away. I've spend many hours on a ship to try to make this possible.

FS14 also introduces fuel requirements on tighter supply cycles, so there's more of an incentive to shut down an unused part of the ship in order to reduce fuel consumption.

There was some brief discussion on discord about whether cable selectivity was a problem, but no discussion about whether this is an entity worth introducing. This shouldn't affect the gameplay if a player wants to stick to the default behavior. I started doing this to learn how my favorite game works, and to recover from some programming burnout. If this PR is merged, I will make a map that takes advantage of shielded cables.

How to test

Spawn a map; manufacture some shielded cable, place a shielded APC construction ghost, build; connect shielded cable to it, make network, place power consumer (power monitor).

When there are neighboring LV providers, a power receiver entity anchored on top of an existing Shielded LV cable will always select it as the provider. If a cable is placed under a receiver which already has a provider, the receiver will remain connected to that provider until it is re-anchored on top of the shielded LV cable. This is actually default behavior that you can observe with LV cables as well.

Media

Shielded LV Cable on tile (I will fix the gap soon)
2024-09-16-193801_302x320_scrot

etc:
2024-09-16-194034_836x388_scrot
2024-09-16-194114_374x229_scrot
2024-09-16-194000_1368x1209_scrot

description (TODO change color of "Shielded LV Cable")`
2024-09-16-193822_406x252_scrot

Requirements

  • I have read and I am following the Pull Request Guidelines. I understand that not doing so may get my pr closed at maintainer’s discretion
  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

The changes are mostly additive, to support the shielded lv network, and should not change how existing cases are handled. The most significant change I would say is the addition to the TryFindAvailableProvider, which is optional but makes the shielded cables more useful.

Changelog

🆑

  • add: Added Shielded LV Cables and Shielded APC. Unlike normal LV cables and APCs, Shielded power network components only power object on top of them and cannot power objects on neighboring tiles. If an LV and a Shielded LV cable is placed before an object is anchored on top of it, the Shielded LV cable will always be used as the power provider. Now you can build an Airlock APC! They are also less likely to routinely cause cancer. Note: You can't connect a normal LV cable to a shielded APC and vice versa.

spacedwarf14 added 9 commits September 16, 2024 19:56
Shielded cables create a fourth type of cable network. Shielded lv cables will not connect to normal lv cables, and will furthermore require a shielded APC. Otherwise shielded cables work on anything with an extensioncablereceivercomponent on the same tile.
Make it so that if both an lv and shielded cable are underneath the receiver, the shielded cable is always selected as the provider. This also breaks the entity check loop early.
(TODO: Make APCShieldedFrame inherit from APCFrame instead of copying the parameters)
@spacedwarf14 spacedwarf14 changed the title Shielded cables : LV cables and APC that only powers objects on top of them Shielded cables : Add Shielded LV cables and Shielded APC that only powers objects on top of them Sep 17, 2024
Copy link
Contributor

github-actions bot commented Sep 17, 2024

RSI Diff Bot; head commit 45d8c52 merging into 28c27e2
This PR makes changes to 1 or more RSIs. Here is a summary of all changes:

Resources/Textures/Objects/Tools/cable-coils.rsi

State Old New Status
coilsh-10 Added
coilsh-20 Added
coilsh-30 Added
coilsh-equipped-BELT Added
coilsh-inhand-left Added
coilsh-inhand-right Added

Resources/Textures/_NF/Structures/Power/Cables/sh_cable.rsi

State Old New Status
shcable_0 Added
shcable_1 Added
shcable_10 Added
shcable_11 Added
shcable_12 Added
shcable_13 Added
shcable_14 Added
shcable_15 Added
shcable_2 Added
shcable_3 Added
shcable_4 Added
shcable_5 Added
shcable_6 Added
shcable_7 Added
shcable_8 Added
shcable_9 Added

Edit: diff updated after 45d8c52

@Cheackraze
Copy link
Member

Not really a fan of making changes like this to power systems, especially since I feel power is already needlessly over-complicated. On an ideal world, we would drop lv cables altogether and just have apc's have a larger power broadcast. The 3 existing cable types and power conversion is already too complicated of a system for our use case on frontier.

The real solution to your specific use case you outlined would be to implement power switch verbs onto machines that don't have them to turn them off individually

@spacedwarf14
Copy link
Contributor Author

spacedwarf14 commented Sep 17, 2024

yeah that makes a lot of sense. Would a PR with those changes be considered?

@dvir001
Copy link
Contributor

dvir001 commented Sep 17, 2024

Before my opinion this PR has issue with yml that 100% could have been under _NF folders, and missing comments to mention # Frontier / // Frontier on them (All removed lines and added lines need comments if they are to upstream files so we can track changes when we update)

Not a fan of this change tbh, this feels like it over complicated a system, why not just add a toggle on APC that turn the APC into this range mod?

@spacedwarf14
Copy link
Contributor Author

spacedwarf14 commented Sep 17, 2024

Not a fan of this change tbh, this feels like it over complicated a system, why not just add a toggle on APC that turn the APC into this range mod?

I actually started with this. I decided against the dynamic behavior since was not immediately intuitive which provider an entity would attach to once it is anchored. Receivers cannot have more than one provider so it would attach to neighboring networks if the APC's range is turned off. This means there's both the anchor state and the APC's range/nearfield state to keep track of when determining which network the entity attaches to.

It was also cleaner to implement as a separate network, otherwise I would have had to introduce more event passing and complications to the code. More rules to tweak that maps might unintentionally rely on.

@spacedwarf14
Copy link
Contributor Author

Please see #2027!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants