Пример #1
0
        /// <summary>
        ///     Does the find.
        /// </summary>
        /// <param name="worker">The worker.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override void DoFind(Pawn worker)
        {
            if (_chosenAnimalToScan == null)
            {
                Log.Error($"calling DoFind on {parent.ThingID} which does not have a chosen animal!");
                return;
            }

            _scratchList.Clear();
            _scratchList.AddRange(_chosenAnimalToScan.GetAllMutationsFrom().Where(m => !DB.StoredMutations.Contains(m)));

            if (_scratchList.Count == 0)
            {
                Log.Warning("unable to find mutation to give!");
                _chosenAnimalToScan = null;
                return;
            }

            MutationDef mutation = _scratchList.RandomElement();

            DB.AddToDatabase(mutation);

            TaggedString msg = MUTATION_GATHERED_LABEL.Translate(mutation.Named("mutation"),
                                                                 _chosenAnimalToScan.Named("animal")
                                                                 );

            Messages.Message(msg, MessageTypeDefOf.PositiveEvent);
            if (_scratchList.Count - 1 == 0)
            {
                _chosenAnimalToScan = null;
            }
        }
Пример #2
0
 /// <summary>
 /// Tries to add the specified mutation to the database, returning false on failure.
 /// </summary>
 /// <param name="db">The database.</param>
 /// <param name="def">The definition.</param>
 /// <param name="displayMessageIfAdded">if set to <c>true</c> [display message if added].</param>
 /// <returns></returns>
 public static bool TryAddToDatabase([NotNull] this ChamberDatabase db, [NotNull] MutationDef def, bool displayMessageIfAdded = true)
 {
     if (!db.CanAddToDatabase(def))
     {
         return(false);
     }
     db.AddToDatabase(def);
     if (displayMessageIfAdded)
     {
         Messages.Message(MUTATION_ADDED_MESSAGE.Translate(def.Named("Mutation")), MessageTypeDefOf.PositiveEvent);
     }
     return(true);
 }