예제 #1
0
        private void ReadFormXML()
        {
            List <string>      list             = new List <string>();
            ThingDef_Readables clutterThingDefs = (ThingDef_Readables)def;

            if (clutterThingDefs.BookText.Count > 0)
            {
                list = clutterThingDefs.BookText;
            }
            if (!clutterThingDefs.CloseTexture.NullOrEmpty())
            {
                OpenBook = GraphicDatabase.Get <Graphic_Single>(clutterThingDefs.CloseTexture);
            }
        }
예제 #2
0
        private void ReadXML()
        {
            ThingDef_Readables clutterThingDefs = (ThingDef_Readables)def;

            if (clutterThingDefs.BooksList.Count > 0 && StoredBooks.Count <= 0)
            {
                while (StoredBooks.Count < 3 && MissingBooksList.Count <= 0)
                {
                    Thing thing = ThingMaker.MakeThing(clutterThingDefs.BooksList.RandomElement <ThingDef>());
                    if (!StoredBooks.Contains(thing.def))
                    {
                        StoredBooks.Add(thing.def);
                    }
                }
            }
        }
예제 #3
0
        public List <string> PrepareText()
        {
            ThingDef_Readables clutterThingDefs = (ThingDef_Readables)def;

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

            if (BookText.Count > 0)
            {
                result = TextChooping(BookText);
            }
            else
            {
                result = TextChooping(DefaultText);
            }
            return(result);
        }
예제 #4
0
        public Toil PlaceItemToRead(TargetIndex bookInd)
        {
            Toil placeItem = new Toil();

            placeItem.initAction = delegate
            {
                Pawn  actor        = placeItem.actor;
                Thing carriedThing = actor.carrier.CarriedThing;
                ThingDef_Readables clutterThingDefs = (ThingDef_Readables)carriedThing.def;
                if (!clutterThingDefs.IsABook)
                {
                    Log.Message(actor + " tried to place book for reading but was carrying " + actor.carrier.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())
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                actor,
                                " tried to place book out of bounds at ",
                                position,
                                ". Correcting."
                            }));
                            position = actor.Position;
                        }
                        if (!actor.carrier.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);
        }