protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            try
            {
                if (mRequirement.mCareerSim != null)
                {
                    AcquireOccupationParameters parameters = new AcquireOccupationParameters(mRequirement.CareerLoc, false, false);
                    parameters.JumpStartJob   = true;
                    parameters.JumpStartLevel = mRequirement.CareerLevel.NextLevels[0];

                    Sim.AcquireOccupation(parameters);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(Sim, e);
                return(false);
            }

            if (mRequirement.mCareerSim == null)
            {
                Add(frame, new FindJobScenario(Sim, true, false), ScenarioResult.Start);

                mCareerSim = null;
            }
            else
            {
                if (Sim.Occupation != null)
                {
                    foreach (KeyValuePair <uint, DreamNodeInstance> instance in DreamsAndPromisesManager.sMajorWishes)
                    {
                        if (instance.Value.InputSubject == null)
                        {
                            continue;
                        }

                        if (instance.Value.InputSubject.mType != DreamNodePrimitive.InputSubjectType.Career)
                        {
                            continue;
                        }

                        OccupationNames career = (OccupationNames)instance.Value.InputSubject.EnumValue;
                        if (career != Sim.Occupation.Guid)
                        {
                            continue;
                        }

                        Sim.LifetimeWish = instance.Key;
                        break;
                    }
                }

                Add(frame, new CareerChangedScenario(Sim), ScenarioResult.Start);

                mRequirement.mCareerSim = null;
            }

            return(true);
        }
Beispiel #2
0
        public override void Reset()
        {
            base.Reset();

            UpdateCareer();

            if (Sim.Occupation == null)
            {
                if ((Sim.Elder) && (Sim.CareerManager != null) && (Sim.CareerManager.RetiredCareer != null))
                {
                    if (ManagerCareer.RetiredLocation != null)
                    {
                        mRetire = true;
                    }
                }
            }

            if (mRetire)
            {
                if ((ManagerCareer.RetiredLocation != null) && (!(Sim.CareerManager.Occupation is Careers.Retired)))
                {
                    Occupation retiredCareer = Sim.CareerManager.mRetiredCareer;
                    Sim.CareerManager.mRetiredCareer = null;

                    try
                    {
                        Sim.AcquireOccupation(new AcquireOccupationParameters(ManagerCareer.RetiredLocation, false, false));
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(Sim, e);
                    }
                    finally
                    {
                        Sim.CareerManager.mRetiredCareer = retiredCareer;
                    }
                }
                mRetire = false;
            }
        }
Beispiel #3
0
        public static bool Enroll(Sim sim, string unemployedName, CareerLocation location)
        {
            Occupation job        = sim.Occupation;
            Occupation retiredJob = sim.CareerManager.RetiredCareer;

            sim.CareerManager.mRetiredCareer = null;

            try
            {
                if (location.Career is School)
                {
                    sim.CareerManager.mJob = null;
                }

                if (!sim.AcquireOccupation(new AcquireOccupationParameters(location, true, false)))
                {
                    return(false);
                }

                NRaas.Gameplay.Careers.Unemployed unemployed = sim.Occupation as NRaas.Gameplay.Careers.Unemployed;
                if (unemployed != null)
                {
                    unemployed.UpdateName(unemployedName);
                }
                return(true);
            }
            finally
            {
                if (sim.CareerManager.mJob == null)
                {
                    sim.CareerManager.mJob = job;
                }

                sim.CareerManager.mRetiredCareer = retiredJob;
                sim.CareerManager.UpdateCareerUI();
            }
        }
Beispiel #4
0
        public static Sim CreateAnNPCPerformer(ShowStage ths)
        {
            Sim createdSim = null;
            Lot lotCurrent = null;

            OccupationNames[]           randomList           = new OccupationNames[] { OccupationNames.SingerCareer, OccupationNames.MagicianCareer, OccupationNames.PerformanceArtistCareer };
            AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(RandomUtil.GetRandomObjectFromList(randomList), false, true);
            bool flag = RandomUtil.CoinFlip();

            // Custom
            List <SimDescription> list = Household.AllTownieSimDescriptions(ValidPerformer);

            if (list.Count != 0)
            {
                SimDescription randomObjectFromList = RandomUtil.GetRandomObjectFromList(list);
                if (randomObjectFromList.CreatedSim == null)
                {
                    lotCurrent = ths.LotCurrent;
                    createdSim = randomObjectFromList.Instantiate(lotCurrent);
                }
                else
                {
                    createdSim = randomObjectFromList.CreatedSim;
                }
            }
            else
            {
                Sim servicePerformer = CreateServicePerformer(ths);
                if (servicePerformer != null)
                {
                    createdSim = servicePerformer;
                }
            }

            if (createdSim == null)
            {
                return(null);
            }

            GoToLot interaction = GoToLot.Singleton.CreateInstanceWithCallbacks(ths.LotCurrent, createdSim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, true, null, new Callback(GoToLotSuccess), new Callback(GoToLotFailure)) as GoToLot;

            if (createdSim.InteractionQueue != null)
            {
                Common.DebugNotify("Pushing GoToLot on " + createdSim.FullName);
                createdSim.InteractionQueue.Add(interaction);
            }

            if (createdSim.CareerManager == null)
            {
                return(null);
            }

            if (createdSim.CareerManager.OccupationAsPerformanceCareer == null)
            {
                try
                {
                    if (createdSim.WasCreatedByAService)
                    {
                        switch (createdSim.Service.ServiceType)
                        {
                        case ServiceType.Magician:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.MagicianCareer, false, true);
                            break;

                        case ServiceType.Singer:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.SingerCareer, false, true);
                            break;

                        case ServiceType.PerformanceArtist:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.PerformanceArtistCareer, false, true);
                            break;

                        default:
                            break;
                        }
                    }

                    createdSim.AcquireOccupation(occupationParameters);

                    int num = flag ? RandomUtil.GetInt(0x0, 0x5) : RandomUtil.GetInt(0x5, createdSim.Occupation.HighestLevel);
                    for (int i = 0x1; i < num; i++)
                    {
                        createdSim.CareerManager.Occupation.PromoteSim();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(createdSim, e);
                    return(null);
                }
            }
            return(createdSim);
        }
Beispiel #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <CareerLocation> schools = GetPotentials();

            if (schools.Count == 0)
            {
                IncStat("No Choice");
                return(false);
            }
            else
            {
                if ((Sim.CareerManager.School != null) &&
                    (schools.Contains(Sim.CareerManager.School.CareerLoc)))
                {
                    IncStat("Already Has");
                    return(false);
                }

                CareerLocation location = RandomUtil.GetRandomObjectFromList(schools);

                if ((Sim.CareerManager.School != null) &&
                    (location == Sim.CareerManager.School.CareerLoc))
                {
                    IncStat("Same");
                    return(false);
                }
                else
                {
                    Occupation job        = Sim.Occupation;
                    Occupation retiredJob = Sim.CareerManager.mRetiredCareer;

                    Sim.CareerManager.mJob           = null;
                    Sim.CareerManager.mRetiredCareer = null;

                    try
                    {
                        if (Sim.AcquireOccupation(new AcquireOccupationParameters(location, false, false)))
                        {
                            School school = Sim.CareerManager.School;
                            if (school != null)
                            {
                                school.mWhenCurLevelStarted = SimClock.Subtract(school.mWhenCurLevelStarted, TimeUnit.Days, 1);
                            }

                            return(true);
                        }
                        else
                        {
                            IncStat("Core Failure");
                            return(false);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(Sim, e);

                        IncStat("Exception Failure");
                        return(false);
                    }
                    finally
                    {
                        Sim.CareerManager.mJob           = job;
                        Sim.CareerManager.mRetiredCareer = retiredJob;
                    }
                }
            }
        }