Exemple #1
0
        private static bool Prefix(
            // ReSharper disable InconsistentNaming
            // ReSharper disable SuggestBaseTypeForParameter
            ItemCollector __instance,
            Collider other,
            int ___maxNumberOfItems,
            Collider ___collectorCollider)
        // ReSharper restore SuggestBaseTypeForParameter
        // ReSharper restore InconsistentNaming
        {
            if (!___collectorCollider.enabled ||
                ___maxNumberOfItems != 0 &&
                __instance.collectedItems.Count >= ___maxNumberOfItems ||
                !Helper.ObjectIsOnLayer(other.transform.gameObject, __instance.collectMask))
            {
                //Skip collection
                return(false);
            }

            var itemNet = __instance.GetComponentInParent <ItemNet>();

            if (itemNet == null ||
                itemNet.itemCollector == null)
            {
                // this is not an item net, continue with collection algorithm
                return(true);
            }
            var item = other.transform.GetComponentInParent <PickupItem_Networked>();

            if (item == null)
            {
                // invalid item, continue with collection algorithm
                return(true);
            }

            if (ShouldBeFilteredOut(item, itemNet.itemCollector.ObjectIndex))
            {
                //Skip collection
                return(false);
            }

            // Continue with collection algorithm
            return(true);
        }