Continuing Feature Parity Part 2 (Patreon)
Content
As I said before, I am in the process of bringing in all the old behaviors now to make sure v0.9 is everything v0.8 had (minus glitches), and of course to allow mod support (helps me speed up development ALOT).
This week I added back in sleeping. It is identical to the behavior you are familiar with:
There are a few new features that were implemented to allow for this. To start, remember that every behavior (including built in ones) are now runtime mods in v0.9. So this sleeping mod was able to find a bed for the character and tell them to sleep on it. How it went about doing that was by taking advantage of the new "attributes" feature of the custom item system.
I imported v0.8's futons and I created an item from it. I then added the attribute "bed" to it in the Create tab inspector:
Now, my mod can look for items in the character's vision that has the attribute "bed" and begin the sleeping behavior:
This means that anyone can also make a bed model, make an item from it, and my sleeping mod will recognize that item as a bed. This attributes system is also very useful for communication between your scripts and items you make.
To add support for multiple characters, I had to make sure that each bed is allocated for 1 character. Two characters cannot occupy the same bed. So I also implemented custom variables. This is a new runtime mod feature that allows you to create variables for items (or characters). In the bed example, I created the "occupied" variable and made sure that it wasn't assigned to someone else. The result (Demonstrated by poor Taiga):
And the code:
There are a couple leftover miscellaneous animations not yet implemented (poking while sleeping) that I haven't quite gotten around to yet (will be done later). But every other sleeping animation from v0.8 is in (like the rub eyes animation):
Quick note on my experience remaking my game using the new runtime mods: It is very easy. I am surprised how fast it is to iterate through code. In Unity you typically have to wait for Unity to compile everything and then press Play, but the fact that all of that is ignored and scripts update as you Save the C# file, development just feels so snappy and responsive. I hope others will eventually feel the same way once they start developing their own mods.
Next on the list is bringing back handholding animations.
Stay tuned!