示例#1
0
文件: Maybe.cs 项目: PaulWild/FX
 public override int GetHashCode()
 {
     unchecked
     {
         return((HasItem.GetHashCode() * 397) ^ EqualityComparer <T> .Default.GetHashCode(Value));
     }
 }
示例#2
0
        bool HasItem_IsTrue(On.HasItem.orig_IsTrue orig, HasItem self)
        {
            bool       hasItem = false;
            LocationRO check;

            //Check to make sure this is an item that was randomized and make sure we are not ignoring this specific trigger check
            if (randoStateManager.IsRandomizedFile && randoStateManager.IsLocationRandomized(self.item, out check) && !RandomizerConstants.GetSpecialTriggerNames().Contains(self.Owner.name))
            {
                if (self.transform.parent != null && "InteractionZone".Equals(self.Owner.name) && RandomizerConstants.GetSpecialTriggerNames().Contains(self.transform.parent.name) && EItems.KEY_OF_LOVE != self.item)
                {
                    //Special triggers that need to use normal logic, call orig method. This also includes the trigger check for the key of love on the sunken door because yeah.
                    Console.WriteLine($"While checking if player HasItem in an interaction zone, found parent object '{self.transform.parent.name}' in ignore logic. Calling orig HasItem logic.");
                    return(orig(self));
                }

                //OLD WAY
                //Don't actually check for the item i have, check to see if I have the item that was at it's location.
                //int itemQuantity = Manager<InventoryManager>.Instance.GetItemQuantity(randoStateManager.CurrentLocationToItemMapping[check].Item);

                //NEW WAY
                //Don't actually check for the item I have, check to see if I have done this check before. We'll do this by seeing if the item at its location has been collected yet or not
                int itemQuantity = randoStateManager.GetSeedForFileSlot(randoStateManager.CurrentFileSlot).CollectedItems.Contains(randoStateManager.CurrentLocationToItemMapping[check]) ? randoStateManager.CurrentLocationToItemMapping[check].Quantity : 0;

                switch (self.conditionOperator)
                {
                case EConditionOperator.LESS_THAN:
                    hasItem = itemQuantity < self.quantityToHave;
                    break;

                case EConditionOperator.LESS_OR_EQUAL:
                    hasItem = itemQuantity <= self.quantityToHave;
                    break;

                case EConditionOperator.EQUAL:
                    hasItem = itemQuantity == self.quantityToHave;
                    break;

                case EConditionOperator.GREATER_OR_EQUAL:
                    hasItem = itemQuantity >= self.quantityToHave;
                    break;

                case EConditionOperator.GREATER_THAN:
                    hasItem = itemQuantity > self.quantityToHave;
                    break;
                }

                Console.WriteLine($"Rando inventory check complete for check '{self.Owner.name}'. Item '{self.item}' || Actual Item Check '{randoStateManager.CurrentLocationToItemMapping[check]}' || Current Check '{self.conditionOperator}' || Expected Quantity '{self.quantityToHave}' || Actual Quantity '{itemQuantity}' || Condition Result '{hasItem}'.");

                return(hasItem);
            }
            else //Call orig method
            {
                Console.WriteLine("HasItem check was not randomized. Doing vanilla checks.");
                Console.WriteLine($"Is randomized file : '{randoStateManager.IsRandomizedFile}' | Is location '{self.item}' randomized: '{randoStateManager.IsLocationRandomized(self.item, out check)}' | Not in the special triggers list: '{!RandomizerConstants.GetSpecialTriggerNames().Contains(self.Owner.name)}'|");
                return(orig(self));
            }
        }
示例#3
0
        public void ItemPropertiesNotAreIgnoredWhenDestructuring()
        {
            var indexed = new HasItem();
            var pv      = (StructureValue)_converter.CreatePropertyValue(indexed, true);

            Assert.Equal(1, pv.Properties.Count);
            var item = pv.Properties.Single();

            Assert.Equal("Item", item.Name);
        }
 public void ItemPropertiesNotAreIgnoredWhenDestructuring()
 {
     var indexed = new HasItem();
     var pv = (StructureValue)_converter.CreatePropertyValue(indexed, true);
     Assert.AreEqual(1, pv.Properties.Count);
     var item = pv.Properties.Single();
     Assert.AreEqual("Item", item.Name);
 }