melia
melia copied to clipboard
Feature - Personal Storage
Adds feature of personal storage.
Includes:
- Open/Close personal storage
- Store/Retrieve items in personal storage
- Stacking of items to/from personal storage
- Swapping of items in personal storage
- 20 silver cost for personal storage
- Saving personal storage in SQL DB
- 'Multistack' toggleable feature
- Chatcommand to open personal storage anywhere
- Rita storage keeper in klaipeda
Does not include:
- Team storage
- Personal storage expansion
Overview: Basic storage implementation using arrays. Index of array is it's position in storage and value is the item. Hardcoded storage size of 60 for time being.
'Multistack' feature allows toggling on/off the possibility of creating multiple stacks of same item class when storing. If it's toggled off, you can only store 1 stack of the same item class. If feature is toggled on and then off after a while, players may see multiple stacks of items in storage but once these are retrieved they'll not be able to create multiple stacks anymore.
Multistack implementation stores first to existing items and then any remainder to a new stack.
Multisack comes enabled by default.
I have refactored the implementation into a more reusable approach.
- 'Storage' class is now abstract and has the core of storage implementation
- 'PersonalStorage' class inherits from it and implements single character storage
- Changed _storageItems data type to SortedList<Item> to be compatible with either PersonalStorage or TeamStorage
- Whether you want an ordered storage or not now can be achieved by either loading storage with Add() or AddAtPosition()
- Removed unecessary fields from 'Character' class, now 'isBrowsing' field is in 'PersonalStorage' class.
- The new implementation allows to easily create shared storages between multiple characters.
- The new implementation also allows for easy creation of other storage types (i.e. guild storage).
- The new implementation also allows to easily manipulate storage sizes.
- Added a few more methods for better manipulation of storages.
Personal Storage is high on my todo list, but I feel like it's important we get this right early on, as it's been my experience that refactoring item-/inventory-related code can be rather tedious. Seeing how the last couple comments have not been addressed for the most part yet, I might take this promising PR as the base for completing the feature in the near future.