Beispiel #1
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>
 /// <returns></returns>
 public static bool TryAddToDatabase([NotNull] this ChamberDatabase db, [NotNull] MutationDef def)
 {
     if (!db.CanAddToDatabase(def))
     {
         return(false);
     }
     db.AddToDatabase(def);
     return(true);
 }
Beispiel #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);
 }
Beispiel #3
0
 /// <summary>
 /// Tries to add the specified pawnkind to the database, returning false on failure
 /// </summary>
 /// <param name="db">The database.</param>
 /// <param name="pawnKind">Kind of the pawn.</param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException">
 /// db
 /// or
 /// pawnKind
 /// </exception>
 public static bool TryAddToDatabase([NotNull] this ChamberDatabase db, [NotNull] PawnKindDef pawnKind)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     if (pawnKind == null)
     {
         throw new ArgumentNullException(nameof(pawnKind));
     }
     if (!db.CanAddToDatabase(pawnKind))
     {
         return(false);
     }
     db.AddToDatabase(pawnKind);
     return(true);
 }
Beispiel #4
0
 /// <summary>
 /// Tries to add the specified pawnkind to the database, returning false on failure
 /// </summary>
 /// <param name="db">The database.</param>
 /// <param name="pawnKind">Kind of the pawn.</param>
 /// <param name="displayMessageIfAdded">if set to <c>true</c> [display message if added].</param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException">db
 /// or
 /// pawnKind</exception>
 public static bool TryAddToDatabase([NotNull] this ChamberDatabase db, [NotNull] PawnKindDef pawnKind, bool displayMessageIfAdded = true)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     if (pawnKind == null)
     {
         throw new ArgumentNullException(nameof(pawnKind));
     }
     if (!db.CanAddToDatabase(pawnKind))
     {
         return(false);
     }
     db.AddToDatabase(pawnKind);
     if (displayMessageIfAdded)
     {
         Messages.Message(ANIMAL_ADDED_TO_DATABASE_MESSAGE.Translate(pawnKind), MessageTypeDefOf.PositiveEvent);
     }
     return(true);
 }