Esempio n. 1
0
        protected override Job TryGivePlayJob(Pawn pawn, Thing t)
        {
            if (!ListenBuildingUtility.TryFindBestListenCell(t, pawn, def.desireSit, out var vec, out var t2))
            {
                if (!ListenBuildingUtility.TryFindBestListenCell(t, pawn, false, out vec, out t2))
                {
                    return(null);
                }
            }

            if (t2 == null)
            {
                return(new Job(def.jobDef, t, vec, (Building)null));
            }

            if (vec != t2.Position)
            {
                return(new Job(def.jobDef, t, vec, t2));
            }

            if (!pawn.Map.reservationManager.CanReserve(pawn, t2))
            {
                return(null);
            }

            return(new Job(def.jobDef, t, vec, t2));
        }
        protected override Job TryGivePlayJob(Pawn pawn, Thing t)
        {
            IntVec3  vec;
            Building t2;

            if (!ListenBuildingUtility.TryFindBestListenCell(t, pawn, this.def.desireSit, out vec, out t2))
            {
                if (!ListenBuildingUtility.TryFindBestListenCell(t, pawn, false, out vec, out t2))
                {
                    return(null);
                }
            }
            if (t2 != null)
            {
                if (vec == t2.Position)
                {
                    if (!pawn.Map.reservationManager.CanReserve(pawn, t2))
                    {
                        return(null);
                    }
                }
            }

            return(new Job(this.def.jobDef, t, vec, t2));
        }
        protected override bool CanInteractWith(Pawn pawn, Thing t, bool inBed)
        {
            if (!base.CanInteractWith(pawn, t, inBed))
            {
                return(false);
            }
            if (inBed)
            {
                Building_Bed layingDownBed = pawn.CurrentBed();

                return(ListenBuildingUtility.CanListenFromBed(pawn, layingDownBed, t));
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// All the menu options for the Gramophone.
        /// </summary>
        /// <param name="myPawn"></param>
        /// <returns></returns>
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn)
        {
            if (!myPawn.CanReserve(this, 16))
            {
                FloatMenuOption item = new FloatMenuOption("CannotUseReserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item
                });
            }
            if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn))
            {
                FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item2
                });
            }
            if (!myPawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                FloatMenuOption item3 = new FloatMenuOption("CannotUseReason".Translate(new object[]
                {
                    "IncapableOfCapacity".Translate(new object[]
                    {
                        PawnCapacityDefOf.Manipulation.label
                    })
                }), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item3
                });
            }


            List <FloatMenuOption> list = new List <FloatMenuOption>();
            IntVec3  vec = myPawn.Position;
            Building t2  = null;

            if (IsOn() == true)
            {
                Action action0 = delegate
                {
                    Job job = null;
                    if (ListenBuildingUtility.TryFindBestListenCell(this, myPawn, true, out vec, out t2))
                    {
                        job = new Job(DefDatabase <JobDef> .GetNamed("ListenToGramophone"), this, vec, t2);
                    }
                    else if (ListenBuildingUtility.TryFindBestListenCell(this, myPawn, false, out vec, out t2))
                    {
                        job = new Job(DefDatabase <JobDef> .GetNamed("ListenToGramophone"), this, vec, t2);
                    }
                    if (job != null)
                    {
                        job.targetB = vec;
                        job.targetC = t2;
                        if (myPawn.jobs.TryTakeOrderedJob(job))
                        {
                            //Lala
                        }
                    }
                };
                list.Add(new FloatMenuOption("Listen to " + this.Label, action0, MenuOptionPriority.Default, null, null, 0f, null));

                Action action0a = delegate
                {
                    Job job = new Job(DefDatabase <JobDef> .GetNamed("TurnOffGramophone"), this);
                    job.targetA = this;
                    if (myPawn.jobs.TryTakeOrderedJob(job))
                    {
                        //Lala
                    }
                };
                list.Add(new FloatMenuOption("Turn off " + this.Label, action0a, MenuOptionPriority.Default, null, null, 0f, null));
            }


            if (tuneScape != null)
            {
                var tuneDefs = tuneScape.TuneDefCache.Where(x => !x.instrumentOnly);
                if (tuneDefs.Any())
                {
                    foreach (TuneDef def in tuneDefs)
                    {
                        Action actionDef = delegate
                        {
                            Job job = new Job(DefDatabase <JobDef> .GetNamed("PlayGramophone"), this);
                            job.targetA    = this;
                            currentTuneDef = def;
                            if (myPawn.jobs.TryTakeOrderedJob(job))
                            {
                                //Lala
                            }
                        };
                        list.Add(new FloatMenuOption("Play " + def.LabelCap, actionDef, MenuOptionPriority.Default, null, null, 0f, null));
                    }
                }
            }
            return(list);
        }