If a first matching container is full, put loot into the next matching
container
This commit is contained in:
parent
850b5caff1
commit
3b6760605e
@ -74,14 +74,9 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerCollection targetContainerCollection = FindTargetContainerCollection(item, inventory);
|
IEnumerable<IContainer> targetContainers = FindTargetContainers(item, inventory);
|
||||||
|
|
||||||
if (targetContainerCollection == null)
|
foreach (IContainer collectionContainer in targetContainers)
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (IContainer collectionContainer in targetContainerCollection.Containers)
|
|
||||||
{
|
{
|
||||||
if (!(collectionContainer is GClass2318 container))
|
if (!(collectionContainer is GClass2318 container))
|
||||||
{
|
{
|
||||||
@ -138,10 +133,9 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContainerCollection FindTargetContainerCollection(Item item, Inventory inventory)
|
private static IEnumerable<IContainer> FindTargetContainers(Item item, Inventory inventory)
|
||||||
{
|
{
|
||||||
ContainerCollection targetContainerCollection = null;
|
var matchingContainerCollections = new List<(ContainerCollection containerCollection, int priority)>();
|
||||||
int? lowestFoundPriority = null;
|
|
||||||
|
|
||||||
foreach (Item inventoryItem in inventory.Equipment.GetAllItems())
|
foreach (Item inventoryItem in inventory.Equipment.GetAllItems())
|
||||||
{
|
{
|
||||||
@ -180,19 +174,14 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
string priorityString = regexMatch.Value.Substring(lootTagLength);
|
string priorityString = regexMatch.Value.Substring(lootTagLength);
|
||||||
int priority = priorityString.Length == 0 ? 0 : int.Parse(priorityString);
|
int priority = priorityString.Length == 0 ? 0 : int.Parse(priorityString);
|
||||||
|
|
||||||
if (lowestFoundPriority == null || priority < lowestFoundPriority.Value)
|
matchingContainerCollections.Add((containerCollection, priority));
|
||||||
{
|
|
||||||
lowestFoundPriority = priority;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetContainerCollection = containerCollection;
|
IEnumerable<IContainer> result = matchingContainerCollections
|
||||||
}
|
.OrderBy(x => x.priority)
|
||||||
|
.SelectMany(x => x.containerCollection.Containers);
|
||||||
|
|
||||||
return targetContainerCollection;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Player GetLocalPlayerFromWorld(GameWorld gameWorld)
|
private static Player GetLocalPlayerFromWorld(GameWorld gameWorld)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user