Bones and Code

Semaphores, the dropbox, and placeable items

;

Posted 04/12/2016 20:21:16 in Homestead

Updated 07/04/2017 14:07:47

I've been plugging away at my long list of TODOs, fixing little issues that have been around for a while but are starting to get tiresome to work around. One of the more interesting things I improved was the handling of player control locking-- I recently learned about semaphores in my operating systems course, and used the concept! Previously, a global object kept a bool playerLock variable that represented whether the player's inputs would be sent to the character GameObject, but I ran into issues when the dialogue system, inventory system, and tool system all wanted to lock and unlock the player! It started getting fragile trying to design the systems in ways that didn't interfere with each other, so I just replaced the bool playerLock with an int playerLockSemaphore and had the individual systems increment/decrement that instead. This way, the global object can just check if playerLockSemaphore equals 0, and the problem is solved without the systems needing to know about each other!

Here's a look at the Dropbox! I'm still working on the expanded inventory system, and with that comes some design work. I'm planning on making more use of Unity's UI system than I have been, particularly the sliced sprite and event functionalities. I even made a pretty slick opening/closing animation for it, but I'm saving that for when I have the system ready to show off with it.

Screenshot of the dropbox
A look at the dropbox

Items are now persistent! You can leave them all over the place. Also, eggs. They come from the chickens. You might notice that the date and time are a little wonky too-- That's what I get for opening the project up in Windows while my Linux installation was down!

Placeable items in Homestead
Scattered items, now placeable!

That's all for this week! I'm sorry there's not much more to show, but most of the work was behind the scenes and the majority of the animation work I did isn't implemented in-game yet (plus, after refreshing my OS last week I neglected to reinstall my video recording software!). Until next time!

ROADMAP: Continue polishing TODOs, continue implementation of the input wrapper and inventory redesign, build a barn, and continue implementing secondary player actions.

Comments

Today