Beispiel #1
0
        public static Occupation ImportJobContent(CareerManager ths, uint key, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader)
        {
            Occupation            occupation = null;
            IPropertyStreamReader child      = reader.GetChild(key);

            if (child != null)
            {
                ulong num;
                child.ReadUint64(0xae293ba5, out num, 0L);

                // Custom, EA Standard occupations are handled by EA
                if (Enum.IsDefined(typeof(OccupationNames), num))
                {
                    return(null);
                }

                {
                    OccupationNames guid = (OccupationNames)num;
                    if (guid != OccupationNames.Undefined)
                    {
                        Occupation staticOccupation = CareerManager.GetStaticOccupation(guid);
                        if (staticOccupation != null)
                        {
                            occupation = staticOccupation.Clone();
                            occupation.OwnerDescription = ths.mSimDescription;
                            occupation.ImportContent(resKeyTable, objIdTable, child);
                        }
                    }
                }
            }

            return(occupation);
        }
Beispiel #2
0
            public void SetDefaults(OccupationNames name)
            {
                Career career = CareerManager.GetStaticCareer(name);

                if (career != null)
                {
                    foreach (string branch in career.CareerLevels.Keys)
                    {
                        if (branch != mBranch)
                        {
                            continue;
                        }

                        foreach (KeyValuePair <int, CareerLevel> level in career.CareerLevels[branch])
                        {
                            if (level.Key == mLevel)
                            {
                                CareerLevelSettings settings = new CareerLevelSettings();
                                settings.mBranch         = mBranch;
                                settings.mLevel          = mLevel;
                                settings.mPayPerHourBase = level.Value.PayPerHourBase;
                                settings.mCarpoolType    = level.Value.CarpoolType;

                                mDefaults = settings;
                            }
                        }
                    }
                }
            }
		public List<OccupationName> Get(OccupationNames request)
		{
			OccupationNameRepository repository = GetOccupationNameRepository();
			List<OccupationNameEntity> entities = repository.Read();

			return entities.TranslateToResponse();
		}
        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 #5
0
        public bool IsCareer(OccupationNames job)
        {
            if (Sim.Occupation == null)
            {
                return(false);
            }

            return(Sim.Occupation.Guid == job);
        }
Beispiel #6
0
            public void Parse(string key, OnPopulate populate)
            {
                XmlDbData careerFile = XmlDbData.ReadData(key);

                if ((careerFile != null) && (careerFile.Tables != null) && (careerFile.Tables.ContainsKey("CareerData")))
                {
                    XmlDbTable table = careerFile.Tables["CareerData"];

                    foreach (XmlDbRow row in table.Rows)
                    {
                        string guid = row.GetString("Career");

                        string branch = row.GetString("Branch");
                        if (string.IsNullOrEmpty(branch))
                        {
                            branch = "Base";
                        }

                        int level = row.GetInt("Level");
                        if (level == 1)
                        {
                            continue;
                        }

                        OccupationNames careerGuid = OccupationNames.Undefined;
                        ParserFunctions.TryParseEnum <OccupationNames>(guid, out careerGuid, OccupationNames.Undefined);

                        if (careerGuid == OccupationNames.Undefined)
                        {
                            careerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(guid));
                        }

                        Dictionary <int, Dictionary <string, TData> > levels;
                        if (!mLevels.TryGetValue(careerGuid, out levels))
                        {
                            levels = new Dictionary <int, Dictionary <string, TData> >();
                            mLevels.Add(careerGuid, levels);
                        }

                        Dictionary <string, TData> branches;
                        if (!levels.TryGetValue(level, out branches))
                        {
                            branches = new Dictionary <string, TData>();
                            levels.Add(level, branches);
                        }

                        if (branches.ContainsKey(branch))
                        {
                            continue;
                        }

                        branches.Add(branch, populate(row));
                    }
                }
            }
Beispiel #7
0
            public int GetFee(OccupationNames school)
            {
                SchoolFee fee = Value.Find(item => { return(item.mSchool == school); });

                if (fee == null)
                {
                    return(0);
                }

                return(fee.mValue);
            }
Beispiel #8
0
        protected bool AskForJob(SimDescription sim, OccupationNames careerName)
        {
            Occupation occupation = CareerManager.GetStaticOccupation(careerName);

            if (occupation == null)
            {
                IncStat("Bad Occupation");
                return(false);
            }

            return(AskForJob(sim, occupation));
        }
Beispiel #9
0
        protected bool AcquireOccupation(CareerManager ths, AcquireOccupationParameters occupationParameters)
        {
            Occupation occupation;

            Sim createdSim = ths.mSimDescription.CreatedSim;

            CareerLocation  location   = occupationParameters.Location;
            OccupationNames newJobGuid = occupationParameters.TargetJob;

            if ((ths.mJob != null) && (location != null) && (ths.mJob.Guid == location.Career.Guid) && (ths.mJob.CareerLoc != location))
            {
                Career mJob = ths.mJob as Career;
                if ((mJob != null) && (mJob.TransferBetweenCareerLocations(location, false)))
                {
                    IncStat("Transferred");
                    return(true);
                }
            }

            if (!ths.TryGetNewCareer(newJobGuid, out occupation))
            {
                IncStat("TryGetNewCareer Fail");
                return(false);
            }

            if (ths.mJob != null)
            {
                if (createdSim != null)
                {
                    EventTracker.SendEvent(new TransferCareerEvent(createdSim, ths.mJob, occupation));
                }
                ths.mJob.LeaveJob(false, Career.LeaveJobReason.kTransfered);
            }

            EventTracker.SendEvent(EventTypeId.kCareerNewJob, createdSim);
            occupation.OwnerDescription        = ths.mSimDescription;
            occupation.mDateHired              = SimClock.CurrentTime();
            occupation.mAgeWhenJobFirstStarted = ths.mSimDescription.Age;
            occupation.SetAttributesForNewJob(location, occupationParameters.LotId, occupationParameters.CharacterImportRequest);
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerHired, occupation));
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerChanged, occupation));
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kCareerDataChanged, occupation));
            occupation.RefreshMapTagForOccupation();
            ths.UpdateCareerUI();

            if ((createdSim != null) && createdSim.IsActiveSim)
            {
                HudController.SetInfoState(InfoState.Career);
            }

            IncStat("Job Acquired " + occupation.Guid);
            return(true);
        }
Beispiel #10
0
        protected CareerLocation FindClosestCareerLocation(SimDescription s, OccupationNames careerName)
        {
            if (s.Household == null)
            {
                IncStat("No Household");
                return(null);
            }

            Career staticCareer = CareerManager.GetStaticCareer(careerName);

            if (staticCareer == null)
            {
                IncStat("Career Fail");
                return(null);
            }

            Lot lotHome = s.Household.LotHome;

            if (lotHome == null)
            {
                if (staticCareer.Locations.Count > 0x0)
                {
                    return(RandomUtil.GetRandomObjectFromList <CareerLocation>(staticCareer.Locations));
                }
                else
                {
                    IncStat("No Lot Home");
                    return(null);
                }
            }

            CareerLocation location         = null;
            float          bestDistance     = float.MaxValue;
            float          distanceToObject = 0f;

            foreach (CareerLocation location2 in staticCareer.Locations)
            {
                if (!GetLotOptions(location2.Owner.LotCurrent).AllowCastes(this, s))
                {
                    continue;
                }

                distanceToObject = lotHome.GetDistanceToObject(location2.Owner.RabbitHoleProxy);
                if (distanceToObject < bestDistance)
                {
                    location     = location2;
                    bestDistance = distanceToObject;
                }
            }

            return(location);
        }
        protected override string LocalizeValue(OccupationNames value)
        {
            Occupation career = CareerManager.GetStaticOccupation(value);

            if (career != null)
            {
                return(career.GetLocalizedCareerName(false));
            }
            else
            {
                return(base.LocalizeValue(value));
            }
        }
Beispiel #12
0
 public void UpdateCareer()
 {
     if (Sim.Occupation != null)
     {
         mCareer      = Sim.Occupation.Guid;
         mCareerLevel = Sim.Occupation.CareerLevel;
     }
     else
     {
         mCareer      = OccupationNames.Undefined;
         mCareerLevel = 0;
     }
 }
Beispiel #13
0
        public void Add(OccupationNames occupation, int score)
        {
            int value = 0;

            if (!mScores.TryGetValue(occupation, out value))
            {
                mScores.Add(occupation, score);
            }
            else
            {
                mScores[occupation] = value + score;
            }
        }
Beispiel #14
0
 public void UpdateCareer()
 {
     if (Sim.Occupation != null)
     {
         mCareer = Sim.Occupation.Guid;
         mCareerLevel = Sim.Occupation.CareerLevel;
     }
     else
     {
         mCareer = OccupationNames.Undefined;
         mCareerLevel = 0;
     }
 }
Beispiel #15
0
        public static bool Contains(List<DreamJob> jobs, OccupationNames career)
        {
            foreach (DreamJob job in jobs)
            {
                if (job == null) continue;

                if (job.mCareer == career)
                {
                    return true;
                }
            }

            return false;
        }
Beispiel #16
0
        public CareerTransfer(XmlDbRow row, Dictionary <string, Dictionary <int, CareerLevel> > careerLevels, string careerName)
            : base(row, careerLevels, null)
        {
            mStringKey = "NRaas.CareerTransfer:" + row.GetString("EventType");

            if (row.Exists("TransferCareer"))
            {
                string guid = row.GetString("TransferCareer");

                ParserFunctions.TryParseEnum <OccupationNames>(guid, out mTransferCareer, OccupationNames.Undefined);

                if (mTransferCareer == OccupationNames.Undefined)
                {
                    mTransferCareer = unchecked ((OccupationNames)ResourceUtils.HashString64(guid));
                }
            }

            if (row.Exists("TransferBranch"))
            {
                mTransferBranch = row.GetString("TransferBranch");
            }

            if (row.Exists("TransferLevelAbsolute"))
            {
                mAbsoluteLevel = row.GetInt("TransferLevelAbsolute");
            }

            if (row.Exists("TransferLevelRelative"))
            {
                string relativeLevel = row.GetString("TransferLevelRelative");

                List <string> relativeLevels = new List <string>(relativeLevel.Split(new char[] { ':' }));

                mRelativeLevelMin = int.Parse(relativeLevels[0]);
                if (relativeLevels.Count > 1)
                {
                    mRelativeLevelMax = int.Parse(relativeLevels[1]);
                }
                else
                {
                    if (mRelativeLevelMin > 0)
                    {
                        mRelativeLevelMax = mRelativeLevelMin;
                        mRelativeLevelMin = 0;
                    }
                }
            }
        }
Beispiel #17
0
        public CareerTransfer(XmlDbRow row, Dictionary<string, Dictionary<int, CareerLevel>> careerLevels, string careerName)
            : base(row, careerLevels, null)
        {
            mStringKey = "NRaas.CareerTransfer:" + row.GetString("EventType");

            if (row.Exists("TransferCareer"))
            {
                string guid = row.GetString("TransferCareer");

                ParserFunctions.TryParseEnum<OccupationNames>(guid, out mTransferCareer, OccupationNames.Undefined);

                if (mTransferCareer == OccupationNames.Undefined)
                {
                    mTransferCareer = unchecked((OccupationNames)ResourceUtils.HashString64(guid));
                }
            }

            if (row.Exists("TransferBranch"))
            {
                mTransferBranch = row.GetString("TransferBranch");
            }

            if (row.Exists("TransferLevelAbsolute"))
            {
                mAbsoluteLevel = row.GetInt("TransferLevelAbsolute");
            }

            if (row.Exists("TransferLevelRelative"))
            {
                string relativeLevel = row.GetString("TransferLevelRelative");

                List<string> relativeLevels = new List<string>(relativeLevel.Split(new char[] { ':' }));
                
                mRelativeLevelMin = int.Parse(relativeLevels[0]);
                if (relativeLevels.Count > 1)
                {
                    mRelativeLevelMax = int.Parse(relativeLevels[1]);
                }
                else
                {
                    if (mRelativeLevelMin > 0)
                    {
                        mRelativeLevelMax = mRelativeLevelMin;
                        mRelativeLevelMin = 0;
                    }
                }
            }
        }
Beispiel #18
0
        public static bool Contains(List <DreamJob> jobs, OccupationNames career)
        {
            foreach (DreamJob job in jobs)
            {
                if (job == null)
                {
                    continue;
                }

                if (job.mCareer == career)
                {
                    return(true);
                }
            }

            return(false);
        }
        public CareerSettings GetCareerSettings(OccupationNames name, bool create)
        {
            CareerSettings result;

            if (mCareerSettings.TryGetValue(name, out result))
            {
                return(result);
            }
            else
            {
                if (create)
                {
                    return(new CareerSettings(name));
                }
            }

            return(null);
        }
        protected override bool PersistCreate(ref OccupationNames defValue, string value)
        {
            if (!ParserFunctions.TryParseEnum <OccupationNames>(value, out defValue, OccupationNames.Undefined))
            {
                ulong guid;
                if (ulong.TryParse(value, out guid))
                {
                    defValue = (OccupationNames)guid;

                    if (CareerManager.GetStaticOccupation(defValue) == null)
                    {
                        defValue = OccupationNames.Undefined;
                        return(false);
                    }
                }
            }

            return(true);
        }
Beispiel #21
0
        public CareerSettings GetCareerSettings(OccupationNames name, bool create)
        {
            CareerSettings result;

            if (mCareerSettings.TryGetValue(name, out result))
            {
                return(result);
            }
            else
            {
                if (create)
                {
                    CareerSettings settings = new CareerSettings(name);
                    CareerSettings cloned   = settings.mDefaults.Clone();
                    cloned.SetDefaults();
                    return(cloned);
                }
            }

            return(null);
        }
Beispiel #22
0
        protected override void Perform(BooterHelper.BootFile file, XmlDbRow row)
        {
            string toneName = row.GetString("ToneName");

            if (string.IsNullOrEmpty(toneName))
            {
                BooterLogger.AddError("Tone found with no name");
                return;
            }

            Type classType = row.GetClassType("FullClassName");

            if (classType == null)
            {
                BooterLogger.AddError("Tone: " + toneName + " FullClassName no match");
                return;
            }

            string guid = row.GetString("CareerGuid");

            OccupationNames careerGuid = OccupationNames.Undefined;

            ParserFunctions.TryParseEnum <OccupationNames>(guid, out careerGuid, OccupationNames.Undefined);

            if (careerGuid == OccupationNames.Undefined)
            {
                careerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(guid));
            }

            Career staticCareer = CareerManager.GetStaticCareer(careerGuid);

            if (staticCareer == null)
            {
                BooterLogger.AddError("Tone: " + toneName + " CareerGuid no match");
                return;
            }

            staticCareer.SharedData.ToneDefinitions.Add(new CareerBooterToneDefinition(row, classType));
        }
Beispiel #23
0
        public List <CareerLevelItem> GetLevelOptions(OccupationNames career)
        {
            List <CareerLevelItem> results = new List <CareerLevelItem>();

            Career career2 = CareerManager.GetStaticCareer(career);

            if (career2 == null)
            {
                return(results);
            }

            results.Add(new CareerLevelItem(new LevelData(career, string.Empty, -1), Common.Localize("Selection:All"), ThumbnailKey.kInvalidThumbnailKey));

            foreach (KeyValuePair <string, Dictionary <int, Sims3.Gameplay.Careers.CareerLevel> > staticData in career2.CareerLevels)
            {
                foreach (KeyValuePair <int, Sims3.Gameplay.Careers.CareerLevel> levelStaticData in staticData.Value)
                {
                    results.Add(new CareerLevelItem(new LevelData(career, staticData.Key, levelStaticData.Key), career2.Name + " - " + levelStaticData.Value.BranchName + " - " + Common.LocalizeEAString(false, levelStaticData.Value.mName) + " (" + EAText.GetNumberString(levelStaticData.Key) + ")", new ThumbnailKey(ResourceKey.CreatePNGKey(career2.CareerIconColored, ResourceUtils.ProductVersionToGroupId(ProductVersion.BaseGame)), ThumbnailSize.Medium)));
                }
            }

            return(results);
        }
Beispiel #24
0
        public override bool Parse(XmlDbRow row, ref string error)
        {
            if (row.Exists("CustomOccupation"))
            {
                mOccupation = unchecked ((OccupationNames)ResourceUtils.HashString64(row.GetString("CustomOccupation")));
            }
            else
            {
                if (!row.Exists("Occupation"))
                {
                    error = "Occupation missing";
                    return(false);
                }
                else if (!ParserFunctions.TryParseEnum <OccupationNames>(row.GetString("Occupation"), out mOccupation, OccupationNames.Undefined))
                {
                    error = "Unknown Occupation " + row.GetString("Occupation");
                    return(false);
                }
            }

            mBranch = row.GetString("Branch");

            return(base.Parse(row, ref error));
        }
Beispiel #25
0
            public void RevertToDefaults(OccupationNames name)
            {
                Career career = CareerManager.GetStaticCareer(name);

                if (career != null && mDefaults != null)
                {
                    foreach (string branch in career.CareerLevels.Keys)
                    {
                        if (branch != mBranch)
                        {
                            continue;
                        }

                        foreach (KeyValuePair <int, CareerLevel> level in career.CareerLevels[branch])
                        {
                            if (level.Key == mLevel)
                            {
                                level.Value.PayPerHourBase = mDefaults.mPayPerHourBase;
                                level.Value.CarpoolType    = mDefaults.mCarpoolType;
                            }
                        }
                    }
                }
            }
Beispiel #26
0
 public DreamJob(OccupationNames career)
 {
     mCareer = career;
 }
Beispiel #27
0
        public bool IsCareer(OccupationNames job)
        {
            if (Sim.Occupation == null) return false;

            return (Sim.Occupation.Guid == job);
        }
Beispiel #28
0
 public Item(OccupationNames value, string name, int count)
     : base(value, name, count)
 {
 }
Beispiel #29
0
 public CareerBooterElement(OccupationNames career, RabbitHoleType type)
 {
     mCareer = career;
     mType   = type;
 }
Beispiel #30
0
 public CareerDreamJob(OccupationNames career)
     : base(career)
 {
 }
Beispiel #31
0
        public CareerSettings GetCareerSettings(OccupationNames name, bool create)
        {
            CareerSettings result;
            if (mCareerSettings.TryGetValue(name, out result))
            {
                return result;
            }
            else
            {
                if (create)
                {
                    return new CareerSettings(name);
                }
            }

            return null;
        }
Beispiel #32
0
 public Homemaker(OccupationNames guid)
     : base(guid)
 {
 }
Beispiel #33
0
 public CareerLevelSettings(OccupationNames career, string branchName, int level)
 {
     mBranch = branchName;
     mLevel  = level;
     SetDefaults(career);
 }
Beispiel #34
0
 public DreamJobScoring(int hit, int miss, OccupationNames occupation)
     : base(hit, miss)
 {
     mOccupation = occupation;
 }
Beispiel #35
0
 public CareerSettings(OccupationNames name)
 {
     mName = name;
 }
Beispiel #36
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 #37
0
            protected override bool Allow(OccupationNames value)
            {
                School school = CareerManager.GetStaticCareer(value) as School;

                return(school != null);
            }
Beispiel #38
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 #39
0
        protected static bool AcquireOccupation(CareerManager ths, AcquireOccupationParameters occupationParameters, bool prompt)
        {
            CareerLocation  location   = occupationParameters.Location;
            OccupationNames newJobGuid = occupationParameters.TargetJob;

            if ((ths.mJob != null) && (location != null) && (ths.mJob.Guid == location.Career.Guid) && (ths.mJob.CareerLoc != location))
            {
                Career mJob = ths.mJob as Career;
                return((mJob != null) && mJob.TransferBetweenCareerLocations(location, false));
            }

            Occupation occupation = null;

            if (!ths.TryGetNewCareer(newJobGuid, out occupation))
            {
                return(false);
            }

            if (occupation is Career)
            {
                if (location == null)
                {
                    return(false);
                }
            }

            Sim createdSim = ths.mSimDescription.CreatedSim;

            if (ths.mJob != null)
            {
                if (prompt)
                {
                    string newJobName = string.Empty;
                    if (!occupation.TryDisplayingGetHiredUi(location, ref occupationParameters, out newJobName))
                    {
                        return(false);
                    }

                    if (!Occupation.ShowYesNoCareerOptionDialog(Common.LocalizeEAString(ths.mSimDescription.IsFemale, "Gameplay/Careers/Career:ConfirmLeavingOldCareer", new object[] { ths.mSimDescription, occupation.CareerName, ths.mJob.CareerName })))
                    {
                        return(false);
                    }
                }

                if (createdSim != null)
                {
                    EventTracker.SendEvent(new TransferCareerEvent(createdSim, ths.mJob, occupation));
                }
                ths.mJob.LeaveJob(false, Career.LeaveJobReason.kTransfered);
            }

            if (newJobGuid == OccupationNames.AcademicCareer)
            {
                AcademicCareer.EnrollSimInAcademicCareer(ths.mSimDescription, ths.DegreeManager.EnrollmentAcademicDegreeName, ths.DegreeManager.EnrollmentCouseLoad);
            }
            else
            {
                EventTracker.SendEvent(EventTypeId.kCareerNewJob, createdSim);
                occupation.OwnerDescription        = ths.mSimDescription;
                occupation.mDateHired              = SimClock.CurrentTime();
                occupation.mAgeWhenJobFirstStarted = ths.mSimDescription.Age;

                occupation.SetAttributesForNewJob(location, occupationParameters.LotId, occupationParameters.CharacterImportRequest);

                EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerHired, occupation));
                EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerChanged, occupation));
                EventTracker.SendEvent(new CareerEvent(EventTypeId.kCareerDataChanged, occupation));
            }

            occupation.RefreshMapTagForOccupation();
            ths.UpdateCareerUI();

            if ((createdSim != null) && createdSim.IsActiveSim)
            {
                HudController.SetInfoState(InfoState.Career);
            }

            return(true);
        }
Beispiel #40
0
 public CareerBooterElement(OccupationNames career, RabbitHoleType type)
 {
     mCareer = career;
     mType = type;
 }
Beispiel #41
0
 public CareerDreamJob(OccupationNames career)
     : base (career)
 { }