コード例 #1
0
ファイル: ManagerHousehold.cs プロジェクト: yakoder/NRaas
        public bool MoveSim(SimDescription sim, Household moveTo)
        {
            if (sim.Household == moveTo)
            {
                return(true);
            }

            if (sim.Household != null)
            {
                if (sim.CreatedSim != null)
                {
                    try
                    {
                        if ((sim.CreatedSim.Autonomy != null) && (sim.CreatedSim.Autonomy.Motives == null))
                        {
                            sim.CreatedSim.Autonomy.RecreateAllMotives();

                            IncStat("Motives Recreated");
                        }

                        if (sim.CreatedSim.LotCurrent == null)
                        {
                            sim.CreatedSim.InternalOnSetLotCurrent(null);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(sim, e);

                        Sims.Reset(sim);
                    }
                }

                Household oldHouse = sim.Household;

                ProcessAbandonHouse(oldHouse, moveTo);

                sim.Household.Remove(sim);

                foreach (SimDescription member in HouseholdsEx.All(oldHouse))
                {
                    GetData(member).InvalidateCache();
                }
            }

            moveTo.Add(sim);

            foreach (SimDescription member in HouseholdsEx.All(moveTo))
            {
                GetData(member).InvalidateCache();
            }

            ManagerSim.ForceRecount();

            SetValue <InspectedOption, bool>(moveTo, false);

            Sims.Instantiate(sim, moveTo.LotHome, true);

            return(sim.Household == moveTo);
        }
コード例 #2
0
ファイル: CareerPushScenario.cs プロジェクト: yakoder/NRaas
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Sim sim = Sim.CreatedSim;

            if (sim == null)
            {
                Sims.Instantiate(Sim, null, false);

                sim = Sim.CreatedSim;
            }

            if (sim == null)
            {
                IncStat("Hibernating");
                return(false);
            }

            Career job = Occupation as Career;

            Careers.VerifyTone(job);

            if (!ManagerCareer.ValidCareer(job))
            {
                IncStat("Career Invalidated");
                return(false);
            }

            InteractionInstance instance = GetWorkInteraction(job);

            if (instance == null)
            {
                IncStat("No Interaction");
                return(false);
            }
            else if (!Test(sim, instance.InteractionDefinition))
            {
                return(false);
            }
            else
            {
                if (sim.InteractionQueue.Add(instance))
                {
                    if (GetValue <AllowGoHomePushOption, bool>(Sim))
                    {
                        Manager.AddAlarm(new GoHomePushScenario(Sim));
                    }
                }
                else
                {
                    IncStat("Failure");
                }

                mReport = PostSlackerWarning();
                return(true);
            }
        }
コード例 #3
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            PregnancySimData other = data.Get <PregnancySimData>();

            if (sim.IsPregnant)
            {
                if ((other.mLastCheckPregnancy != 0) && (other.mLastCheckPregnancy < SimClock.ElapsedCalendarDays()))
                {
                    if (!AllowProgression(sim))
                    {
                        // Delay pregnancy indefinitely
                        sim.Pregnancy.mHourOfPregnancy = other.mPregnancyHour;

                        IncStat("Pregnancy Suspended");
                    }
                    else
                    {
                        if (other.mPregnancyHour == sim.Pregnancy.mHourOfPregnancy)
                        {
                            IncStat(sim.FirstName + " " + sim.LastName + ": Stuck Pregnancy", Common.DebugLevel.High);

                            if (!SimTypes.IsSelectable(sim))
                            {
                                Sims.Reset(sim);

                                if ((sim.CreatedSim != null) && (sim.LotHome != null))
                                {
                                    SimDescription dad = ManagerSim.Find(sim.Pregnancy.DadDescriptionId);
                                    if (dad != null)
                                    {
                                        Sims.Instantiate(dad, sim.LotHome, false);
                                    }

                                    if (sim.Pregnancy.PreggersAlarm != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(sim.Pregnancy.PreggersAlarm);
                                        sim.Pregnancy.PreggersAlarm = AlarmHandle.kInvalidHandle;
                                    }
                                    sim.Pregnancy.Continue(sim.CreatedSim, true);

                                    IncStat("Pregnancy Reset");
                                }
                            }
                        }
                    }
                }

                other.mPregnancyHour      = sim.Pregnancy.mHourOfPregnancy;
                other.mLastCheckPregnancy = SimClock.ElapsedCalendarDays();
            }
            else
            {
                other.mPregnancyHour      = 0;
                other.mLastCheckPregnancy = 0;
            }
        }
コード例 #4
0
ファイル: HaveBabyBaseScenario.cs プロジェクト: yakoder/NRaas
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Sim.CreatedSim == null)
            {
                Sims.Instantiate(Sim, Sim.LotHome, false);
            }

            if (Target.CreatedSim == null)
            {
                Sims.Instantiate(Target, Target.LotHome, false);
            }

            if ((Sim.CreatedSim == null) || (Target.CreatedSim == null))
            {
                IncStat("Uninstantiated");
                return(false);
            }
            else
            {
                if (Sim.IsRobot)
                {
                    if ((Sim.LotHome == null) ||
                        ((Sim.LotHome.CountObjects <BotMakingStation> () + Sim.LotHome.CountObjects <InventionWorkbench>()) == 0))
                    {
                        IncStat("No Workbench");
                        return(false);
                    }

                    SimDescription child = null;
                    if (Sim.IsFrankenstein)
                    {
                        bool reward = Sim.OccultManager.mIsLifetimeReward;

                        if ((Target.IsFrankenstein) && (RandomUtil.CoinFlip()))
                        {
                            reward = Target.OccultManager.mIsLifetimeReward;
                        }

                        Sim childSim = OccultFrankenstein.CreateFrankenStein(Sim.CreatedSim, CASAgeGenderFlags.None, reward);
                        if (childSim == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        child = childSim.SimDescription;
                    }
                    else
                    {
                        child = OccultRobot.MakeRobot(CASAgeGenderFlags.Adult, CASAgeGenderFlags.None, RobotForms.MaxType);
                        if (child == null)
                        {
                            IncStat("Creation Fail");
                            return(false);
                        }

                        CASRobotData supernaturalData = child.SupernaturalData as CASRobotData;
                        if (supernaturalData != null)
                        {
                            supernaturalData.CreatorSim = Sim.SimDescriptionId;

                            int quality = 0;
                            int count   = 0;

                            CASRobotData parentData = Sim.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality = parentData.BotQualityLevel;
                                count++;
                            }

                            parentData = Target.SupernaturalData as CASRobotData;
                            if (parentData != null)
                            {
                                quality += parentData.BotQualityLevel;
                                count++;
                            }

                            if (count == 2)
                            {
                                quality /= count;
                            }

                            supernaturalData.BotQualityLevel = quality;
                        }
                    }

                    if (child.Genealogy.Parents.Count == 0)
                    {
                        Sim.Genealogy.AddChild(child.Genealogy);
                    }

                    Target.Genealogy.AddChild(child.Genealogy);

                    if (!Households.MoveSim(child, Sim.Household))
                    {
                        IncStat("Move Fail");

                        Deaths.CleansingKill(child, true);

                        return(false);
                    }

                    return(true);
                }
                else if (Target.IsRobot)
                {
                    IncStat("Simbot Partner");
                    return(false);
                }
                else
                {
                    if (CommonSpace.Helpers.Pregnancies.Start(Sim.CreatedSim, Target, false) != null)
                    {
                        ManagerSim.ForceRecount();

                        if (Sim.IsHuman)
                        {
                            if (OnGatheringScenario != null)
                            {
                                OnGatheringScenario(this, frame);
                            }
                        }

                        if ((!Sim.IsHuman) && (Sim.Partner != Target))
                        {
                            if ((GetValue <AllowMarriageOption, bool>(Sim)) && (GetValue <AllowMarriageOption, bool>(Target)))
                            {
                                if ((Romances.AllowBreakup(this, Sim, Managers.Manager.AllowCheck.None)) && (Romances.AllowBreakup(this, Target, Managers.Manager.AllowCheck.None)))
                                {
                                    RemoveAllPetMateFlags(Sim);
                                    RemoveAllPetMateFlags(Target);
                                    Relationship.Get(Sim, Target, false).LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry);
                                }
                            }
                        }
                    }
                    return(true);
                }
            }
        }
コード例 #5
0
ファイル: FindJobScenario.cs プロジェクト: yakoder/NRaas
        protected bool AskForJob(SimDescription sim, Occupation occupation)
        {
            if ((sim.Occupation != null) && (sim.Occupation.Guid == occupation.Guid))
            {
                IncStat("Same Job");
                return(false);
            }

            Career career = occupation as Career;

            if (career != null)
            {
                if (!career.CareerAgeTest(sim))
                {
                    IncStat("Wrong Age");
                    return(false);
                }
            }

            if (!Careers.TestCareer(this, Sim, occupation.Guid))
            {
                IncStat("User Disallow " + occupation.CareerName);
                return(false);
            }

            AcquireOccupationParameters parameters;

            if (occupation is Career)
            {
                CareerLocation location = Career.FindClosestCareerLocation(sim, occupation.Guid);
                if (location == null)
                {
                    IncStat("No Location " + occupation.CareerName);
                    return(false);
                }
                else if (!AllowStandalone(location))
                {
                    IncStat("Standalone " + occupation.CareerName);
                    return(false);
                }
                else
                {
                    parameters = new AcquireOccupationParameters(location, false, false);
                }
            }
            else
            {
                parameters = new AcquireOccupationParameters(occupation.Guid, false, false);
            }

            try
            {
                if (sim.Occupation != null)
                {
                    if (sim.Occupation.Guid == occupation.Guid)
                    {
                        IncStat("Already In Job");
                        return(true);
                    }

                    if (sim.Occupation.CareerLoc != null)
                    {
                        foreach (SimDescription worker in sim.Occupation.CareerLoc.Workers)
                        {
                            if (worker.Occupation == null)
                            {
                                continue;
                            }

                            if (worker.Occupation.Coworkers == null)
                            {
                                worker.Occupation.Coworkers = new List <SimDescription>();
                            }
                        }
                    }

                    sim.Occupation.LeaveJobNow(Career.LeaveJobReason.kQuit);
                }

                Occupation retiredCareer = sim.CareerManager.mRetiredCareer;
                sim.CareerManager.mRetiredCareer = null;

                int originaHighest = 0;
                try
                {
                    if (occupation is ActiveFireFighter)
                    {
                        ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter);

                        originaHighest = activeCareerStaticData.HighestLevel;

                        // Required to bypass auto promotion in SetAttributesForNewJob
                        activeCareerStaticData.HighestLevel = 1;
                    }

                    if (occupation is XpBasedCareer)
                    {
                        // Required by Stylist.GetOccupationJoiningTnsTextPrefix()
                        if (!Sims.Instantiate(sim, sim.LotHome, false))
                        {
                            IncStat("Hibernating");
                            return(false);
                        }
                    }

                    if (AcquireOccupation(sim.CareerManager, parameters))
                    {
                        IncStat(occupation.Guid.ToString());
                        return(true);
                    }
                }
                finally
                {
                    sim.CareerManager.mRetiredCareer = retiredCareer;

                    if (occupation is ActiveFireFighter)
                    {
                        ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter);
                        activeCareerStaticData.HighestLevel = originaHighest;
                    }
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, e);
            }

            IncStat("Core Failure");
            return(false);
        }
コード例 #6
0
ファイル: MoveInLotScenario.cs プロジェクト: yakoder/NRaas
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            ManagerLot.FindLotFlags flags = Inspect;
            if (CheapestHome)
            {
                flags |= ManagerLot.FindLotFlags.CheapestHome;
            }

            Lot lot = Lots.FindLot(this, mMovers, MaximumLoan, flags, OnLotPriceCheck);

            if (lot == null)
            {
                IncStat("No Lot");
                return(false);
            }
            else if (lot.Household != null)
            {
                IncStat("Occupied");
                return(false);
            }

            int lotCost = Lots.GetLotCost(lot);

            AddStat("Lot Cost", lotCost);

            List <SimDescription> sims = new List <SimDescription>(mMovers);

            Dictionary <Household, bool> oldHouses = new Dictionary <Household, bool>();

            House = null;

            foreach (SimDescription sim in sims)
            {
                if (House == null)
                {
                    if (SimTypes.IsSpecial(sim))
                    {
                        break;
                    }
                    else if (HouseholdsEx.NumSims(sim.Household) == sims.Count)
                    {
                        House = sim.Household;
                    }
                }
                else if (House != sim.Household)
                {
                    House = null;
                    break;
                }
            }

            int newFunds = 0;

            Lot oldLot = null;

            mNewHouse = false;
            if (House == null)
            {
                House = Household.Create();
                House.ModifyFamilyFunds(-House.FamilyFunds);

                House.SetName(sims[0].LastName);

                SetValue <AcountingOption, AccountingData>(House, new AccountingData());

                mNewHouse = true;
            }
            else if (House.LotHome != null)
            {
                oldLot = House.LotHome;

                newFunds = Lots.GetLotCost(House.LotHome);

                Lots.ProcessAbandonLot(oldLot);

                House.MoveOut();
            }

            if (OnPresetLotHome != null)
            {
                OnPresetLotHome(lot, House);
            }
            lot.MoveIn(House);

            ManagerSim.ForceRecount();

            Money.AdjustFunds(House, "SellLot", newFunds);

            AddStat("New Home Funds", House.FamilyFunds);

            SetValue <InspectedOption, bool>(House, false);

            if (mNewHouse)
            {
                foreach (SimDescription sim in sims)
                {
                    if (sim.Household != null)
                    {
                        AdjustFundsMoveInLot(sim, oldHouses);
                    }

                    Households.MoveSim(sim, House);

                    if (sim.IsMale)
                    {
                        House.Name = sim.LastName;
                    }
                }
            }

            if (OnLotPriceCheck(this, lot, newFunds, newFunds) != ManagerLot.CheckResult.IgnoreCost)
            {
                PayForMoveInLot(oldHouses, lotCost);
            }

            AddStat("Remaining Funds", House.FamilyFunds);

            foreach (SimDescription sim in sims)
            {
                Sims.Instantiate(sim, lot, true);
            }

            EventTracker.SendEvent(new HouseholdUpdateEvent(EventTypeId.kFamilyMovedInToNewHouse, House));

            if ((oldLot != null) && (GetValue <NotifyOnMoveOption, bool>(House)))
            {
                if (AcceptCancelDialog.Show(Common.Localize("NotifyOnMove:Prompt", false, new object[] { oldLot.Name, oldLot.Address })))
                {
                    if (CameraController.IsMapViewModeEnabled())
                    {
                        Sims3.Gameplay.Core.Camera.ToggleMapView();
                    }

                    Camera.FocusOnLot(oldLot.LotId, 0f);
                }
            }

            SetValue <NotifyOnMoveOption, bool>(House, false);

            return(true);
        }
コード例 #7
0
        protected bool PrivatePerform()
        {
            if (!Sims.Instantiate(Sim, null, false))
            {
                return(false);
            }

            if (Sim.CreatedSim == null)
            {
                return(false);
            }

            bool DnP = (Sim.CreatedSim.DreamsAndPromisesManager != null);

            bool success = false;

            if (!DnP)
            {
                bool hadWish = Sim.HasLifetimeWish;

                try
                {
                    DreamsAndPromisesManager.CreateAndIntitForSim(Sim.CreatedSim);
                }
                catch (Exception e)
                {
                    Common.DebugException(Sim, e);
                }

                if (!hadWish)
                {
                    Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager);
                    if (Sim.HasLifetimeWish)
                    {
                        Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish();
                    }
                    success = true;
                }
            }

            if ((Sims.MatchesAlertLevel(Sim)) && (GetValue <PromptOption, bool>()))
            {
                if ((AcceptCancelDialog.Show(ManagerSim.GetPersonalInfo(Sim, Common.Localize("ChooseLifetimeWish:Prompt", Sim.IsFemale)))) && (LifetimeWants.SetLifetimeWant(Sim)))
                {
                    success = true;
                }
            }

            if (!success)
            {
                Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager);
                if (Sim.HasLifetimeWish)
                {
                    Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish();
                }
            }

            IncStat("Set");

            if (!DnP)
            {
                Sim.CreatedSim.NullDnPManager();
            }

            return(true);
        }
コード例 #8
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Guests.Count < TargetMinimum)
            {
                IncStat("Too Few");
                return(false);
            }

            AddStat("Guests", Guests.Count);

            if (Household.ActiveHousehold != null)
            {
                foreach (SimDescription active in HouseholdsEx.Humans(Household.ActiveHousehold))
                {
                    Target = active;
                    if (!TargetAllow(active))
                    {
                        continue;
                    }

                    if (mGuests.Contains(active))
                    {
                        continue;
                    }

                    if (ManagerFriendship.AreFriends(Sim, active))
                    {
                        mGuests.Add(active);
                    }
                }

                Target = null;
            }

            int delay = 3;

            if (Lot == Sim.LotHome)
            {
                Situations.PushGoHome(this, Sim);

                PushBuffetInteractions(this, Sim, Lot);

                DateAndTime startTime = SimClock.CurrentTime();
                startTime.Ticks += SimClock.ConvertToTicks(3f, TimeUnit.Hours);

                /*
                 * if (Lot != Sim.LotHome)
                 * {
                 *  DateAndTime rentTime = startTime;
                 *  rentTime.Ticks -= SimClock.ConvertToTicks(Sims3.Gameplay.Situations.Party.HoursToStartRentBeforePartyStart, TimeUnit.Hours);
                 *  if (rentTime.CompareTo(SimClock.CurrentTime()) < 0)
                 *  {
                 *      rentTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Minutes, 2f);
                 *  }
                 *
                 *  if (!RentScheduler.Instance.RentLot(Lot, Sim.CreatedSim, rentTime, Guests))
                 *  {
                 *      IncStat("Couldn't Rent");
                 *      Lot = Sim.LotHome;
                 *  }
                 * }
                 */

                Party party = GetParty(Lot, Sim.CreatedSim, Guests, PartyAttire, startTime);

                EventTracker.SendEvent(new PartyEvent(EventTypeId.kThrewParty, Sim.CreatedSim, Sim, party));

                delay = 3;
            }
            else
            {
                List <Sim> followers = new List <Sim>();

                foreach (SimDescription guest in Guests)
                {
                    if (SimTypes.IsSelectable(guest))
                    {
                        continue;
                    }

                    if (!Sims.Instantiate(guest, Lot, false))
                    {
                        continue;
                    }

                    Sim guestSim = guest.CreatedSim;
                    if (guestSim == null)
                    {
                        continue;
                    }

                    guestSim.PushSwitchToOutfitInteraction(Sims3.Gameplay.Actors.Sim.ClothesChangeReason.GoingToSituation, PartyAttire);

                    followers.Add(guestSim);
                }

                AddStat("Followers", followers.Count);

                if (!Situations.PushMassVisit(this, Sim, followers, Lot))
                {
                    return(false);
                }

                delay = 0;
            }

            if (mReport)
            {
                Manager.AddAlarm(new DelayedStoryScenario(this, delay));
            }

            return(true);
        }
コード例 #9
0
            protected override bool PrivateUpdate(ScenarioFrame frame)
            {
                Career job = Job;

                if (Sim.CreatedSim == null)
                {
                    Sims.Instantiate(Sim, null, false);
                }

                if (Sim.CreatedSim == null)
                {
                    IncStat("Hibernating");
                    return(false);
                }

                if ((job.mCalledInSick) || (job.mIsFakeSickDay))
                {
                    IncStat("Sick Day");
                    return(false);
                }

                Careers.VerifyTone(job);

                bool selfCommute = false;

                if ((!GetValue <AllowCarpoolOption, bool>(Sim)) ||
                    (!CarpoolEnabled(job)) ||
                    (!job.CurLevel.HasCarpool) ||
                    (!SimTypes.IsSelectable(Sim)))
                {
                    if (!SimTypes.IsSelectable(Sim))
                    {
                        try
                        {
                            // Don't queue stomp on their birthday
                            if ((Sim.YearsSinceLastAgeTransition != 0) &&
                                (Sim.CreatedSim.InteractionQueue != null))
                            {
                                Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
                            }
                        }
                        catch (Exception e)
                        {
                            Common.DebugException(Sim, e);
                        }
                    }

                    if (SimTypes.IsSelectable(Sim))
                    {
                        IncStat("Active Alarm");
                    }
                    else
                    {
                        IncStat("Inactive Alarm");
                    }

                    selfCommute = true;
                }
                else
                {
                    IncStat("Carpool");
                }

                if ((SimTypes.IsSelectable(Sim)) && (GetValue <ShowCarpoolMessageOption, bool>()) && job.mHoursUntilWork <= 2)
                {
                    string msg = GetCarpoolMessage(selfCommute);
                    if (msg != null)
                    {
                        StyledNotification.Format format = new StyledNotification.Format(msg, ObjectGuid.InvalidObjectGuid, Sim.CreatedSim.ObjectId, StyledNotification.NotificationStyle.kGameMessagePositive);
                        StyledNotification.Show(format, job.CareerIconColored);
                    }
                }

                Manager.AddAlarm(GetCommuteScenario(selfCommute));

                return(selfCommute);
            }