コード例 #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;
            }
        }