Saturday, 7 March 2009

Equipment re-design

Previously I had items in inventory list and they had in_use -variable to show in what use the item had. This included wearing and wielding items, but I really didn't think I would have to re-design it later. In fact I didn't think at all when I designed the first system, it just felt nice to have inventory with items tagged as equipment.

The problem was that when you check for items you have to go through the list and check in_use every time and with monsters doing the same it's going to be slow. So, I changed the equipment to an array of items each in equipment slot. The real problem was that I had to re-write everything related to in_use and I'm still re-writing it, because in_use was in pretty heavy use, so to speak.

When this is done I still have to re-design in_use, because it's going to be used in other kind of uses like when you put on a lamp, to indicate that the lamp is on.

I think this was one of the last really annoying re-writes. From now on I try to work with the current style of the source code and accept the fact that it's not going to be perfect OOP.

No comments:

Post a comment