예제 #1
0
        public virtual void CheckBookOut(Thing book, bool misplaced = false)
        {
            // This was fun!
            // 0. normal use                            -> eject,   release -> not leased,  not misplaced,  update.
            // 1. book taken, ongoing scan              -> hold,    keep    -> leased,      not misplaced,  update.
            // 2. failed scan finish, book missing      -> eject,   release -> leased,      misplaced,      no update.
            // 3. failed scan finish, book returned     -> eject,   keep    -> not leased,  misplaced,      no update.
            // 4. sucessful scan finish, book missing   -> eject,   release -> leased,      misplaced,      no update.
            // 5. sucessful scan finish, book returned  -> eject,   keep    -> not leased,  misplaced,      no update.

            var  tech    = book.TryGetTech();
            bool leased  = borrowed.Contains(book);
            bool release = leased == misplaced;
            bool hold    = leased && !misplaced;

            //Log.Message($"checking book out: {(leased ? "leased," : "")} {(misplaced? "misplaced,":"")} => {(release? "release," : "no release")} {(hold? "hold":"eject")}");
            if (release)
            {
                unlocked.libraryFreeSpace++;
                borrowed.Remove(book);
            }
            if (!hold)
            {
                tech.Ejected(this, true);
            }
            if (!misplaced)
            {
                CompStorageGraphic.UpdateGraphics();
            }
        }
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     CompStorageGraphic?.UpdateGraphics();
     if (!minifiedBackup.NullOrEmpty())
     {
         ReUpload();
     }
     base.SpawnSetup(map, respawningAfterLoad);
 }
예제 #3
0
 public bool TryDrop(Thing item, bool forbid = true)
 {
     if (innerContainer.Contains(item))
     {
         Thing outThing;
         innerContainer.TryDrop(item, ThingPlaceMode.Near, out outThing);
         ResearchProjectDef tech = outThing.TryGetTech();
         if (forbid)
         {
             outThing.SetForbidden(true);
         }
         CompStorageGraphic.UpdateGraphics();
         return(true);
     }
     return(false);
 }
예제 #4
0
 public bool TryDrop(Thing item, bool forbid = true)
 {
     if (innerContainer.Contains(item))
     {
         Thing outThing;
         innerContainer.TryDrop(item, ThingPlaceMode.Near, out outThing);
         ResearchProjectDef tech = ModBaseHumanResources.unlocked.techByStuff[outThing.Stuff];
         tech.EjectTech(this);
         if (forbid)
         {
             outThing.SetForbidden(true);
         }
         ModBaseHumanResources.unlocked.libraryFreeSpace++;
         CompStorageGraphic.UpdateGraphics();
         return(true);
     }
     return(false);
 }
예제 #5
0
        public virtual void CheckBookIn(Thing book)
        {
            //Log.Message($"checking book in, borrowed={borrowed.Contains(book)}");
            var tech = book.TryGetTech();

            if (tech != null)
            {
                tech.Unlock(this, true);
            }
            if (!borrowed.Contains(book))
            {
                unlocked.libraryFreeSpace--;
            }
            else
            {
                borrowed.Remove(book);
            }
            CompStorageGraphic.UpdateGraphics();
        }