Beispiel #1
0
        private static void DoTimeAssignment(Rect rect, int day, Building_TeachingSpot spot)
        {
            rect = rect.ContractedBy(1f);
            Texture2D texture = TimeAssignmentDefOf.Anything.ColorTexture;

            if (spot.seasonSchedule[day] == 1)
            {
                texture = ModTextures.RedColor;
            }
            else if (spot.seasonSchedule[day] == 2)
            {
                texture = ModTextures.BlueColor;
            }
            else if (spot.seasonSchedule[day] == 3)
            {
                texture = ModTextures.YellowColor;
            }

            GUI.DrawTexture(rect, texture);
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 2);
                //if (Input.GetMouseButton(0))
                if (Widgets.ButtonInvisible(rect))
                {
                    spot.seasonSchedule[day] = (spot.seasonSchedule[day] % 4) + 1;
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
                    //p.timetable.SetAssignment(hour, this.selectedAssignment);
                }
            }
        }
 public static void AbortLesson(Building_TeachingSpot spot)
 {
     if (spot != null)
     {
         spot.ChangeState(Building_TeachingSpot.State.notinuse);
     }
 }
        public static void GiveAttendLessonJob(Building_TeachingSpot spot, Pawn attendee)
        {
            if (IsTeacher(attendee))
            {
                return;
            }
            if (attendee.Drafted)
            {
                return;
            }
            if (attendee.IsPrisoner)
            {
                return;
            }
            if (attendee.jobs.curJob.def.defName == "AttendLesson")
            {
                return;
            }

            IntVec3  result;
            Building chair;

            if (!WatchBuildingUtility.TryFindBestWatchCell(spot, attendee, true, out result, out chair))
            {
                if (!WatchBuildingUtility.TryFindBestWatchCell(spot as Thing, attendee, false, out result, out chair))
                {
                    return;
                }
            }

            int dir = spot.Rotation.Opposite.AsInt;

            if (chair != null)
            {
                IntVec3 newPos = chair.Position + GenAdj.CardinalDirections[dir];

                Job J = new Job(DefDatabase <JobDef> .GetNamed("AttendLesson"), spot, newPos, chair);
                J.playerForced            = true;
                J.ignoreJoyTimeAssignment = true;
                J.expiryInterval          = 9999;
                J.ignoreDesignations      = true;
                J.ignoreForbidden         = true;
                attendee.jobs.jobQueue.EnqueueLast(J);
                attendee.jobs.EndCurrentJob(JobCondition.Incompletable);
            }
            else
            {
                IntVec3 newPos = result + GenAdj.CardinalDirections[dir];

                Job J = new Job(DefDatabase <JobDef> .GetNamed("AttendLesson"), spot, newPos, result);
                J.playerForced            = true;
                J.ignoreJoyTimeAssignment = true;
                J.expiryInterval          = 9999;
                J.ignoreDesignations      = true;
                J.ignoreForbidden         = true;
                attendee.jobs.jobQueue.EnqueueLast(J);
                attendee.jobs.EndCurrentJob(JobCondition.Incompletable);
            }
        }
 public static void AbortLesson(Building_TeachingSpot spot, String reason)
 {
     if (spot != null)
     {
         spot.ChangeState(Building_TeachingSpot.State.notinuse);
     }
     Messages.Message(reason + " Aborting lesson.", MessageTypeDefOf.NegativeEvent);
 }
 public Dialog_ChooseIgnoredGroup(List <PawnIgnoreData> group, ref Building_TeachingSpot spot)
 {
     this.forcePause = true;
     this.doCloseX   = true;
     this.absorbInputAroundWindow = true;
     this.closeOnClickedOutside   = true;
     this.group = group;
     this.spot  = spot;
 }
        public static void TeachingComplete(Pawn teacher, Building_TeachingSpot spot)
        {
            spot.ChangeState(Building_TeachingSpot.State.lesson, Building_TeachingSpot.LessonState.finishing);

            spot.ChangeState(Building_TeachingSpot.State.lesson, Building_TeachingSpot.LessonState.finished);
            //altar.currentState = Building_SacrificialAltar.State.finished;

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

            Messages.Message("The lesson has finished.", TargetInfo.Invalid, MessageTypeDefOf.PositiveEvent);
        }
Beispiel #7
0
        public static void TeachingComplete(Pawn teacher, Building_TeachingSpot spot)
        {
            spot.ChangeState(Building_TeachingSpot.State.lesson, Building_TeachingSpot.LessonState.finishing);

            spot.ChangeState(Building_TeachingSpot.State.lesson, Building_TeachingSpot.LessonState.finished);
            //altar.currentState = Building_SacrificialAltar.State.finished;

            FactionBase factionBase = (FactionBase)spot.Map.info.parent;

            Messages.Message("The lesson has finished.", TargetInfo.Invalid, MessageSound.Benefit);
        }
Beispiel #8
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));
        }
        public static bool ShouldAttendLesson(Pawn p, Building_TeachingSpot spot)
        {
            if (!IsActorAvailable(spot.teacher))
            {
                AbortLesson(spot);
                return(false);
            }
            //Everyone get over here!
            if (p != spot.teacher && p.IsColonistPlayerControlled == true)
            {
                return(true);
            }

            return(false);
        }
        public static void GetLessonGroup(Building_TeachingSpot spot, Map map, bool forced = false)
        {
            Room room = spot.GetRoom();

            if (room.Role != RoomRoleDefOf.PrisonBarracks && room.Role != RoomRoleDefOf.PrisonCell)
            {
                List <Pawn> listeners = new List <Pawn>();
                if (forced)
                {
                    listeners = map.mapPawns.AllPawnsSpawned.FindAll(x => x.RaceProps.intelligence == Intelligence.Humanlike && !x.Downed && !x.Dead &&
                                                                     x.CurJob.def.defName != "AttendLesson" &&
                                                                     x.CurJob.def != JobDefOf.ExtinguishSelf &&
                                                                     x.CurJob.def != JobDefOf.Rescue &&
                                                                     x.CurJob.def != JobDefOf.TendPatient &&
                                                                     x.CurJob.def != JobDefOf.BeatFire &&
                                                                     !spot.ignored.Contains(x) &&
                                                                     x.CurJob.def != JobDefOf.FleeAndCower &&
                                                                     (x.GetCaravan() == null || x.GetCaravan().IsPlayerControlled == true) &&
                                                                     !x.InAggroMentalState && !x.InMentalState);
                }
                else
                {
                    listeners = map.mapPawns.AllPawnsSpawned.FindAll(x => x.RaceProps.intelligence == Intelligence.Humanlike && !x.Downed && !x.Dead &&
                                                                     x.CurJob.def.defName != "AttendLesson" &&
                                                                     x.CurJob.def != JobDefOf.ExtinguishSelf &&
                                                                     x.CurJob.def != JobDefOf.Rescue &&
                                                                     x.CurJob.def != JobDefOf.TendPatient &&
                                                                     x.CurJob.def != JobDefOf.BeatFire &&
                                                                     x.CurJob.def != JobDefOf.Lovin &&
                                                                     x.CurJob.def != JobDefOf.LayDown &&
                                                                     !spot.ignored.Contains(x) &&
                                                                     (x.GetCaravan() == null || x.GetCaravan().IsPlayerControlled == true) &&
                                                                     x.CurJob.def != JobDefOf.FleeAndCower &&
                                                                     !x.InAggroMentalState && !x.InMentalState);
                }
                bool[] flag = new bool[listeners.Count];
                for (int i = 0; i < listeners.Count; i++)
                {
                    if (!flag[i] && TeachingUtility.ShouldAttendLesson(listeners[i], spot))
                    {
                        GiveAttendLessonJob(spot, listeners[i]);
                        flag[i] = true;
                    }
                }
            }
        }
Beispiel #11
0
        public static void listHours(Building_TeachingSpot spot)
        {
            List <FloatMenuOption> list           = new List <FloatMenuOption>();
            List <int>             availableHours = new List <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 });


            foreach (int i in availableHours)
            {
                list.Add(new FloatMenuOption(i.ToString() + ":00h", delegate
                {
                    spot.lessonHour = i;
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }


            Find.WindowStack.Add(new FloatMenu(list));
        }
        public Dialog_ChooseIgnored(Building_TeachingSpot spot)
        {
            this.forcePause = true;
            this.doCloseX   = true;
            this.absorbInputAroundWindow = true;
            this.closeOnClickedOutside   = true;
            this.spot       = spot;
            this.ignoreTemp = IncidentWorker_SetLeadership.getAllColonists();


            foreach (Pawn p in this.ignoreTemp)
            {
                if (this.spot.ignored.Contains(p))
                {
                    tempPawnList.Add(new PawnIgnoreData(p, true));
                }
                else
                {
                    tempPawnList.Add(new PawnIgnoreData(p, false));
                }
            }
        }
Beispiel #13
0
        public static void DrawCard(Rect rect, Building_TeachingSpot spot)
        {
            //GUI.BeginGroup(rect);
            //Rect position = new Rect(0f, 0f, rect.width, 65f);
            Rect position = rect;

            hourWidth = 20.833334f;
            float num  = 15f;
            float num2 = 250f;

            Text.Font = GameFont.Medium;
            Rect title = new Rect(rect.x + 5, rect.y + 5, rect.width, rect.height);

            Widgets.Label(title, "LessonSchedule".Translate());

            Text.Font = GameFont.Small;

            Rect text = new Rect(rect.x + 5, rect.y + 40, 300f, 240f);

            Widgets.Label(text, "ScheduleText".Translate());


            Rect seasonLabel = new Rect(rect.x + 110f, rect.y + 5 + 230f, 150f, 200f);

            Widgets.Label(seasonLabel, "SeasonDays".Translate());

            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.LowerLeft;


            for (int i = 1; i <= 15; i++)
            {
                Rect rect2 = new Rect(num + 4f, num2 + 0f, hourWidth, 30f);
                Widgets.Label(rect2, i.ToString());
                Rect rect3 = new Rect(num, num2 + 30f, hourWidth, 30f);
                DoTimeAssignment(rect3, i - 1, spot);
                num += hourWidth;
            }

            Text.Anchor = TextAnchor.UpperLeft;
            float dist = 25f;


            Rect   button = new Rect(rect.x + dist, rect.y + 175, 140f, 30f);
            String name   = (spot.teachers[0] == null ? "NoneL".Translate() : spot.teachers[0].Name.ToStringShort);

            if (Widgets.ButtonText(button, "RedTeacher".Translate() + name, true, false, true))
            {
                listPawns(0, spot);
            }

            Rect   button2 = new Rect(rect.x + dist + 150f, rect.y + 175, 140f, 30f);
            String name2   = (spot.teachers[1] == null ? "NoneL".Translate() : spot.teachers[1].Name.ToStringShort);

            if (Widgets.ButtonText(button2, "BlueTeacher".Translate() + name2, true, false, true))
            {
                listPawns(1, spot);
            }

            Rect   button3 = new Rect(rect.x + dist, rect.y + 135f, 140f, 30f);
            String hour    = spot.lessonHour.ToString() + ":00h";

            if (Widgets.ButtonText(button3, "LessonStart".Translate() + hour, true, false, true))
            {
                listHours(spot);
            }

            Rect button4 = new Rect(rect.x + dist + 150f, rect.y + 135f, 140f, 30f);

            if (Widgets.ButtonText(button4, "IgnoreList".Translate(), true, false, true))
            {
                Find.WindowStack.Add(new Dialog_ChooseIgnored(spot)); //
            }


            // GUI.EndGroup();
        }