Esempio n. 1
0
        private bool CanGatherToLessonNow(out String skills)
        {
            skills = "";
            if (Find.TickManager.TicksGame < lastTryTick + (GenDate.TicksPerHour / 3))
            {
                return(false);
            }
            lastTryTick = Find.TickManager.TicksGame;
            if (Find.TickManager.TicksGame < lastLessonTick + GenDate.TicksPerDay - 1000)
            {
                return(RejectMessage("MustWaitForLesson".Translate()));
            }

            GameComponent_ColonyLeadership comp = Utility.getCLComp();

            if (comp != null && Find.TickManager.TicksGame < comp.lastLessonTick + GenDate.TicksPerDay - 1000)
            {
                return(RejectMessage("MustWaitForLesson".Translate()));
            }

            if (tempTeacher == null)
            {
                return(RejectMessage("NoTeacherSelected".Translate()));
            }
            String report = "";

            bool hasSkill = TeachingUtility.leaderHasAnySkill(tempTeacher, out report, out skills);

            if (hasSkill && report != "")
            {
//                Messages.Message(report, TargetInfo.Invalid, nullSound);

                Messages.Message(report, TargetInfo.Invalid, MessageTypeDefOf.NeutralEvent);
            }
            if (!hasSkill)
            {
                return(RejectMessage(report));
            }
            if (tempTeacher.Drafted)
            {
                return(RejectMessage("TeacherDrafted".Translate()));
            }
            if (tempTeacher.Dead || this.tempTeacher.Downed)
            {
                return(RejectMessage("TeacherDownedDead".Translate(), this.tempTeacher));
            }
            if (!tempTeacher.CanReserve(this))
            {
                return(RejectMessage("TeacherTableReserved".Translate()));
            }

            return(true);
        }
Esempio n. 2
0
        public static void listPawns(int index, Building_TeachingSpot spot)
        {
            List <FloatMenuOption> list   = new List <FloatMenuOption>();
            List <Pawn>            tpawns = new List <Pawn>();

            foreach (Pawn current in IncidentWorker_LeaderElection.getAllColonists())
            {
                Hediff h1 = current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
                Hediff h2 = current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
                Hediff h3 = current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
                Hediff h4 = current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));

                if (h1 != null || h2 != null || h3 != null || h4 != null)
                {
                    if (!spot.teachers.Contains(current))
                    {
                        tpawns.Add(current);
                    }
                }
            }


            list.Add(new FloatMenuOption("-None-", delegate
            {
                spot.teachers[index] = null;
            }, MenuOptionPriority.Default, null, null, 0f, null, null));

            foreach (Pawn p in tpawns)
            {
                list.Add(new FloatMenuOption(p.Name.ToStringShort, delegate
                {
                    String report = "";
                    String skills = "";
                    bool hasSkill = TeachingUtility.leaderHasAnySkill(p, out report, out skills);
                    if (hasSkill)
                    {
                        spot.teachers[index] = p;
                        if (report != "")
                        {
                            Messages.Message(report, TargetInfo.Invalid, MessageSound.Standard);
                        }
                    }
                    else
                    {
                        spot.teachers[index] = null;
                        Messages.Message(report, TargetInfo.Invalid, MessageSound.RejectInput);
                    }
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }


            Find.WindowStack.Add(new FloatMenu(list));
        }