コード例 #1
0
        /// <summary>
        ///     Set up a list, with which this test first tests an increase in stack count,
        /// then tests a decrease in stack count.
        /// </summary>
        public override void Setup()
        {
            _loadout5 = new AILoadout(_loadout4)
            {
                _finemeal,
                _shirtClothNormal,
                _knifePlasteelLegendary
            };

            _list = new List <AILoadout>()
            {
                _loadout5,
                _loadout4
            };
        }
コード例 #2
0
        /// <summary>
        ///     Set up a list, with which this test first tests an increase in stack count,
        /// then tests a decrease in stack count
        /// </summary>
        public override void Setup()
        {
            _loadout5 = new AILoadout(_loadout4)
            {
                _finemeal,
                _shirtClothNormal,
                _knifePlasteelLegendary
            };

            _list = new List <AILoadout>()
            {
                _loadout5,
                _loadout4
            };

            LoadoutManager.AddLoadout(_loadout5);
            _pawn.equipment.AddEquipment((_knifePlasteelLegendary.DeepCopy()) as ThingWithComps);
            _pawn.inventory.innerContainer.TryAdd(_finemeal.DeepCopy());
        }
コード例 #3
0
        public override void Run(out bool result)
        {
            _compRPGI = _pawn.GetComp <CompAwesomeInventoryLoadout>();
            result    = true;

            for (int i = _loadouts.Count - 2; i > -1; i--)
            {
                AILoadout loadout = _loadouts[i];
                if (loadout != null)
                {
                    _pawn.SetLoadout(loadout);
                    // Check if they are the same instance
                    result &= AssertUtility.AreEqual(loadout, _compRPGI.Loadout, nameof(loadout), nameof(_compRPGI.Loadout));
                    // Check if InventoryTracker and Loadout has the same number of items
                    result &= AssertUtility.AreEqual(
                        _compRPGI.InventoryTracker.Count
                        , loadout.Count
                        , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker))
                        , string.Format(StringResource.ObjectCount, nameof(loadout)));
                    foreach (Thing thing in loadout)
                    {
                        // Check if InventoryTracker has same items as Loadout
                        result &= AssertUtility.Contains(
                            _compRPGI.InventoryTracker.Keys
                            , thing
                            , nameof(_compRPGI.InventoryTracker)
                            , thing.LabelCapNoCount);
                        // Check if stack count is matched
                        result &= AssertUtility.Expect(
                            _compRPGI.InventoryTracker[thing]
                            , thing.stackCount * -1
                            , string.Format(StringResource.ObjectCount, nameof(_compRPGI.InventoryTracker)));
                    }
                }
            }
            return;
        }
コード例 #4
0
        static Test_UpdateForNewLoadout()
        {
            _pawn         = PawnGenerator.GeneratePawn(PawnKindDefOf.Colonist);
            _pawn.outfits = new Pawn_OutfitTracker(_pawn);
            _pawn.apparel.DestroyAll();
            _pawn.equipment.DestroyAllEquipment();
            _pawn.inventory.DestroyAll();

            ThingDef knifeDef = ThingDef.Named("MeleeWeapon_Knife");
            ThingDef shirtDef = ThingDef.Named("Apparel_BasicShirt");

            _knifePlasteelLegendary
                = new ThingStuffPairWithQuality(
                      knifeDef
                      , ThingDefOf.Plasteel
                      , QualityCategory.Legendary)
                  .MakeThing();

            _knifePlasteelGood
                = new ThingStuffPairWithQuality(
                      knifeDef
                      , ThingDefOf.Plasteel
                      , QualityCategory.Good)
                  .MakeThing();

            _knifeSteelGood
                = new ThingStuffPairWithQuality(
                      knifeDef
                      , ThingDefOf.Steel
                      , QualityCategory.Good)
                  .MakeThing();

            _shirtClothNormal
                = new ThingStuffPairWithQuality(
                      shirtDef
                      , ThingDefOf.Cloth
                      , QualityCategory.Normal)
                  .MakeThing();

            _finemeal            = ThingMaker.MakeThing(ThingDefOf.MealFine);
            _finemeal.stackCount = 11;

            _loadout0 = null;
            _loadout1 = new AILoadout(_pawn);
            LoadoutManager.AddLoadout(_loadout1);

            _loadout2 = new AILoadout(_pawn);
            LoadoutManager.AddLoadout(_loadout2);

            _loadout3 = new AILoadout(_pawn);
            LoadoutManager.AddLoadout(_loadout3);

            _loadout4 = new AILoadout(_pawn);
            LoadoutManager.AddLoadout(_loadout4);

            _loadout1.Add(_knifePlasteelLegendary);

            _loadout2.Add(_knifePlasteelLegendary);
            _loadout2.Add(_knifePlasteelGood);

            _loadout3.Add(_knifePlasteelLegendary);
            _loadout3.Add(_knifePlasteelGood);
            _loadout3.Add(_knifeSteelGood);

            _loadout4.Add(_knifePlasteelLegendary);
            _loadout4.Add(_knifePlasteelGood);
            _loadout4.Add(_knifeSteelGood);
            _loadout4.Add(_shirtClothNormal);
            _loadout4.Add(_finemeal);

            _loadouts = new List <AILoadout>()
            {
                _loadout0,
                _loadout1,
                _loadout2,
                _loadout3,
                _loadout4,
            };
        }