コード例 #1
0
            public bool Equals(PickupTagKey x, PickupTagKey y)
            {
                bool ret = false;

                if (x.hash == y.hash)
                {
                    var bitsA = new TagBits(ref FetchManager.disallowedTagMask);
                    var bitsB = new TagBits(ref FetchManager.disallowedTagMask);
                    x.id.AndTagBits(ref bitsA);
                    y.id.AndTagBits(ref bitsB);
                    ret = bitsA.AreEqual(ref bitsB);
                }
                return(ret);
            }
コード例 #2
0
 public void UpdatePickups(PathProber path_prober, Navigator worker_navigator, GameObject worker_go)
 {
     GatherPickupablesWhichCanBePickedUp(worker_go);
     GatherReachablePickups(worker_navigator);
     finalPickups.Sort(ComparerIncludingPriority);
     if (finalPickups.Count > 0)
     {
         Pickup  pickup = finalPickups[0];
         TagBits rhs    = new TagBits(ref disallowedTagMask);
         pickup.pickupable.KPrefabID.AndTagBits(ref rhs);
         int num  = pickup.tagBitsHash;
         int num2 = finalPickups.Count;
         int num3 = 0;
         for (int i = 1; i < finalPickups.Count; i++)
         {
             bool    flag        = false;
             Pickup  pickup2     = finalPickups[i];
             TagBits rhs2        = default(TagBits);
             int     tagBitsHash = pickup2.tagBitsHash;
             if (pickup.masterPriority == pickup2.masterPriority)
             {
                 rhs2 = new TagBits(ref disallowedTagMask);
                 pickup2.pickupable.KPrefabID.AndTagBits(ref rhs2);
                 if (pickup2.tagBitsHash == num && rhs2.AreEqual(ref rhs))
                 {
                     flag = true;
                 }
             }
             if (flag)
             {
                 num2--;
             }
             else
             {
                 num3++;
                 pickup = pickup2;
                 rhs    = rhs2;
                 num    = tagBitsHash;
                 if (i > num3)
                 {
                     finalPickups[num3] = pickup2;
                 }
             }
         }
         finalPickups.RemoveRange(num2, finalPickups.Count - num2);
     }
 }
コード例 #3
0
        /// <summary>
        /// Condenses the pickups.
        /// </summary>
        /// <param name="pickups">The pickups to condense down.</param>
        private void CondensePickups(List <Pickup> pickups)
        {
            int    n          = pickups.Count;
            Pickup prevPickup = pickups[0];
            var    tagBits    = new TagBits(ref FetchManager.disallowedTagMask);

            prevPickup.pickupable.KPrefabID.AndTagBits(ref tagBits);
            int hash = prevPickup.tagBitsHash, last = n, next = 0;

            for (int i = 1; i < n; i++)
            {
                bool del        = false;
                var  pickup     = pickups[i];
                var  newTagBits = default(TagBits);
                if (prevPickup.masterPriority == pickup.masterPriority)
                {
                    newTagBits = new TagBits(ref FetchManager.disallowedTagMask);
                    pickup.pickupable.KPrefabID.AndTagBits(ref newTagBits);
                    if (pickup.tagBitsHash == hash && newTagBits.AreEqual(ref tagBits))
                    {
                        // Identical to the previous item
                        del = true;
                    }
                }
                if (del)
                {
                    // Skip
                    last--;
                }
                else
                {
                    // Keep and move down
                    next++;
                    prevPickup = pickup;
                    tagBits    = newTagBits;
                    hash       = pickup.tagBitsHash;
                    if (i > next)
                    {
                        pickups[next] = pickup;
                    }
                }
            }
            pickups.RemoveRange(last, n - last);
        }