CombatExtendedRWMod / CombatExtended

Combat Extended mod for RimWorld
128 stars 91 forks source link

Add player-forced system to loadouts #89

Closed NoImageAvailable closed 7 years ago

NoImageAvailable commented 7 years ago

Currently pawns will drop anything from their inventory that's not part of their loadout. This is problematic because it means if you want a single pawn to carry some specific item you need to create a completely new loadout for them. Disabling this behavior is not an option as it leads to inventory clutter and micromanagement hell.

Potential solution would be to add a list of player-forced items to CompInventory, then make the update loadout job check against that list to see if an item was picked up through a player command before deciding to drop it.

ProfoundDarkness commented 7 years ago

Pro V Con. It seems we have two potential methods to attack this.

Method 1 is to add something new to CompInventory to track if an inventory item was forced on and then don't try dropping that from a loadout. Probably pretty simple to implement, loadout code doesn't change much, probably have another thing we need to save. Potential pitfall, if a player forces picking up an item that is part of a loadout...

Method 2 is to have loadouts track what items it has directed a pawn to pickup. When it comes time to drop items from loadout the loadout will ONLY drop items that it has picked up. Only loadout needs to change and we have some data that needs to be saved. On the plus side no more kludges for things like holding food for pet training, no more assigning a meal to a pawn so they stop picking one up and dropping one now and then. Probably don't need to do anything special to let drugs get picked up by drug manager (#34). Potential pitfall if the pawn already had an item in their inventory that is now in loadout.

So what seems the apt path? Got any other notes in one of those? I was thinking of attempting both paths to see what pitfalls appear but if one looks better than the other I can go with one implementation.

RenaudF commented 7 years ago

"sticky" button beside to the drop button to remove auto drop behaviour? related to #70

ProfoundDarkness commented 7 years ago

Having looked at this with fresh eyes I see a little issue with trying to block item drops. The way the code related to issue #70 works is IF there is more stuff in inventory THEN drop something. ... I've got some ideas I need to explore...

ProfoundDarkness commented 7 years ago

OK... So after giving it some serious thought and looking over some code, here is what I'm looking at.

At it's root (I think) what we want is something a bit like how Apparel works where pawns will automatically pick stuff based on their apparel setting but can also force something to stay there with a simple click.

What I'm thinking is the following: -Modify the loadout system to have a root/node relationship. -Players modify the parent (root) loadouts. Never see children (node). -Pawns generally get their own loadout (node) which points to a parent (root). -Add interface (properties/methods) to loadouts so as to maintain most code which looks at loadouts not expecting this parent/child (so interface will return expected values for single loadout) to minimize non-loadout code changes. -Add/modify the float menu on items to indicate to the player that the item they are picking up is forced, like apparel. -Add a new button on the assign interface which effectively clears all forced loadout items for the pawn. -Add a new button to inventory to clear that item from forced loadout.

ProfoundDarkness commented 7 years ago

OK. This went back and forth after my comment above. The new system which I call HoldTracker (just to give a name to it) functions similar to a per pawn LoadoutSlot set to DropExcess mode. Currently this system is inventory only (which was deemed the most important), when a pawn is instructed to pick something up and they have a non-empty loadout that thing's thingDef is added to that pawn's HoldTracker which is consulted when a pawn considers dropping items (not in call cases but certainly in Loadout related cases).