Esempio n. 1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Career job = Career;

            LawEnforcement lawCareer = job as LawEnforcement;

            if (lawCareer != null)
            {
                SimDescription partner = lawCareer.Partner;
                if (partner != null)
                {
                    if (IsValidPartner(lawCareer, partner, false))
                    {
                        try
                        {
                            job.AddCoworker(partner);
                        }
                        catch (Exception e)
                        {
                            Common.Exception(Career.OwnerDescription, partner, e);
                        }
                    }
                }
            }

            base.PrivateUpdate(frame);

            if (lawCareer != null)
            {
                if (!IsValidPartner(lawCareer, lawCareer.Partner, false))
                {
                    lawCareer.Partner = null;

                    if (job.Coworkers != null)
                    {
                        foreach (SimDescription coworker in job.Coworkers)
                        {
                            if (HandlePartner(lawCareer, coworker, SimTypes.IsSelectable(Sim)))
                            {
                                break;
                            }
                        }
                    }

                    if (lawCareer.Partner == null)
                    {
                        HandlePartner(lawCareer, lawCareer.Boss, SimTypes.IsSelectable(Sim));
                    }
                }

                if (lawCareer.Partner != null)
                {
                    if (Relationship.AreStrangers(Sim, lawCareer.Partner))
                    {
                        Relationship.Get(Sim, lawCareer.Partner, true).MakeAcquaintances();
                    }
                }
            }

            Careers.VerifyTone(Sim);
            return(mNewCoworkers.Count > 0);
        }
Esempio n. 2
0
        protected bool AddCoworker(Career job)
        {
            SimDescription newCoworker = null;

            if (!job.GetType().ToString().StartsWith("Sims3."))
            {
                List <SimDescription> previous = new List <SimDescription>(job.Coworkers);

                if (job.AddCoworker())
                {
                    foreach (SimDescription sim in job.Coworkers)
                    {
                        if (previous.Contains(sim))
                        {
                            continue;
                        }

                        newCoworker = sim;
                        break;
                    }
                }
            }
            else
            {
                List <SimDescription> candidateCoworkers = new List <SimDescription>();
                foreach (SimDescription sim in job.CareerLoc.Workers)
                {
                    if (IsValid(job, sim, true))
                    {
                        candidateCoworkers.Add(sim);
                    }
                }

                if (candidateCoworkers.Count == 0)
                {
                    foreach (CareerLocation location in job.Locations)
                    {
                        if (location == job.CareerLoc)
                        {
                            continue;
                        }

                        location.CheckWorkers();
                        foreach (SimDescription coworker in location.Workers)
                        {
                            if (IsValid(job, coworker, true))
                            {
                                candidateCoworkers.Add(coworker);
                            }
                        }
                    }
                }

                if (candidateCoworkers.Count > 0)
                {
                    newCoworker = RandomUtil.GetRandomObjectFromList(candidateCoworkers);
                    job.AddCoworker(newCoworker);
                }
            }

            if (newCoworker != null)
            {
                if (GetValue <MeetImmediatelyOption, bool>())
                {
                    Relationship.Get(job.OwnerDescription, newCoworker, true).MakeAcquaintances();
                }
                else
                {
                    Relationship.Get(job.OwnerDescription, newCoworker, true);
                }

                if (!SimTypes.IsSelectable(newCoworker))
                {
                    mNewCoworkers.Add(newCoworker);
                }

                IncStat("Added");
                return(true);
            }
            else
            {
                IncStat("No choices");
                return(false);
            }
        }