space-station-14 icon indicating copy to clipboard operation
space-station-14 copied to clipboard

Body ECS/Refactor

Open DoctorBeard opened this issue 1 year ago • 4 comments

About the PR

ECS'd and refactored the body system. The whole thing is based on #6147, though since this was supposed to be a learning experience I reimplemented the changes from scratch rather than try to merge master into that branch. Once I had reimplemented those changes I did some additional refactoring on top of it.

Opening as a draft PR for now because there is some stuff I'm still not super happy with and probably some stuff I did wrong but just don't know how to do better yet in the context of SS14. I also still want to test this a bunch more to make sure I didn't break anything.

Aside from ECSing the thing one of the biggest changes is that body parts live in ContainerSlots now, similar to the ItemSlotsSystem or the inventory slots on mobs. The containers are wrapped in a BodyPartSlot object that tracks some body part slot meta data, like part type and connections. My line of thinking behind that was that body parts were already more or less arranged in slots anyway and rather than having the body system be a homebrew ContainerManager it might as well let the actual ContainerManager do the heavy lifting.

There are two downsides to this approach though and I'm not happy about how I ended up solving them. Feedback and ideas would be much appreciated there. With body parts creating ContainerSlots on the mob entity now there were some conflicts with the existing inventory slots.

One is the head slot, with both the inventory ContainerSlot (for headgear) and the body part slot being called "head" and trying to create their container with this ID. As a workaround I have changed the ID of the body part to "head-part" but this feels iffy and isn't consistent with the rest of the parts now.

The second one was with the HandsSystem, which creates ContainerSlots for held items for each added hand body part using the same ID as that body part. As a workaround I've made it use "{slotId}-inv" instead but that also feels hacky.

The BodyScanner actually works now but I just gave it the bare minimum amount of work to not be a hollow shell of commented out lines and broken code. It just lists body parts and mechanisms now with no real additional information, and the UI just shows the body parts of whoever last interacted with the device.

Since this is my first big PR and the primary purpose of this refactor for me was to learn and get into the SS14 codebase I'm absolutely open to any feedback and suggestions.

DoctorBeard avatar Aug 04 '22 00:08 DoctorBeard

holy shit

Just-a-Unity-Dev avatar Aug 04 '22 00:08 Just-a-Unity-Dev

Tests are failing because of #10273 by the way. Linter is failing because I'm a dummy and forgot to change something.

DoctorBeard avatar Aug 04 '22 00:08 DoctorBeard

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Aug 04 '22 04:08 github-actions[bot]

This pull request has conflicts, please resolve those before we can evaluate the pull request.

github-actions[bot] avatar Aug 17 '22 00:08 github-actions[bot]

@DoctorBeard are you ever coming back to this?

EmoGarbage404 avatar Sep 24 '22 23:09 EmoGarbage404