private void ReadFormXML()
        {
            List <string>      list          = new List <string>();
            ThingDef_Readables Readables_Def = (ThingDef_Readables)def;

            if (Readables_Def.BookText.Count > 0)
            {
                list = Readables_Def.BookText;
            }
            if (!Readables_Def.CloseTexture.NullOrEmpty())
            {
                OpenBook = GraphicDatabase.Get <Graphic_Single>(Readables_Def.CloseTexture, ShaderDatabase.CutoutComplex, Vector2.one, DrawColor, DrawColorTwo);
            }
            this.Tdef = (ThingDef_Readables)this.def;
        }
Ejemplo n.º 2
0
        private void DrawThingRow(ref float y, float width, ThingDef thingDef)
        {
            Rect rect = new Rect(0f, y, width, 28f);

            Widgets.InfoCardButton(rect.width - 24f, y, thingDef);
            rect.width -= 24f;
            if (this.CanControl)
            {
                Rect rect2 = new Rect(rect.width - 24f, y, 24f, 24f);
                TooltipHandler.TipRegion(rect2, "DropThing".Translate());
                if (Widgets.ButtonImage(rect2, dropbutton))
                {
                    SoundDefOf.TickHigh.PlayOneShotOnCamera();
                    this.InterfaceDrop(thingDef, this.Shelf);
                }
                rect.width -= 24f;
            }
            if (Mouse.IsOver(rect))
            {
                GUI.color = ITab_Bookshelf.HighlightColor;
                GUI.DrawTexture(rect, TexUI.HighlightTex);
                Rect rect12 = rect;
                ThingDef_Readables readablesDef   = (ThingDef_Readables)thingDef;
                string             learnableStuff = "Nothing";
                if (readablesDef.SkillToLearn != null)
                {
                    learnableStuff = readablesDef.SkillToLearn.label;
                }
                TooltipHandler.TipRegion(rect12, "GetBookToolTip".Translate(new object[]
                {
                    readablesDef.description,
                    learnableStuff,
                }));
            }
            if (thingDef.DrawMatSingle != null && thingDef.DrawMatSingle.mainTexture != null)
            {
                Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thingDef);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.color   = ITab_Bookshelf.ThingLabelColor;
            Rect   rect3 = new Rect(36f, y, width - 36f, 28f);
            string text  = thingDef.LabelCap;

            Widgets.Label(rect3, text);
            y += 28f;
        }
        public List <string> PrepareText()
        {
            ThingDef_Readables Readables_Def = (ThingDef_Readables)def;

            BookText = Readables_Def.BookText;
            List <string> result;

            if (BookText.Count > 0)
            {
                result = TextChooping(BookText);
            }
            else
            {
                result = TextChooping(DefaultText);
            }
            return(result);
        }
Ejemplo n.º 4
0
 public void AddBookToLibrary(ThingDef_Readables rdef)
 {
     this.StoredBooks.Add(rdef);
 }
Ejemplo n.º 5
0
        public Toil PlaceItemToRead(TargetIndex bookInd)
        {
            Toil placeItem = new Toil();

            placeItem.initAction = delegate
            {
                Pawn  actor        = placeItem.actor;
                Thing carriedThing = actor.carryTracker.CarriedThing;
                ThingDef_Readables Readables_Def = (ThingDef_Readables)carriedThing.def;
                if (!Readables_Def.IsABook)
                {
                    Log.Message(actor + " tried to place book for reading but was carrying " + actor.carryTracker.CarriedThing);
                    actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                }
                else
                {
                    if (carriedThing.Destroyed)
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable);
                    }
                    else
                    {
                        IntVec3 position;
                        if (!TryFindAdjacentReadPlaceSpot(actor.Position, carriedThing.def, out position))
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                actor,
                                " could not read: found no place spot near ",
                                actor.Position,
                                ". Correcting."
                            }));
                            position = actor.Position;
                        }
                        if (!position.InBounds(this.pawn.Map))
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                actor,
                                " tried to place book out of bounds at ",
                                position,
                                ". Correcting."
                            }));
                            position = actor.Position;
                        }
                        if (!actor.carryTracker.TryDropCarriedThing(position, ThingPlaceMode.Direct, out carriedThing))
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                actor,
                                " could not read: book vanished when placed at ",
                                position,
                                "."
                            }));
                            actor.jobs.EndCurrentJob(JobCondition.Errored);
                        }
                        else
                        {
                            actor.jobs.curJob.SetTarget(bookInd, carriedThing);
                            IntVec3 intVec = position - actor.Position;
                            if (carriedThing.def.rotatable && intVec != IntVec3.Zero)
                            {
                                carriedThing.Rotation = Rot4.FromIntVec3(intVec);
                            }
                        }
                    }
                }
            };
            placeItem.defaultCompleteMode = ToilCompleteMode.Instant;

            return(placeItem);
        }