//GetRoster gets all open and manned jobs
        private SortedDictionary <string, int> GetRoster(Players.Player player, Colony colony)
        {
            SortedDictionary <string, int> roster = new SortedDictionary <string, int>();

            JobTracker.JobFinder jf = (JobTracker.JobFinder)JobTracker.GetOrCreateJobFinder(player);
            List <IJob>          oj = jf.openJobs;

            foreach (IJob j in oj)
            {
                if (roster.ContainsKey(j.NPCType.ToString()))
                {
                    roster[j.NPCType.ToString()]++;
                }
                else
                {
                    roster.Add(j.NPCType.ToString(), 0);
                }
            }
            foreach (NPCBase follower in colony.Followers)
            {
                if (follower.Job != null)
                {
                    string npc = follower.Job.NPCType.ToString();
                    if (roster.ContainsKey(npc))
                    {
                        roster[npc]++;
                    }
                    else
                    {
                        if (follower.Job.NeedsNPC)
                        {
                            roster.Add(npc, 0);
                        }
                        else
                        {
                            roster.Add(npc, 1);
                        }
                    }
                }
                else
                {
                    if (roster.ContainsKey("Laborer"))
                    {
                        roster["Laborer"]++;
                    }
                    else
                    {
                        roster.Add("Laborer", 1);
                    }
                }
            }
            return(roster);
        }
Example #2
0
        private static void SetPriorityJobs(Colony colony)
        {
            SortedDictionary <string, IJob> current = new SortedDictionary <string, IJob>();

            JobTracker.JobFinder jobfinder = JobTracker.GetOrCreateJobFinder(colony.Owner) as JobTracker.JobFinder;

            foreach (NPCBase follower in colony.Followers)
            {
                if (follower.Job != null)
                {
                    follower.Job.NPC = null;
                    follower.ClearJob();
                }
            }

            IJob[] openjobs = jobfinder.openJobs.ToArray();
            int    count    = 0;

            Logger.Log("{0} ", openjobs.Length.ToString());
            foreach (string o in PlayerState.GetPlayerState(colony.Owner).LineUp)
            {
                count = 0;
                while (count < openjobs.Length)
                {
                    IJob j = openjobs[count];
                    if (o == j.NPCType.ToString() && j.NeedsNPC)
                    {
                        foreach (NPCBase follower in colony.Followers)
                        {
                            if (follower.Job == null)
                            {
                                Logger.Log("Job set to : {0}", j.NPCType.ToString());
                                follower.TakeJob(j);
                                break;
                            }
                        }
                    }
                    count++;
                }
            }
        }