Example #1
0
        public static void FixCareer(Occupation job, bool allowDrop, Logger log)
        {
            if (job == null) return;

            if (job.Coworkers != null)
            {
                for (int i = job.Coworkers.Count - 1; i >= 0; i--)
                {
                    SimDescription coworker = job.Coworkers[i];

                    if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription))
                    {
                        job.Coworkers.RemoveAt(i);

                        if (coworker == null)
                        {
                            if (log != null)
                            {
                                log(" Bad Coworker " + job.CareerName + " - <Invalid>");
                            }
                        }
                        else
                        {
                            if (log != null)
                            {
                                log(" Bad Coworker " + job.CareerName + " - " + coworker.FullName);
                            }
                        }
                    }
                }
            }

            if ((allowDrop) && (job is Career))
            {
                bool replace = false;

                if (job.CareerLoc == null)
                {
                    if (log != null)
                    {
                        log(" Bad Location " + job.CareerName + " - " + job.GetType().ToString());
                    }
                    replace = true;
                }
                else
                {
                    RabbitHole hole = job.CareerLoc.Owner;
                    if (hole == null)
                    {
                        if (log != null)
                        {
                            log(" Missing Rabbithole " + job.CareerName + " - " + job.GetType().ToString());
                        }
                        replace = true;
                    }
                    else
                    {
                        RabbitHole proxy = hole.RabbitHoleProxy;
                        if (proxy == null)
                        {
                            if (log != null)
                            {
                                log(" Missing Proxy " + job.CareerName + " - " + job.GetType().ToString());
                            }
                            replace = true;
                        }
                        else
                        {
                            if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) ||
                                (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0))
                            {
                                if (log != null)
                                {
                                    log(" Missing Slots " + job.CareerName + " - " + job.GetType().ToString());
                                }
                                replace = true;
                            }
                        }
                    }
                }

                if (replace)
                {
                    SimDescription me = job.OwnerDescription;

                    Occupation retiredJob = me.CareerManager.mRetiredCareer;

                    try
                    {
                        CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid);
                        if (location != null)
                        {
                            if (log != null)
                            {
                                log(" Location Replaced " + me.FullName);
                            }

                            if (job.CareerLoc != null)
                            {
                                job.CareerLoc.Workers.Remove(me);
                            }

                            job.CareerLoc = location;

                            location.Workers.Add(me);
                        }
                        else
                        {
                            if (log != null)
                            {
                                log(" Career Dropped " + me.FullName);
                            }

                            job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid);
                        }
                    }
                    finally
                    {
                        me.CareerManager.mRetiredCareer = retiredJob;
                    }
                }
            }
        }
Example #2
0
 public static void FixCareer(Occupation job, bool allowDrop)
 {
     try{
         if (job == null)
         {
             return;
         }
         if (job.Coworkers != null)
         {
             for (int i = job.Coworkers.Count - 1; i >= 0; i--)
             {
                 SimDescription coworker = job.Coworkers[i];
                 if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription))
                 {
                     job.Coworkers.RemoveAt(i);
                 }
             }
         }
         if ((allowDrop) && (job is Career))
         {
             bool replace = (false);
             if (job.CareerLoc == null)
             {
                 replace = (true);
             }
             else
             {
                 RabbitHole hole = job.CareerLoc.Owner;
                 if (hole == null)
                 {
                     replace = (true);
                 }
                 else
                 {
                     RabbitHole proxy = hole.RabbitHoleProxy;
                     if (proxy == null)
                     {
                         replace = (true);
                     }
                     else
                     {
                         if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) ||
                             (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0))
                         {
                             replace = (true);
                         }
                     }
                 }
             }
             if (replace)
             {
                 SimDescription me         = job.OwnerDescription;
                 Occupation     retiredJob = me.CareerManager.mRetiredCareer;
                 try{
                     CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid);
                     if (location != null)
                     {
                         if (job.CareerLoc != null)
                         {
                             job.CareerLoc.Workers.Remove(me);
                         }
                         job.CareerLoc = location;
                         location.Workers.Add(me);
                     }
                     else
                     {
                         job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid);
                     }
                 }finally{
                     me.CareerManager.mRetiredCareer = retiredJob;
                 }
             }
         }
     }catch (Exception exception) {
         //  Get stack trace for the exception. with source file information
         var st = new StackTrace(exception, true);
         //  Get the top stack frame
         var frame = st.GetFrame(0);
         //  Get the line number from the stack frame
         var line = frame.GetFileLineNumber();
         Alive.WriteLog(exception.Message + "\n\n" +
                        exception.StackTrace + "\n\n" +
                        exception.Source + "\n\n" +
                        line);
     }finally{
     }
 }
Example #3
0
        public static void FixCareer(Occupation job, bool allowDrop, Logger log)
        {
            if (job == null)
            {
                return;
            }

            if (job.Coworkers != null)
            {
                for (int i = job.Coworkers.Count - 1; i >= 0; i--)
                {
                    SimDescription coworker = job.Coworkers[i];

                    if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription))
                    {
                        job.Coworkers.RemoveAt(i);

                        if (coworker == null)
                        {
                            if (log != null)
                            {
                                log(" Bad Coworker " + job.CareerName + " - <Invalid>");
                            }
                        }
                        else
                        {
                            if (log != null)
                            {
                                log(" Bad Coworker " + job.CareerName + " - " + coworker.FullName);
                            }
                        }
                    }
                }
            }

            if ((allowDrop) && (job is Career))
            {
                bool replace = false;

                if (job.CareerLoc == null)
                {
                    if (log != null)
                    {
                        log(" Bad Location " + job.CareerName + " - " + job.GetType().ToString());
                    }
                    replace = true;
                }
                else
                {
                    RabbitHole hole = job.CareerLoc.Owner;
                    if (hole == null)
                    {
                        if (log != null)
                        {
                            log(" Missing Rabbithole " + job.CareerName + " - " + job.GetType().ToString());
                        }
                        replace = true;
                    }
                    else
                    {
                        RabbitHole proxy = hole.RabbitHoleProxy;
                        if (proxy == null)
                        {
                            if (log != null)
                            {
                                log(" Missing Proxy " + job.CareerName + " - " + job.GetType().ToString());
                            }
                            replace = true;
                        }
                        else
                        {
                            if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) ||
                                (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0))
                            {
                                if (log != null)
                                {
                                    log(" Missing Slots " + job.CareerName + " - " + job.GetType().ToString());
                                }
                                replace = true;
                            }
                        }
                    }
                }

                if (replace)
                {
                    SimDescription me = job.OwnerDescription;

                    Occupation retiredJob = me.CareerManager.mRetiredCareer;

                    try
                    {
                        CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid);
                        if (location != null)
                        {
                            if (log != null)
                            {
                                log(" Location Replaced " + me.FullName);
                            }

                            if (job.CareerLoc != null)
                            {
                                job.CareerLoc.Workers.Remove(me);
                            }

                            job.CareerLoc = location;

                            location.Workers.Add(me);
                        }
                        else
                        {
                            if (log != null)
                            {
                                log(" Career Dropped " + me.FullName);
                            }

                            job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid);
                        }
                    }
                    finally
                    {
                        me.CareerManager.mRetiredCareer = retiredJob;
                    }
                }
            }
        }