I have 2 Item Droppers attached to my AI, one to drop a weapon and the other to drop some loot. When the dropper logic fires, it calls `ItemCollection.Compare()` to find the correct item collection to take the drops from. The collections are both of type `Drop`, one is `WeaponDrops` the other `ItemDrops`. Since the check for `m_Name` will not return failure if the names don't match, it goes on to return true on the m_Purpose comparison resulting in both drops coming from ItemDrops. The drops have the correct item prefab but actually results in both drops being a medkit, one that looks like a weapon.
The original method was:
I changed it to the following and I'm now seeing drops as expected. I don't know if this will break drop functionality elsewhere as I'm still working my way through to see if it has any unintended side effects.
The original method was:
C#:
public bool Compare(ItemCollection itemCollection)
{
if (itemCollection == null) { return false; }
if (string.IsNullOrWhiteSpace(m_Name) == false && itemCollection.Name == m_Name) { return true; }
if (m_Purpose == ItemCollectionPurpose.None) { return false; }
return m_Purpose == itemCollection.Purpose;
}
I changed it to the following and I'm now seeing drops as expected. I don't know if this will break drop functionality elsewhere as I'm still working my way through to see if it has any unintended side effects.
C#:
public bool Compare(ItemCollection itemCollection)
{
if (itemCollection == null)
{
return false;
}
if (m_Purpose == ItemCollectionPurpose.None)
{
return false;
}
return m_Purpose == itemCollection.Purpose && string.IsNullOrWhiteSpace(m_Name) == false &&
itemCollection.Name == m_Name;
}