public Toil TakeBookFromBookshelf(TargetIndex ind, Pawn reader, TargetIndex bookInd) { Toil takeBook = new Toil(); takeBook.initAction = delegate { bool flag = true; Pawn actor = takeBook.actor; Bookshelf bookshelf = (Bookshelf)actor.jobs.curJob.GetTarget(ind).Thing; Thing thing = bookshelf.JobBook(reader); if (thing == null) { actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable); } else { ReadableBooks readableBooks = thing as ReadableBooks; readableBooks.currentReader = reader; actor.carrier.TryStartCarry(readableBooks); actor.jobs.curJob.targetB = actor.carrier.CarriedThing; } if (flag) { if (Find.Reservations.FirstReserverOf(bookshelf, bookshelf.Faction) == reader) { Find.Reservations.Release(bookshelf, reader); } } }; takeBook.defaultCompleteMode = ToilCompleteMode.Delay; takeBook.defaultDuration = 20; return(takeBook); }
public void FeedBackPulse() { foreach (Thing current in Find.ListerThings.AllThings) { if (current.def.defName == "ClutterBookShelf") { Bookshelf bookshelf = current as Bookshelf; if (bookshelf.MissingBooksList.Contains(def)) { if (bookshelf.StoredBooks.Count < 3) { bookshelf.MissingBooksList.Remove(def); bookshelf.StoredBooks.Add(def); if (Spawned) { Destroy(); } break; } } } } if (Spawned) { Destroy(); } }
public Toil ReadEnd(Pawn reader, TargetIndex bookInd, TargetIndex BookShelfInd) { return(new Toil { initAction = delegate { Bookshelf bookshelf = (Bookshelf)reader.jobs.curJob.GetTarget(BookShelfInd).Thing; ReadableBooks readableBooks = (ReadableBooks)reader.jobs.curJob.GetTarget(bookInd).Thing; readableBooks.Thoughts(reader); }, defaultCompleteMode = ToilCompleteMode.Instant }); }
public Toil ReadingBook(Pawn reader, int durationMultiplier, TargetIndex Ind, TargetIndex bookInd) { Toil toil = new Toil(); List <string> text = new List <string>(); Bookshelf thing = null; ReadableBooks thingBook = null; int s = 0; int i = 0; bool tickOnce = false; toil.tickAction = delegate { if (!tickOnce) { thing = (Bookshelf)reader.jobs.curJob.GetTarget(Ind).Thing; thingBook = (ReadableBooks)reader.jobs.curJob.GetTarget(bookInd).Thing; if (thingBook.PrepareText().Count > 0) { text = thingBook.PrepareText(); } thingBook.TexChange = true; tickOnce = true; } if (text.Count > 0) { if (i > 150) { s++; MoteMaker.ThrowText(reader.TrueCenter() + new Vector3(0f, 0f, 0.7f), text.ElementAt(s), Color.green); reader.needs.joy.CurLevel += 0.03f; i = 0; } i++; } reader.Drawer.rotator.FaceCell(thingBook.Position); }; toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.FailOnDespawnedOrNull(TargetIndex.B); toil.defaultDuration = durationMultiplier; return(toil); }