scrdest / UristMcStation

Urist McStation's BS12 branch. Come play at byond://24.240.44.164:59359
GNU Affero General Public License v3.0
0 stars 1 forks source link

Conversion to interaction interfaces & more handler work #62

Closed CPU-Blanc closed 1 year ago

CPU-Blanc commented 1 year ago

Many changes here, but very much a WIP, things subject to change. But I'm kind of tired of looking at it so I'm sending it here :P

There's things here I'm already looking at changing in the future. Mainly how the interactions_holder currently uses a bitflag system with the mob/atom type. There was a gross oversight while thinking this through which I didn't realise until later which made me change how it works (curse you hex). Now it might be better to have a CheckAllowed(var/atom) proc for /datum/interactions which can be overloaded and do type checking as required by each individual interaction, though this would mean many more proc definitions and calls.

CPU-Blanc commented 1 year ago

Made a little bit of a refactor to generic handlers

Because using different tools would basically be a load of "if crowbar is in inventory, click this with it", "if screwdriver is in inventory, click this with it", it didn't make sense to have a load of different procs essentially doing the same thing. This part has now been offloaded to the UseGenericTool proc. As all tools basically have their own respective procs to check for them (ie, obj.isscrewdriver()), we just use a single proc and pass those procnames to it to find and use what tool we want. This has been made into a sort of helper proc due to extra checks you might want to do in a handler that could change depending on the state of the target, or the exact task you're trying to accomplish. For example: this way we can have a "Pry open the airlock" handler, that'll make sure that the airlock isn't actually already open before slapping a crowbar on it by calling the new UseGenericTool proc inside of it. This'd be hard to do with a single generic tool proc without a lot of nasty typecasting inside of it, or making a new proc that has all the same inventory and tool usage code in it. Hope this makes sense.

Also extracted several very repeated chunks of code into their own helper procs. If something's being done the exact same way in 10 different places, it should probably be a proc, so it now is.

Airlock pry and screw handlers have also been added.

The inventory stuff is very much a placeholder for now until we work out how exactly we're going to handle all that. For now we just... magically use items from inside their inventory. Bluespace or something :shrug:

CPU-Blanc commented 1 year ago

No worries! Hold off on some fixes for a little bit, I've already had a follow-up commit in the works. Just couldn't verify some behaviour because of the obstacle pathing being wonk so I was holding off until I could verify that. If you're happy for some unverified changes, I could push that commit and open a new PR with the fixes shortly?