Example #1
0
        public static GovType getGov()
        {
            GameComponent_ColonyLeadership comp = getCLComp();

            if (comp != null)
            {
                return(comp.chosenLeadership);
            }
            return(null);
        }
Example #2
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);
        }
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(inRect);

            listing_Standard.Label("ChooseGov".Translate());

            String label = this.chosenLeadership.name;

            if (listing_Standard.ButtonText(label, null))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                foreach (GovType gov in ColonyLeadership.govtypes)
                {
                    list.Add(new FloatMenuOption(gov.name, delegate
                    {
                        this.chosenLeadership = gov;
                    }, MenuOptionPriority.Default, delegate() { TooltipHandler.TipRegion(inRect, gov.desc); }, null, 0f, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
            }

            listing_Standard.Gap(24f);
            if (listing_Standard.ButtonText("OK".Translate(), null))
            {
                GameComponent_ColonyLeadership comp = Utility.getCLComp();
                if (comp != null)
                {
                    comp.chosenLeadership = this.chosenLeadership;
                }
                if (comp != null)
                {
                    comp.chosenGov = ColonyLeadership.govtypes.IndexOf(this.chosenLeadership);
                }
                Find.WindowStack.TryRemove(this, true);
                if (this.chosenLeadership.name == "Dictatorship".Translate())
                {
                    foreach (Pawn p in IncidentWorker_LeaderElection.getAllColonists())
                    {
                        LeaderWindow.purgeLeadership(p);
                    }

                    Find.WindowStack.Add(new Dialog_ChooseLeader());
                }
            }
            listing_Standard.End();
        }
Example #4
0
        public void StartLesson(bool forced = false, String skills = "")
        {
            teacher = tempTeacher;


            if (this.Destroyed || !this.Spawned)
            {
                TeachingUtility.AbortLesson(null, "The spot is unavailable.");
                return;
            }
            if (!TeachingUtility.IsActorAvailable(this.teacher))
            {
                TeachingUtility.AbortLesson(this, "TeacherUnavailableNamed".Translate(new object[] { this.teacher.LabelShort }));
                this.teacher = null;
                return;
            }



            //FactionBase factionBase = (FactionBase)this.Map.info.parent;

            //Messages.Message("LessonGathering".Translate(new object[] { factionBase.label, teacher.LabelShort }) + skills, TargetInfo.Invalid, nullSound);

            Settlement factionBase = (Settlement)this.Map.info.parent;

            Messages.Message("LessonGathering".Translate(new object[] { factionBase.Label, teacher.LabelShort }) + skills, TargetInfo.Invalid, MessageTypeDefOf.NeutralEvent);

            ChangeState(State.lesson, LessonState.started);
            //this.currentState = State.started;
            Job job = new Job(DefDatabase <JobDef> .GetNamed("TeachLesson"), this);

            teacher.jobs.jobQueue.EnqueueLast(job);
            teacher.jobs.EndCurrentJob(JobCondition.InterruptForced);
            TeachingUtility.GetLessonGroup(this, Map, forced);
            lastLessonTick = Find.TickManager.TicksGame;
            //  HediffLeader hediff = TeachingUtility.leaderH(teacher);
            //  if (hediff != null) hediff.lastLessonTick = Find.TickManager.TicksGame;
            GameComponent_ColonyLeadership comp = Utility.getCLComp();

            if (comp != null)
            {
                comp.lastLessonTick = Find.TickManager.TicksGame;
            }
        }
Example #5
0
        public static GameComponent_ColonyLeadership getCLComp()
        {
            GameComponent_ColonyLeadership comp = Current.Game.GetComponent <GameComponent_ColonyLeadership>();

            return(comp);
        }