コード例 #1
0
 /// <summary>
 /// Adds a critter in the current world to the inventory.
 /// </summary>
 /// <param name="creature">The creature to add.</param>
 private void AddCritter(KPrefabID id)
 {
     if (counts.TryGetValue(id.GetCritterType(), out CritterInventoryPerType byType))
     {
         var  species = id.PrefabTag;
         bool targeted = false, targetable = false;
         // Create critter totals if not present
         if (!byType.TryGetValue(species, out CritterTotals totals))
         {
             byType.Add(species, totals = new CritterTotals());
             discovered = true;
         }
         totals.Total++;
         if (id.TryGetComponent(out FactionAlignment alignment))
         {
             targeted   = FACTION_TARGETED.Get(alignment);
             targetable = FACTION_TARGETABLE.Get(alignment);
         }
         // Reserve wrangled, marked for attack, and trussed/bagged creatures
         if ((id.TryGetComponent(out Capturable capturable) && capturable.
              IsMarkedForCapture) || (targeted && targetable) || id.HasTag(
                 GameTags.Creatures.Bagged))
         {
             totals.Reserved++;
         }
     }
 }