sumghai / MedPod

Advanced regenerative medical beds for RimWorld
Other
14 stars 15 forks source link

Reconnect biological surrogate after using medpod #63

Closed ruifung closed 2 years ago

ruifung commented 2 years ago

Describe the bug:

Android Tiers biological surrogates (VX0 chips) disconnect on unconciousness and don't reconnect after medpod finishes.

Expected behavior:

For it to not be unconcious after the MedPod is done. Or maybe reconnect automatically.

Not sure if this is for android tiers or medpod to handle tbh. Heck, I don't even know if this actually qualifies as a bug tbh.

Steps to reproduce:

  1. Apply any kind of down / unconcious hediff to the VX0 pawn (i.e. the medpod unconciousness one).
  2. Watch as the operator (skycloud) disconnects.
  3. You now have a blank surrogate on the pod that's incapable of moving until you reconnect it manually.

Additional information:

System and Game Configuration

Operating System: Windows 11 (64-bit) Physical RAM: 32 GB RimWorld base game version: 1.3.3200 rev726 RimWorld DLCs loaded: Royalty, Ideology MedPod mod version: 1.3.4 MedPod mod downloaded from: Steam Your mod list:

Declaration

I hereby verify that:

sumghai commented 2 years ago

Please provide the following missing information:

This is so that I can manually download those specific mod versions myself, in order to accurately reproduce and diagnose the issue.

ruifung commented 2 years ago

Updated original post with version info that I could find.

I honestly don't know if it can technically be considered an issue, because android tiers itself disconnects the surrogates when they are downed for ANY reason. Including fake down, or any other kind of unconciousness.

This is honestly more of a feature request (?) to have it automatically reconnect after using the medpod. Especially with vanilla cooking expanded, which gives things like cholesterol and diabetes just from eating, resulting in them going to the medpod often enough that I just disabled that feature from vanilla cooking expanded.

FGRemastered commented 2 years ago

Have you tried updating AT yet? rev3 is just the steam version. Rev6 is the newest.

Edit: That won't help you in this situation, I'm aware, but it'll alleviate some other bugs you might encounter.

sumghai commented 2 years ago

I've recreated this issue in my own game, but devising a solution is going to be tricky.

First, we need to consider the intent of Android Tier's author(s):

Secondly, is there a way for the surrogate's VX0 chip to store the ID of its previous host? This would require work on the part of the mod's author(s).

ruifung commented 2 years ago
  1. Pretty sure downed surrogates are not supposed to automatically try to reconnect.
  2. Maybe not if it's only attempted after removing that delta-wave hediff, if its possible?
  3. Might not be an issue if (2) is viable? Given that apparently surrogates already don't seem to get hauled to the medpod when nobody is controlling them, I'd say it might not be an issue?

Well, given that the surrogate explicitly has an action button to "reconnect to previous host", I'd say yeah, it does store the ID of its previous host.

But as an addendum to (1), normally being downed is due to injuries / illness / etc, which makes sense to disconnect. But given that the intent of the MedPod is to fix issues, having it not reconnect is honestly a pain. (Especially with vanilla cooking expanded due to its hediffs as mentioned above, now I get pawns just randomly disconnecting every so often.)

sumghai commented 2 years ago

I've found the gizmo (and corresponding delegate function) that attempts to reconnect the surrogate to its last host:

https://github.com/Atla55/Android-Tiers-Core/blob/063370c1c0cf5126f934e1e7dc8c08a3673c6afa/Source/Androids%20For%20RW1.3/Components/CompAndroidState.cs#L1230

However, I'm not sure if it is even possible for a MedPod that finishes treating a pawn to trigger that delegate. The original code is also bracketed by additional null checks, which makes matters complicated.

ruifung commented 2 years ago

Uh... yeah, not sure about that. I'm not familiar enough with rimworld modding to give any kind of useful input here.

Though... I fail to understand how null checks makes matters complicated if you can get the instance of that... uh... comp? that was already on the pawn?

sumghai commented 2 years ago

@ruifung - Please test the following development build:

https://github.com/sumghai/MedPod/archive/bdfe1e540628c035f338d947a121e144b9ffbb0b.zip

Surrogates should automatically reconnect with their last known controller after treatment, while regular human pawns are not affected. Non-Android Tiers savegames should also be successfully ignored.

Though... I fail to understand how null checks makes matters complicated if you can get the instance of that... uh... comp? that was already on the pawn?

The null checks I was referring to involved internal references to whether or not a pawn was a surrogate, controller, had the right level of controller chip implant, etc., which weren't trivial to reference directly even if I can get the instance of the comp. The folks over in the RW mod development Discord server were pretty puzzled as well, and feared I had to use reflections or something.

In any case, we ultimately figured out an alternative approach where when the patient is told to wake up, we first check if the Android Tiers mod as a whole is installed, and then check if the pawn actually has the specific "Reconnect to last controller" gizmo/command available - a roundabout alternative to the aforementioned null checks.

ruifung commented 2 years ago

I'll test it later when I have time to.

But in truth, that approach was what I thought of at first. (I was wondering why null checks were relevant if you could just invoke the action.)

Though I suppose it might be a little fragile if Android Tiers ever changes the localization key.

ruifung commented 2 years ago

@sumghai - Confirmed, it does indeed cause pawns to reconnect after MedPod treatment. I'll let it run to see if any issues crop up.

sumghai commented 2 years ago

@ruifung - Any outstanding issues from testing the dev build?

If not, I'll release the fix this weekend.

ruifung commented 2 years ago

As far as I'm aware, there doesn't seem to be any notable issues.

Though the following behaviors has been observed:

  1. Sometimes the pawn goes through a few cycles of the medpod before its freed (but shrugs, not really a problem here).
  2. Sometimes the reconnect gizmo just disappears entirely (though I think thats a android tiers issue...?) and I need to manually reconnect.

But yeah, other than that, it seems to be working fine to the point where I barely notice the effects of turning the hediffs from vanila cooking expanded back on.

sumghai commented 2 years ago

Okay, I'll mark this one as done.