After finishing working on my Attribute system last week, I dove head first into work on an Item system (consumables, weapons, armor, etc.).  Much of the work on Attributes ended up helping me with my work on Items in ways that just… made sense…

For those that didn’t read my last blog post, my Attribute system is a very generic system. I have a base Attribute.cs class that every Attribute must adhere to (name, short name, description, min/max/current value, etc.). From there, you can go out and create attributes to your heart’s content. What ties everything together is the AttributeCollection.cs class that can be set as a component on any object that supports it. All of this will eventually be data driven, and that’s where all the attributes each unit needs will be defined. Pretty simple stuff.

With items, I followed a somewhat similar path. I created a base Item.cs class that every Item uses, and there is an Inventory.cs class that, as you would expect, holds all the specified items.

Where things got interesting was when I started putting in the logic for the attributes of different items, like STR on a sword, or DEF on a piece of armor. Then it clicked! I already created an Attribute system. And it was created in such a way that any combination of attributes can be added to any object. Well then shit, why not create a collection of attributes, and add them to items as well?! That’s exactly what I did.

Implementation wise, it was pretty easy. Most of the work involved creating the new attributes themselves for items. Associating a particular collection of attributes on different items was as easy as it was when I was adding them to units. Then, I just had to get rid of all the hard coded items, and start referencing the real ones being created in the beginning of the game.

After this, I thought “Hell, I might as well try my hand at an actual inventory UI, I’m on a roll!”.

First thing I did was scour the internet for free RPG icons, and found a decent set on From there, I imported a bunch into project, and added a new field to the Item.cs class, Icon. When an item is being created at the start of the game, it will have the path to the image in the project, and those sprites will be loaded and set on the new field.

From there, it was just a bunch of UI work, really. Making a new Inventory panel, adding in a grid layout so all the slots are properly spaced, and then a little code to pull all the items out of an Inventory.cs data object, and display them in the UI, according to whatever its Icon is.

Because I was feeling a little ambitious, I decided to end the day with some work on tool tips. I won’t go into all the details, but most of my time was spent figuring out how to position it, as well as making sure that it was rendered last, so that no other UI elements would block it.

I’m very happy with how things have come out, especially the UI bit, which I’ve only been working on for about a day or so. Of course, there is much more to come. I’ll need the following:

  • More added to the UI to show the unit and all their equipment slots
  • Drag and drop of items
  • Equipping/Unequipping
  • Tabs for better catagorization
  • A bunch of shit I’m sure I’m forgetting, but will remember once I’m knee deep in it

So yeah, that’s it. Pretty solid few days of development, with tangible results.

Till tomorrow…

P.S. Since migrating to the new site, my posting schedule has not followed the cadence I once had. Everyone does it differently, but in the past, I’ve always tried to do a post a day, or at least every other day. This way, I remember all the little details of what I’m working on, giving each post a little more depth. Also, for me, it’s great to come back to read previous posts from years ago, if not for anything else, nostalgia’s sake.

Anyway, no idea if I’ll ever get back to that 2006 cadence, but I’m going to at least try to find some happy medium.