Example #1
0
        public void OnWorldLoadFinished()
        {
            new Common.DelayedEventListener(EventTypeId.kSocialInteraction, OnSocialEvent);
            new Common.DelayedEventListener(EventTypeId.kHouseholdSelected, OnHouseSelected);

            sOldHousehold = Household.ActiveHousehold;
        }
Example #2
0
        public override void Reset()
        {
            base.Reset();

            if (SimTypes.IsDead(Sim)) return;

            mHouse = Sim.Household;

            mNetWorth = 0;
            if (mHouse != null)
            {
                if (mHouse.LotHome != null)
                {
                    if (mHouse.LotHome != mLot)
                    {
                        mLot = mHouse.LotHome;

                        mLotHomeCost = StoryProgression.Main.Lots.GetLotCost(mLot);
                    }

                    mNetWorth = mHouse.FamilyFunds + mLotHomeCost;
                }
                else
                {
                    mNetWorth = mHouse.NetWorth();

                    mLot = null;
                    mLotHomeCost = 0;
                }
            }
        }
Example #3
0
 protected RepairScenario(RepairScenario scenario)
     : base (scenario)
 {
     mRepairs = scenario.mRepairs;
     mTownRepair = scenario.mTownRepair;
     mHouse = scenario.mHouse;
 }
Example #4
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (me == null) return OptionResult.Failure;

            string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt"), me.Name);
            if (string.IsNullOrEmpty(text)) return OptionResult.Failure;

            if (AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":SimsPrompt", false, new object[] { me.Name, text })))
            {
                foreach (SimDescription sim in CommonSpace.Helpers.Households.All(me))
                {
                    if (sim.LastName.Trim().ToLower() == me.Name.Trim().ToLower())
                    {
                        sim.LastName = text;

                        if (me == Household.ActiveHousehold)
                        {
                            HudModel hudModel = Sims3.UI.Responder.Instance.HudModel as HudModel;
                            if (sim.CreatedSim != null)
                            {
                                Household.AddDirtyNameSimID(sim.SimDescriptionId);
                                hudModel.NotifyNameChanged(sim.CreatedSim.ObjectId);
                            }
                        }
                    }
                }
            }

            me.Name = text;
            return OptionResult.SuccessClose;
        }
Example #5
0
        protected static void CloseHouse(Household house)
        {
            if (house != null)
            {
                if (house == Household.ActiveHousehold) return;

                Dictionary<Lot, bool> lots = new Dictionary<Lot, bool>();
                foreach (Sim sim in Households.AllSims(house))
                {
                    if (sim.LotCurrent == null) continue;

                    if (!lots.ContainsKey(sim.LotCurrent))
                    {
                        lots.Add(sim.LotCurrent, true);
                    }
                }

                foreach (Lot lot in LotManager.AllLots)
                {
                    if (lots.ContainsKey(lot)) continue;

                    if (lot.IsResidentialLot)
                    {
                        house.RemoveGreetedLotForHousehold(lot, ObjectGuid.InvalidObjectGuid);
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="interactionName"></param>
        /// <returns></returns>
        public static List<IMiniSimDescription> ShowSimSelector(Sim actor, Household currentHousehold, string interactionName)
        {
            List<IMiniSimDescription> residents = new List<IMiniSimDescription>();
            string buttonFalse = Localization.LocalizeString("Ui/Caption/ObjectPicker:Cancel", new object[0]);

            List<PhoneSimPicker.SimPickerInfo> list = new List<PhoneSimPicker.SimPickerInfo>();

            List<object> list2;

            //Create list of sims
            foreach (Sim s in currentHousehold.Sims)
            {
                list.Add(Phone.Call.CreateBasicPickerInfo(actor.SimDescription, s.SimDescription));
            }

            list2 = PhoneSimPicker.Show(true, ModalDialog.PauseMode.PauseSimulator, list, interactionName, interactionName, buttonFalse, currentHousehold.Sims.Count, false);

            if (list2 == null || list2.Count == 0)
            {
                return null;
            }
            foreach (var item in list2)
            {
                residents.Add(item as SimDescription);
            }

            return residents;
        }
Example #7
0
        public static string Perform(Household house, bool ignorePlaceholders)
        {
            if (house.LotHome == null) return null;

            string msg = null;

            if (Households.NumSims(house) != Households.AllSims(house).Count)
            {
                List<SimDescription> sims = new List<SimDescription>(Households.All(house));
                foreach (SimDescription description in sims)
                {
                    bool flag = true;
                    foreach (Sim sim in Households.AllSims(house))
                    {
                        if (sim.SimDescription == description)
                        {
                            flag = false;
                            break;
                        }
                    }

                    if (flag)
                    {
                        FixInvisibleTask.Perform(description, false);

                        msg += RecoverMissingSimTask.Perform(description, ignorePlaceholders);
                    }
                }
            }

            return msg;
        }
Example #8
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (lot != null)
            {
                List<Item> allOptions = new List<Item>();

                foreach (Household house in Household.sHouseholdList)
                {
                    if (house.RealEstateManager == null) continue;

                    PropertyData data = house.RealEstateManager.FindProperty(lot);
                    if (data == null) continue;

                    allOptions.Add(new Item(house, lot, RealEstate.OwnerType.Full, data.TotalValue));
                }

                if (allOptions.Count == 0)
                {
                    SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Failure"));
                    return OptionResult.Failure;
                }

                CommonSelection<Item>.Results choices = new CommonSelection<Item>(Name, allOptions).SelectMultiple();
                if ((choices == null) || (choices.Count == 0)) return OptionResult.Failure;

                foreach (Item item in choices)
                {
                    item.Perform();
                }
            }

            return OptionResult.SuccessClose;
        }
Example #9
0
 public MemberListModel(Household household, List<User> users, bool canEditPermissions, bool canEditUser)
 {
     Household = household;
     Users = users;
     CanEditPermissions = canEditPermissions;
     CanEditUser = canEditUser;
 }
Example #10
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (lot.IsCommunityLot) return false;

            return (new HomeInspection(lot).Satisfies(me).Count > 0);
        }
Example #11
0
        protected override bool Allow(Lot lot, Household house)
        {
            if (!base.Allow(lot, house)) return false;

            if (lot is WorldLot) return false;

            return (lot != null);
        }
Example #12
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (lot == null) return false;

            return (true);
        }
Example #13
0
        protected static void GetTaxes(Household me, out int owed, out int savings, out int vacationHome)
        {
            owed = (int)(me.ComputeNetWorthOfObjectsInHousehold(true) * Mailbox.kPercentageOfWealthBilled);

            vacationHome = 0;

            savings = 0;

            if (me.RealEstateManager != null)
            {
                int valueOfAllVacationHomes = me.RealEstateManager.GetValueOfAllVacationHomes();

                vacationHome = (int)Math.Round((double)(valueOfAllVacationHomes * RealEstateManager.kPercentageOfVacationHomeValueBilled));

                owed += vacationHome;
            }

            if (me.LotHome != null)
            {
                Dictionary<int, List<float>> dictionary = new Dictionary<int, List<float>>();
                foreach (IReduceBills bills in me.LotHome.GetObjects<IReduceBills>())
                {
                    List<float> list;
                    int key = bills.ReductionArrayIndex();
                    float item = bills.PercentageReduction();
                    if (dictionary.TryGetValue(key, out list))
                    {
                        list.Add(item);
                    }
                    else
                    {
                        List<float> list2 = new List<float>();
                        list2.Add((float)bills.MaxNumberContributions());
                        list2.Add(item);
                        dictionary.Add(key, list2);
                    }
                }

                foreach (KeyValuePair<int, List<float>> pair in dictionary)
                {
                    int num5 = (int)pair.Value[0];
                    pair.Value.RemoveAt(0);
                    pair.Value.Sort();
                    int count = pair.Value.Count;
                    num5 = Math.Min(num5, count);
                    float num7 = 0f;
                    for (int i = 1; i <= num5; i++)
                    {
                        num7 += pair.Value[count - i];
                    }
                    int amount = (int)(owed * num7);

                    owed -= amount;

                    savings += amount;
                }
            }
        }
Example #14
0
        // Lacks the "greater than eight" restriction
        public static bool GhostToPlayableGhost(Urnstone ths, Household newHousehold, Vector3 ghostPosition)
        {
            SimDescription simDescription = ths.DeadSimsDescription;

            if (!simDescription.IsValidDescription)
            {
                simDescription.Fixup();
            }

            if (simDescription.Household != null)
            {
                simDescription.Household.Remove(simDescription, !simDescription.Household.IsSpecialHousehold);
            }

            if (!newHousehold.Contains(simDescription))
            {
                newHousehold.Add(simDescription);
            }

            Sim ghost = Instantiation.Perform(simDescription, ghostPosition, null, null);
            if (ghost == null) return false;

            ths.GhostSetup(ghost, true);

            ths.RemoveMourningRelatedBuffs(ghost);

            simDescription.ShowSocialsOnSim = true;
            simDescription.IsNeverSelectable = false;
            simDescription.Marryable = true;
            simDescription.Contactable = true;

            if (!simDescription.IsEP11Bot)
            {
                simDescription.AgingEnabled = true;
                simDescription.AgingState.ResetAndExtendAgingStage(0f);
                simDescription.PushAgingEnabledToAgingManager();
            }

            string failureReason;
            if (!Inventories.TryToMove(ths, ghost.Inventory, true, out failureReason))
            {
                Common.DebugNotify(failureReason);
            }
            //Inventories.TryToMove(ths, ghost);

            if (simDescription.Child || simDescription.Teen)
            {
                simDescription.AssignSchool();
            }

            if (ghost.IsSelectable)
            {
                ghost.OnBecameSelectable();
            }

            return true;
        }
Example #15
0
 protected override bool Allow(Household house)
 {
     if (house.LotHome != null)
     {
         IncStat("Resident");
         return false;
     }
     return base.Allow(house);
 }
Example #16
0
        public CareerStore(Household house, SafeStore.Flag flags)
        {
            mSafeStore = new Dictionary<ulong, SafeStore>();

            foreach (SimDescription sim in Households.All(house))
            {
                mSafeStore[sim.SimDescriptionId] = new SafeStore(sim, flags);
            }
        }
Example #17
0
        protected override OptionResult PrivatePerform(Lot lot, Household me, List<IMiniSimDescription> sims)
        {
            OptionResult result = base.PrivatePerform(lot, me, sims);
            if (result == OptionResult.Failure) return OptionResult.Failure;

            SetRoommate(lot, me, sims);

            return result;
        }
        protected override Scenario Handle(Event e, ref ListenerAction result)
        {
            mEvent = e as HouseholdUpdateEvent;
            if (mEvent == null) return null;

            mOldHousehold = StoryProgression.Main.Households.ActiveHousehold;

            return base.Handle(e, ref result);
        }
Example #19
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (me == null) return false;

            if (me.RealEstateManager == null) return false;

            return true;
        }
Example #20
0
        public static void AddCheck(Household house)
        {
            if (!Vector.Settings.mAllowInactivePurchases) return;

            if (SimTypes.IsSpecial(house)) return;

            if (sChecks.ContainsKey(house)) return;

            sChecks.Add(house, true);
        }
Example #21
0
 public void FindHouseholdById()
 {
     var house = new Household();
     var rep = new HouseholdRepository(new CSBCDbContext());
     var houses = rep.GetByName(HouseholdName1);
     Assert.IsTrue(houses.Count<Household>() > 0);
     house = rep.GetById(houses.FirstOrDefault().HouseID);
     Assert.IsTrue(house != null);
     Assert.IsTrue(house.Name == HouseholdName1);
 }
        protected override bool Allow(Household house)
        {
            if (!base.Allow(house)) return false;

            if (house == Household.ActiveHousehold) return false;

            if (house.LotHome == null) return false;

            return true;
        }
Example #23
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (lot is WorldLot) return false;

            if (lot == null) return false;

            return MasterController.Settings.IsExcludedLot(lot);
        }
Example #24
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (lot == null) return false;

            if (me == Household.ActiveHousehold) return false;

            return (me != null);
        }
Example #25
0
        protected override bool Allow(Lot lot, Household me)
        {
            if (!base.Allow(lot, me)) return false;

            if (lot == null) return false;

            if (lot.IsPurchaseableVenue) return true;

            return lot.IsResidentialLot;
        }
Example #26
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (lot == null) return OptionResult.Failure;

            if (!ApplyAll)
            {
                string text = StringInputDialog.Show(Name, Common.Localize("DepreciateHouse:Prompt"), "0", 256, StringInputDialog.Validation.None);
                if ((text == null) || (text == "")) return OptionResult.Failure;

                mValue = 0;
                if (!int.TryParse(text, out mValue))
                {
                    SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                    return OptionResult.Failure;
                }
            }

            if ((lot != null) && (lot.IsResidentialLot))
            {
                int oldCost = lot.CalculateFurnitureWorth ();

                int baseCost = lot.Cost - oldCost;

                Dictionary<string,int> objects = new Dictionary<string,int>();

                foreach (GameObject obj in lot.GetObjects<GameObject> ())
                {
                    if (obj is AbstractArtObject) continue;
                    
                    if (obj is Fireplace) continue;
                    
                    if (obj is ImageObject) continue;

                    if (obj is Terrarium) continue;

                    obj.ValueModifier -= (int) (obj.PurchasedPrice * (mValue / 100f));

                    if (!objects.ContainsKey(obj.CatalogName))
                    {
                        objects.Add(obj.CatalogName, 1);
                    }
                    else
                    {
                        objects[obj.CatalogName]++;
                    }
                }

                int newCost = lot.CalculateFurnitureWorth();

                Common.Notify(Common.Localize("DepreciateHouse:Success", false, new object[] { lot.Name, baseCost + oldCost, baseCost + newCost }));
            }

            return OptionResult.SuccessClose;
        }
Example #27
0
        protected override OptionResult Run(Lot lot, Household house)
        {
            NRaas.MasterControllerSpace.Helpers.SortInventory.Item item = NRaas.MasterControllerSpace.Helpers.SortInventory.GetSortType(Name);
            if (item == null) return OptionResult.Failure;

            foreach (GameObject obj in lot.GetObjects<GameObject>())
            {
                NRaas.MasterControllerSpace.Helpers.SortInventory.Perform(obj.Inventory, item);
            }

            return OptionResult.SuccessClose;
        }
Example #28
0
        public static bool IsPassport(Household home)
        {
            foreach (SimDescription sim in Households.All(home))
            {
                if (Passport.IsHostedPassportSim(sim.CreatedSim))
                {
                    return true;
                }
            }

            return false;
        }
Example #29
0
        protected override OptionResult Run(Lot lot, Household me)
        {
            if (me == null) return OptionResult.Failure;

            if (!AcceptCancelDialog.Show(Common.Localize("MakeHomeless:Prompt", false, new object[] { me.Name })))
            {
                return OptionResult.Failure;
            }

            me.MoveOut();
            return OptionResult.SuccessClose;
        }
Example #30
0
        public static bool IsRole(Household home)
        {
            foreach (SimDescription sim in Households.All(home))
            {
                if (sim.AssignedRole != null)
                {
                    return true;
                }
            }

            return false;
        }
 public HouseholdViewContentViewModel(ApplicationInstanceData applicationInstanceData, Household household)
 {
     ApplicationInstanceData = applicationInstanceData;
     Household = household;
 }
Example #32
0
        public static bool Household_ImportContent(Household _this, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader)
        {
            if (_this == null)
            {
                throw new NullReferenceException("if (this == null)");
            }

            reader.ReadString(1357107804u, out _this.mName, "");
            reader.ReadInt32(867787827u, out _this.mFamilyFunds, 0);
            reader.ReadString(3647669240u, out _this.mBioText, "");
            reader.ReadInt32(145720536u, out _this.mUnpaidBills, 0);
            reader.ReadInt32(3338514733u, out _this.mLotHomeWorth, 0);

            long exportTime = DateTime.Now.ToBinary();

            reader.ReadInt64(1669643236u, out exportTime, DateTime.Now.ToBinary());
            _this.mExportTime = DateTime.FromBinary(exportTime);

            reader.ReadBool(571722353u, out _this.mbLifetimeHappinessNotificationShown, false);
            IPropertyStreamReader child = reader.GetChild(2449095374u);

            if (child != null)
            {
                HMembers_ImportContent(_this.mMembers, resKeyTable, objIdTable, child);
            }

            try
            {
                foreach (SimDescription allSimDescription in _this.mMembers.AllSimDescriptionList)
                {
                    allSimDescription.OnHouseholdChanged(_this, true);
                    allSimDescription.CareerManager.OnLoadFixup();
                    Sims3.Gameplay.Careers.Occupation occupation = allSimDescription.CareerManager.Occupation;
                    if (occupation != null)
                    {
                        occupation.RepairLocation();
                    }
                }

                foreach (SimDescription allSimDescription2 in _this.mMembers.AllSimDescriptionList)
                {
                    if (allSimDescription2.Pregnancy != null)
                    {
                        SimDescription value2;
                        if (Household.sOldIdToNewSimDescriptionMap != null && Household.sOldIdToNewSimDescriptionMap.TryGetValue(allSimDescription2.Pregnancy.DadDescriptionId, out value2))
                        {
                            allSimDescription2.Pregnancy.DadDescriptionId = value2.SimDescriptionId;
                        }
                        else if (!Household.IsTravelImport && _this.mMembers.GetSimDescriptionFromId(allSimDescription2.Pregnancy.DadDescriptionId) == null)
                        {
                            allSimDescription2.Pregnancy.DadDescriptionId = 0uL;
                        }
                    }
                }

                child = reader.GetChild(2706303414u);
                if (child != null)
                {
                    //_this.ImportRelationships(resKeyTable, objIdTable, child);
                    //_this.ImportRelationships(resKeyTable, objIdTable, child);
                    Household_ImportRelationships(_this, resKeyTable, objIdTable, child);
                }
            }
            catch (StackOverflowException) { throw; }
            catch (ResetException) { throw; }
            catch (Exception)
            { }


            reader.ReadInt32(141731785u, out _this.mAncientCoinCount, 0);

            ulong uniqueObjectsObtained;

            reader.ReadUint64(1193523264u, out uniqueObjectsObtained, 0uL);
            _this.UniqueObjectsObtained = (UniqueObjectKey)uniqueObjectsObtained;

            _this.mKeystonePanelsUsed = new PairedListDictionary <WorldName, List <string> >();

            int KeystonePanelsUsedCount;

            reader.ReadInt32(129814813u, out KeystonePanelsUsedCount, 0);
            int checkloop = 0; // Fix Loop 12:48 20/05/2019

            for (uint num = 0u; num < KeystonePanelsUsedCount; num++)
            {
                int keystonePanelsUsed;
                reader.ReadInt32(146578516 + num, out keystonePanelsUsed, -1);
                WorldName key = (WorldName)keystonePanelsUsed;

                string[] keystonePanelsList;
                reader.ReadString(163369191 + num, out keystonePanelsList);
                _this.mKeystonePanelsUsed[key] = new List <string>(keystonePanelsList ?? new string[0]);

                if (checkloop++ > 500)
                {
                    break;
                }
            }

            _this.mCompletedHouseholdOpportunities.Clear();

            ulong[] completedHouseholdOpportunities;
            reader.ReadUint64(149611345u, out completedHouseholdOpportunities);

            foreach (ulong key in completedHouseholdOpportunities)
            {
                _this.mCompletedHouseholdOpportunities.Add(key, true);
            }

            reader.ReadUint32(149611346u, out _this.mMoneySaved);
            if (_this.mMoneySaved == null || _this.mMoneySaved.Length != 3)
            {
                _this.mMoneySaved = new uint[3];
            }

            ulong[] wardrobeCasParts;
            reader.ReadUint64(153835052u, out wardrobeCasParts);
            foreach (ulong item in wardrobeCasParts)
            {
                _this.mWardrobeCasParts.Add(item);
            }

            ulong serviceUniform;

            reader.ReadUint64(156333552u, out serviceUniform, 0uL);
            _this.AddServiceUniforms((ServiceType)serviceUniform);

            return(true);
        }
Example #33
0
            internal void Execute(int deltaYear, Repository <Household> householdRepository, Repository <Family> familyRepository, Repository <Person> personRepo)
            {
                // get the pool of individuals to use
                List <Family> familyPool = null, individualPool = null;
                var           familySeed     = (uint)(Parent.RandomGenerator.Take() * uint.MaxValue);
                var           individualSeed = (uint)(Parent.RandomGenerator.Take() * uint.MaxValue);

                Parallel.Invoke(
                    () =>
                {
                    Rand rand  = new Rand(familySeed);
                    familyPool = BuildFamilyPool(deltaYear, rand);
                }, () =>
                {
                    Rand rand      = new Rand(individualSeed);
                    individualPool = BuildIndividualPool(deltaYear, rand);
                });
                var targetPersons = (int)(Parent.NumberOfImmigrantsBySimulationYear[deltaYear + (RegionNumber - 1) * 20] * Scale);

                Repository.GetRepository(Parent.LogSource).WriteToLog($"Number of persons to add in {Name} in {deltaYear} target additions are {targetPersons}.");
                Parent.RandomGenerator.ExecuteWithProvider((rand) =>
                {
                    while (targetPersons > 0)
                    {
                        float chance      = rand.Take();
                        float acc         = 0.0f;
                        int householdType = 0;
                        for (; acc < chance; householdType++)
                        {
                            acc += Parent.HouseholdTypeData[deltaYear * 5 + CMA * 100 + householdType];
                        }
                        Household household = new Household();
                        switch (householdType)
                        {
                        default:
                        case 1:
                            {
                                household.HouseholdType = HouseholdComposition.SingleIndividuals;
                                household.Families.Add(GetFamilyFromPool(individualPool, rand.Take()));
                            }
                            break;

                        case 2:
                            {
                                household.HouseholdType = HouseholdComposition.MultiIndividuals;
                                // create at least 2 individuals
                                household.Families.Add(GetFamilyFromPool(individualPool, rand.Take()));
                                do
                                {
                                    household.Families.Add(GetFamilyFromPool(individualPool, rand.Take()));
                                } while (rand.Take() < ProbabilityOfAdditionalMultiIndividuals);
                            }
                            break;

                        case 3:
                            {
                                household.HouseholdType = HouseholdComposition.SingleFamily;
                                household.Families.Add(GetFamilyFromPool(familyPool, rand.Take()));
                            }
                            break;

                        case 4:
                            {
                                household.HouseholdType = HouseholdComposition.SingleFamilyIndividuals;
                                household.Families.Add(GetFamilyFromPool(familyPool, rand.Take()));
                                //TODO: Assumption is that there is only 1 additional individual
                                household.Families.Add(GetFamilyFromPool(individualPool, rand.Take()));
                            }
                            break;

                        case 5:
                            {
                                household.HouseholdType = HouseholdComposition.MultiFamily;
                                //TODO: Assumption is that there are two families for this type
                                household.Families.Add(GetFamilyFromPool(familyPool, rand.Take()));
                                household.Families.Add(GetFamilyFromPool(familyPool, rand.Take()));
                            }
                            break;
                        }
                        targetPersons -= AddHouseholdToRepositories(household, householdRepository, familyRepository, personRepo);
                    }
                });
            }
Example #34
0
 public abstract void SaveHousehold(Household household);
Example #35
0
 protected abstract OptionResult Run(Lot lot, Household house);
Example #36
0
        public static void ResetHousehold(Household house, bool resetAll)
        {
            if (house == null)
            {
                return;
            }

            if (resetAll)
            {
                if (MasterController.Settings.IsExcludedLot(house.LotHome))
                {
                    return;
                }
            }

            /*
             * Butler instance = Butler.Instance;
             * if ((instance != null) && (instance.IsServiceRequested(lot) || instance.IsAnySimAssignedToLot(lot)))
             * {
             *  List<Sim> assigned = instance.GetSimsAssignedToLot(lot);
             *  foreach (Sim sim in assigned)
             *  {
             *      IGameObject reservedTile = null;
             *      if (sim.FindRoutablePointInsideNearFrontDoor(lot, out reservedTile))
             *      {
             *          sim.ResetBindPoseWithRotation();
             *          sim.SetPosition(reservedTile.Position);
             *          sim.SetForward(reservedTile.ForwardVector);
             *          sim.RemoveFromWorld();
             *          sim.AddToWorld();
             *          sim.SetHiddenFlags(HiddenFlags.Nothing);
             *          sim.SetOpacity(1f, 0f);
             *      }
             *  }
             * }
             */
            house.UniqueObjectsObtained = UniqueObjectKey.None;

            foreach (SimDescription sim in new List <SimDescription>(CommonSpace.Helpers.Households.All(house)))
            {
                try
                {
                    if (sim == null)
                    {
                        continue;
                    }

                    Sim createdSim = sim.CreatedSim;
                    if (createdSim != null)
                    {
                        createdSim = ResetSim(createdSim, resetAll);
                    }

                    if (createdSim == null)
                    {
                        if (sim.LotHome != null)
                        {
                            new InstantiateTask(sim);
                        }
                    }
                    else if (createdSim.Inventory != null)
                    {
                        foreach (UniqueObject uniqueObj in Inventories.QuickFind <UniqueObject>(createdSim.Inventory))
                        {
                            house.UniqueObjectsObtained |= uniqueObj.SpawnedObjectKey;
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }

            if ((house.SharedFamilyInventory != null) && (house.SharedFamilyInventory.Inventory != null))
            {
                foreach (UniqueObject uniqueObj in Inventories.QuickFind <UniqueObject>(house.SharedFamilyInventory.Inventory))
                {
                    house.UniqueObjectsObtained |= uniqueObj.SpawnedObjectKey;
                }
            }
        }
Example #37
0
        public IHttpActionResult Notification([FromBody] CBISMessage cbisMessage)
        {
            try
            {
                if (cbisMessage == null || cbisMessage.Data == null)
                {
                    throw new Exception("Payload is empty");
                }

                //Store incoming request to  application variable
                Dictionary <string, string> lstRequests = HttpContext.Current.Application["AckReq"] == null ? new Dictionary <string, string>() : (Dictionary <string, string>)HttpContext.Current.Application["AckReq"];
                lstRequests.Add(cbisMessage.MessageId, cbisMessage.ToString());
                HttpContext.Current.Application["AckReq"] = lstRequests;

                JToken        token     = cbisMessage.Data;
                List <Person> lstPerson = new List <Person>();

                if (token is JArray)
                {
                    lstPerson = token.ToObject <List <Person> >();
                }
                else if (token is JObject)
                {
                    lstPerson.Add(token.ToObject <Person>());
                }

                List <Applicant>  applicants    = new List <Applicant>();
                List <CBISResult> lstCBISResult = new List <CBISResult>();

                foreach (Person mem in lstPerson)
                {
                    if (mem != null)
                    {
                        Applicant applicant = new Applicant();
                        applicant.FirstName  = mem.FirstName;
                        applicant.LastName   = mem.LastName;
                        applicant.MiddleName = mem.MiddleName;
                        applicant.Gender     = mem.Gender;
                        applicant.DOB        = mem.BirthDate.ToString();

                        if (mem.Households != null && mem.Households.Count > 0)
                        {
                            Household houseHold = mem.Households[0];
                            applicant.HouseholdName = houseHold.Name;
                            if (houseHold.Phones != null && houseHold.Phones.Count > 0)
                            {
                                applicant.HouseholdPhone = houseHold.Phones[0].Number;
                            }
                            if (houseHold.EmailAddresses != null && houseHold.EmailAddresses.Count > 0)
                            {
                                applicant.HouseholdEmail = houseHold.EmailAddresses[0].EmailId;
                            }
                        }

                        if (mem.Grade != null)
                        {
                            applicant.Grade = mem.Grade.Name;
                        }

                        List <string> errors = this.ValidateData(applicant);
                        if (errors.Count > 0)
                        {
                            lstCBISResult.Add(new CBISResult
                            {
                                Id         = mem.PersonId,
                                ResultType = "E_UNPROCESSABLE_RECORD",
                                Errors     = errors
                            });
                        }
                        else
                        {
                            applicants.Add(applicant);

                            lstCBISResult.Add(new CBISResult
                            {
                                Id         = mem.PersonId,
                                ResultType = "SUCCESS"
                            });
                        }
                    }
                }

                if (!DBHelper.InsertApplicantstoDB(applicants))
                {
                    throw new Exception("DB acess failed");
                }

                CBISMessage cbisMessage_Response = new CBISMessage
                {
                    CbInstitutionId = cbisMessage.CbInstitutionId,
                    EventName       = cbisMessage.EventName,
                    MessageId       = cbisMessage.MessageId,
                    MessageType     = "NotificationResponse",
                    Model           = "CBISResult",
                    Origin          = "Tads",
                    Data            = JToken.FromObject(lstCBISResult)
                };

                return(Ok(cbisMessage_Response));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #38
0
        public ActionResult Leavehousehold()
        {
            Household model = db.Households.Find(User.Identity.GetHouseholdId().Value);

            return(View(model));
        }
Example #39
0
 public MoveIn(Household house)
 {
     mHouse = house;
 }
Example #40
0
        public ActionResult CreateTransaction([Bind(Include = "Description,Amount,Type,AccountId,BudgetCategoryId,Date")] TransactionCreateViewModel vm)
        {
            Household userHousehold = db.Households.Find(Convert.ToInt32(User.Identity.GetHouseholdId()));

            if (ModelState.IsValid && (userHousehold.BudgetCategories.Select(bc => bc.Id).Contains(vm.BudgetCategoryId) || db.BudgetCategories.Find(vm.BudgetCategoryId).Name == "General") && userHousehold.Accounts.Select(a => a.Id).Contains(vm.AccountId))
            {
                Transaction transaction = new Transaction();
                transaction.Date             = vm.Date;
                transaction.Description      = vm.Description;
                transaction.Amount           = vm.Amount;
                transaction.AccountId        = vm.AccountId;
                transaction.BudgetCategoryId = vm.BudgetCategoryId;
                if (vm.Type == "+")
                {
                    transaction.Expense = false;
                }
                else
                {
                    transaction.Expense = true;
                }
                transaction.ForReconciled = false;
                Account account = db.Accounts.Find(transaction.AccountId);

                transaction.MadeById = User.Identity.GetUserId();
                db.Transactions.Add(transaction);
                db.SaveChanges();

                if (transaction.Expense)
                {
                    account.CurrentBalance     = account.CurrentBalance - transaction.Amount;
                    account.ReconciledBalance -= transaction.Amount;
                }
                else
                {
                    account.CurrentBalance     = account.CurrentBalance + transaction.Amount;
                    account.ReconciledBalance += transaction.Amount;
                }
                db.Entry(account).Property("CurrentBalance").IsModified = true;
                db.SaveChanges();

                db.Entry(account).Property("ReconciledBalance").IsModified = true;
                db.SaveChanges();

                Budget budget = userHousehold.Budgets.FirstOrDefault(b => b.BudgetCategoryId == vm.BudgetCategoryId);
                return(RedirectToAction("Details", new { id = budget.Id }));
            }

            if (vm.AccountId == 0 || !db.Accounts.ToList().Select(a => a.Id).Contains(vm.AccountId))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Account accountB      = db.Accounts.Find(vm.AccountId);
            string  currentUserId = User.Identity.GetUserId();

            if (!accountB.Household.Members.Select(m => m.Id).Contains(currentUserId))
            {
                return(RedirectToAction("Unauthorized", "Home"));
            }

            ViewBag.AccountName      = accountB.Name;
            ViewBag.AccountId        = vm.AccountId;
            ViewBag.BudgetCategoryId = new SelectList(db.BudgetCategories, "Id", "Name");
            return(View());
        }
Example #41
0
 public Definition(Household fambly, string interactName)
 {
     this.famblyHouse     = fambly;
     this.interactionName = interactName;
 }
Example #42
0
 public static HouseholdAddRequestBuilder Add(Household household)
 {
     return(new HouseholdAddRequestBuilder(household));
 }
Example #43
0
 public static HouseholdUpdateRequestBuilder Update(Household household)
 {
     return(new HouseholdUpdateRequestBuilder(household));
 }
Example #44
0
 public DebtForgivenScenario(Household house)
     : base(house)
 {
 }
Example #45
0
        private static bool ProcessDescendantHouseholds(FutureDescendantService ths)
        {
            Common.StringBuilder msg = new Common.StringBuilder("ProcessDescendantHouseholds");

            for (int i = 0x0; i < FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo.Count; i++)
            {
                try
                {
                    FutureDescendantService.FutureDescendantHouseholdInfo info = FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo[i];
                    Household descendantHousehold = info.DescendantHousehold;
                    if (descendantHousehold != null)
                    {
                        if (Household.ActiveHousehold != null && info.HasAncestorFromHousehold(Household.ActiveHousehold))
                        {
                            msg += Common.NewLine + "descendantHousehold is not null.";
                            while (descendantHousehold.NumMembers > info.mCurrentDesiredHouseholdSize)
                            {
                                msg += Common.NewLine + "Removing descendant because the current size (" + descendantHousehold.NumMembers + ") is greater than the desired (" + info.mCurrentDesiredHouseholdSize + ")";
                                info.RemoveDescendant();
                            }

                            while (descendantHousehold.NumMembers < info.mCurrentDesiredHouseholdSize)
                            {
                                msg += Common.NewLine + "Adding descendant because the current size (" + descendantHousehold.NumMembers + ") is less  than the desired (" + info.mCurrentDesiredHouseholdSize + ")";
                                // Custom
                                if (!FutureDescendantHouseholdInfoEx.CreateAndAddDescendant(info))
                                {
                                    break;
                                }
                            }

                            foreach (ulong num2 in Household.mDirtyNameSimIds)
                            {
                                if (info.IsSimAProgenitor(num2))
                                {
                                    SimDescription description = SimDescription.Find(num2);
                                    if (description != null)
                                    {
                                        foreach (SimDescription description2 in info.DescendantHousehold.SimDescriptions)
                                        {
                                            description2.LastName = description.LastName;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        msg += Common.NewLine + "descendantHousehold is null so instatiating a new one.";
                        // Custom
                        Household household2 = FutureDescendantHouseholdInfoEx.Instantiate(info);
                        FutureDescendantService.sPersistableData.ActiveDescendantHouseholdsInfo[i].mFutureDescendantHouseholdInfoDirty = true;
                        if (household2 == null)
                        {
                            msg += Common.NewLine + "NULL";
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(i.ToString(), e);
                }
                finally
                {
                    Common.DebugWriteLog(msg);
                }
            }
            Household.ClearDirtyNameSimIDs();
            return(true);
        }
Example #46
0
        public static bool Household_ExportContent(Household _this, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamWriter writer)
        {
            if (_this == null)
            {
                throw new NullReferenceException();
            }
            if (_this.mMembers == null)
            {
                return(false);
            }
            string name    = _this.mName;
            string bioText = _this.mBioText;

            //if (!DownloadContent.IsDevBuild())
            //{
            //    name = _this.Name;
            //    bioText = _this.BioText;
            //}
            writer.WriteString(1357107804u, name);
            writer.WriteInt32(867787827u, _this.mFamilyFunds);
            writer.WriteString(3647669240u, bioText);
            writer.WriteInt64(1669643236u, DateTime.Now.ToBinary());
            writer.WriteBool(571722353u, _this.mbLifetimeHappinessNotificationShown);
            writer.WriteInt32(145720536u, _this.mUnpaidBills);
            if (_this.LotHome != null)
            {
                writer.WriteInt32(3338514733u, _this.LotHome.Cost);
            }
            IPropertyStreamWriter writer2 = writer.CreateChild(2449095374u);

            HMembers_ExportContent(_this.mMembers, resKeyTable, objIdTable, writer2);
            writer.CommitChild();
            writer2 = writer.CreateChild(2706303414u);
            try
            {
                //_this.ExportRelationships(resKeyTable, objIdTable, writer2);
                Household_ExportRelationships(_this.mMembers, resKeyTable, objIdTable, writer2);
            }
            catch (StackOverflowException) { throw; }
            catch (ResetException)
            {
                throw;
            }
            catch { }

            writer.CommitChild();
            writer.WriteInt32(141731785u, _this.mAncientCoinCount);
            writer.WriteUint64(1193523264u, (ulong)_this.UniqueObjectsObtained);
            int count = _this.mKeystonePanelsUsed.Count;

            writer.WriteInt32(129814813u, count);
            uint num = 0u;

            foreach (WorldName key in _this.mKeystonePanelsUsed.Keys)
            {
                writer.WriteInt32(146578516 + num, (int)key);
                List <string> list = new List <string>(_this.mKeystonePanelsUsed[key]);
                writer.WriteString(163369191 + num, list.ToArray());
                num++;
            }
            ulong[] array = new ulong[_this.mCompletedHouseholdOpportunities.Count];
            _this.mCompletedHouseholdOpportunities.Keys.CopyTo(array, 0);
            writer.WriteUint64(149611345u, array);
            writer.WriteUint32(149611346u, _this.mMoneySaved);
            ulong[] array2 = new ulong[_this.mWardrobeCasParts.Count];
            _this.mWardrobeCasParts.CopyTo(array2, 0);
            writer.WriteUint64(153835052u, array2);
            writer.WriteUint64(156333552u, (ulong)_this.mServiceUniforms);
            return(true);
        }
Example #47
0
 public CacheValue(Manager manager, Household house)
     : this(house, manager.GetValue <NetWorthOption, int>(house))
 {
 }
Example #48
0
 public static void Perform(Household house)
 {
     new Task(house).AddToSimulator();
 }
        // GET: Budgets/Details/5
        public ActionResult Details(int?id)
        {
            var userId = User.Identity.GetUserId();
            List <UserData2> UserChartList = new List <UserData2>();   //Finding Chart Data for Users in a household's spending amounts
            var       Budget = db.Budgets.Find(id);
            UserData2 Users;
            Household household        = db.Users.FirstOrDefault(u => u.Id == userId).Household;
            var       userobject       = db.Users.Find(userId);
            var       userTransactions = db.Transactions.Where(t => t.SubmitterUserId == userId);

            foreach (var user in household.Users)

            {
                Users       = new UserData2();
                Users.label = user.FullName;
                Users.value = user.Transactions.Where(t => t.BudgetId == Budget.Id).Where(t => t.Void != true).Select(t => t.Amount).ToList().Sum(s => Convert.ToInt32(s));
                UserChartList.Add(Users);
            }

            ViewBag.ArrData2 = UserChartList.ToArray();

            List <UserData2> ExpenseChartList = new List <UserData2>();   //Finding Chart Data for a users spending per category
            var       Budget2 = db.Budgets.Find(id);
            UserData2 Expenses;
            Household household2            = db.Users.FirstOrDefault(u => u.Id == userId).Household;
            var       HouseholdUserIds      = db.Users.Where(u => u.HouseholdId == household2.Id).Select(s => s.Id);
            var       BudgetCategories      = Budget2.Transactions.Select(t => t.TransactionCategory).Distinct().Where(tc => tc != null);
            var       DistinctCategoryNames = BudgetCategories.Select(bc => bc.Name).Distinct().ToList();

            foreach (var transactioncategory in DistinctCategoryNames)
            {
                Expenses       = new UserData2();
                Expenses.label = transactioncategory;
                var ExpenseList = db.Transactions.ToList().Where(t => t.BudgetId == Budget.Id).Where(t => t.Void != true).Where(t => t.TransactionCategory != null && t.TransactionCategory.Name == transactioncategory).Select(p => p.Amount).Sum(s => Convert.ToInt32(s));
                Expenses.value = ExpenseList;
                ExpenseChartList.Add(Expenses);
            }

            ViewBag.ArrData3 = ExpenseChartList.ToArray();

            List <UserData2> DaysLeftList = new List <UserData2>();   //Finding Days Left in Budget Period
            var       Budget3             = db.Budgets.Find(id);
            UserData2 Days;
            string    start          = Budget3.BudgetStartDate.ToShortDateString();
            DateTime  startdate      = DateTime.Parse(start);
            DateTime  expirydate     = Budget3.BudgetEnd;
            string    enddate        = expirydate.ToShortDateString();
            DateTime  now            = DateTime.Now;
            TimeSpan  x              = expirydate - now;
            TimeSpan  y              = now - startdate;
            int       daysremain     = x.Days;
            int       daysintobudget = y.Days;

            Days       = new UserData2();
            Days.label = "Days Remaining in Budget";
            Days.value = daysremain;
            DaysLeftList.Add(Days);

            Days       = new UserData2();
            Days.label = "Days Into Budget";
            Days.value = daysintobudget;
            DaysLeftList.Add(Days);
            ViewBag.ArrData4 = DaysLeftList.ToArray();


            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Budget budget = db.Budgets.Find(id);

            if (budget == null)
            {
                return(HttpNotFound());
            }
            return(View(budget));
        }
Example #50
0
 public static SimDescription HeadOfFamily(Household house)
 {
     return(HeadOfFamily(house, true));
 }
Example #51
0
        public static Household _ImportHousehold(string packageFile, Lot moveinLot, bool full, bool askToCreateSim, out HouseholdContents contents)
        {
            contents = null;
            if (packageFile == null || packageFile.Length == 0)
            {
                return(null);
            }

            try
            {
                HouseholdContentsProxy hoc = HouseholdContentsProxy.Import(packageFile);
                if (hoc != null)
                {
                    Household mhouse = hoc.Household;
                    if (mhouse != null && mhouse.mMembers != null && mhouse.AllSimDescriptions != null && mhouse.AllSimDescriptions.Count != 0)
                    {
                        foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                        {
                            item.mHousehold = mhouse;
                        }

                        try
                        {
                            mhouse.FixupGenealogy();
                        }
                        catch (Exception)
                        { }

                        foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                        {
                            try
                            {
                                item.Fixup();
                            }
                            catch (Exception)
                            { }
                        }



                        bool donelotofmovein = false;
                        if (moveinLot != null && moveinLot.mHousehold == null)
                        {
                            donelotofmovein = true;
                            try
                            {
                                moveinLot.MoveIn(mhouse);
                            }
                            catch (Exception)
                            {
                                moveinLot.mHousehold = mhouse;
                                mhouse.mLotId        = moveinLot.mLotId;
                                mhouse.mLotHome      = moveinLot;
                            }
                        }
                        if (!full)
                        {
                            full = askToCreateSim && Simulator.CheckYieldingContext(false) && NiecMod.Nra.NFinalizeDeath.CheckAccept("Create Sim?");
                        }
                        if (full)
                        {
                            //Sim sim = null;
                            if (donelotofmovein)
                            {
                                try
                                {
                                    foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                                    {
                                        try
                                        {
                                            if (NiecMod.Nra.NFinalizeDeath.SimDesc_OutfitsIsValid(item))
                                            {
                                                item.Instantiate(Service.GetPositionInRandomLot(moveinLot), false);
                                            }
                                        }
                                        catch (Exception)
                                        { }
                                    }
                                }
                                catch (Exception)
                                { }
                            }
                            try
                            {
                                BinCommon.CreateInventories(mhouse, hoc.Contents, NiecMod.Nra.NFinalizeDeath.CreateIndexMap_(mhouse));
                            }
                            catch (Exception)
                            { }
                        }
                        contents = hoc.Contents;
                        return(mhouse);
                    }
                    else
                    {
                        if (mhouse != null)
                        {
                            mhouse.Destroy();
                        }

                        NiecMod.Nra.NiecException.PrintMessagePro("Check mhouse is invalid.\nSorry :(", false, 100);
                    }
                }
                else
                {
                    NiecMod.Nra.NiecException.PrintMessagePro("Could not find Package File" + "\n" + packageFile, false, 1000);
                }
            }
            catch (Exception)
            { }
            return(null);
        }
Example #52
0
            public CreationProtection(SimDescription sim, Sim createdSim, bool performLoadFixup, bool performSelectable, bool performUnselectable)
            {
                try
                {
                    mSim = sim;

                    Corrections.RemoveFreeStuffAlarm(sim);

                    // Stops an issue in "GrantFutureObjects" regarding the use of sIsChangingWorlds=true
                    mWasFutureSim = sim.TraitManager.HasElement(TraitNames.FutureSim);
                    sim.TraitManager.RemoveElement(TraitNames.FutureSim);

                    if (SimTypes.IsSelectable(mSim))
                    {
                        Corrections.CleanupBrokenSkills(mSim, null);
                    }

                    if (OpportunityTrackerModel.gSingleton != null)
                    {
                        mOpportunitiesChanged = OpportunityTrackerModel.gSingleton.OpportunitiesChanged;
                        OpportunityTrackerModel.gSingleton.OpportunitiesChanged = null;
                    }

                    if (mSim.TraitChipManager != null)
                    {
                        mChips = mSim.TraitChipManager.GetAllTraitChips();
                        mSim.TraitChipManager.mTraitChipSlots = new TraitChip[7];
                        mSim.TraitChipManager.mValues.Clear();
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.BuffManager != null)
                        {
                            mBuffs = new List <BuffInstance>();

                            foreach (BuffInstance buff in createdSim.BuffManager.List)
                            {
                                if (!(buff is BuffCustomizable.BuffInstanceCustomizable))
                                {
                                    mBuffs.Add(buff);
                                }
                            }
                        }

                        if (createdSim.Motives != null)
                        {
                            Motive motive = createdSim.Motives.GetMotive(CommodityKind.AcademicPerformance);
                            if (motive != null)
                            {
                                mAcademicPerformance = motive.Value;
                            }

                            motive = createdSim.Motives.GetMotive(CommodityKind.UniversityStudy);
                            if (motive != null)
                            {
                                mUniversityStudy = motive.Value;
                            }
                        }

                        if (createdSim.Inventory != null)
                        {
                            mInventory = createdSim.Inventory.DestroyInventoryAndStoreInList();
                        }

                        mDreamStore = new DreamCatcher.DreamStore(createdSim, false, false);

                        mReservedVehicle           = createdSim.GetReservedVehicle();
                        createdSim.ReservedVehicle = null;
                    }

                    SafeStore.Flag flags = SafeStore.Flag.None;

                    if (performSelectable)
                    {
                        flags |= SafeStore.Flag.Selectable;
                    }

                    if (performLoadFixup)
                    {
                        flags |= SafeStore.Flag.LoadFixup;
                    }

                    if (performUnselectable)
                    {
                        flags |= SafeStore.Flag.Unselectable;
                    }

                    mSafeStore = new SafeStore(mSim, flags);

                    // Stops the startup errors when the imaginary friend is broken
                    mDoll = GetDollForSim(sim);
                    if (mDoll != null)
                    {
                        mDoll.mOwner = null;
                    }

                    mGenealogy = sim.mGenealogy;

                    mRelations = Relationships.StoreRelations(sim, null);

                    // Stops all event processing during the creation process
                    EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = true;

                    // Stops the interface from updating during OnCreation
                    if (sim.Household != null)
                    {
                        mChangedCallback  = sim.Household.HouseholdSimsChanged;
                        mChangedHousehold = sim.Household;

                        sim.Household.HouseholdSimsChanged = null;
                    }

                    sChangingWorldsSuppression.Push();

                    // Stops SetGeneologyRelationshipBits()
                    sim.mGenealogy = new Genealogy(sim);
                }
                catch (Exception e)
                {
                    Common.Exception(sim, e);
                }
            }
Example #53
0
        //public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked)
        //{
        //    return NExportHousehold(ths, household, includeLotContents, isMovingPacked, false);
        //}
        public static string NExportHousehold(Bin ths, Household household, bool includeLotContents, bool isMovingPacked, bool noReset, bool noThum)
        {
            if (ths == null)
            {
                throw new NullReferenceException();
            }
            if (household == null)
            {
                throw new ArgumentNullException("household");
            }
            try
            {
                string createdPackageFile = null;
                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    OccultImaginaryFriend.ForceHouseholdImaginaryFriendsBackToInventory(household);
                }

                if (!noReset)
                {
                    foreach (Sim sim in household.AllActors)
                    {
                        sim.SetObjectToReset();
                    }
                }

                if (Simulator.CheckYieldingContext(false))
                {
                    Simulator.Sleep(0);
                }

                ThumbnailSizeMask sizeMask;
                if (includeLotContents)
                {
                    Lot lotHome = household.LotHome;
                    if (lotHome != null)
                    {
                        int householdFunds  = household.FamilyFunds;
                        int lotHomeLotWorth = World.GetEmptyLotWorth(lotHome.LotId) + ((int)World.GetLotAdditionalPropertyValue(lotHome.LotId));

                        household.SetFamilyFunds(householdFunds + lotHomeLotWorth, false);

                        EditTownModel.SendObjectsToProperLot(lotHome);

                        ulong contentID = DownloadContent.StoreLotContents(lotHome, lotHome.LotId);
                        if (contentID != 0)
                        {
                            ThumbnailHelper.GenerateLotThumbnailSet(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailHelper.GenerateLotThumbnail(lotHome.LotId, contentID, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                            sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;
                            ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask);

                            if (!noThum && household.AllSimDescriptions.Count < 12)
                            {
                                ths.GenerateSimThumbnails(household, contentID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                            }

                            HouseholdContentsProxy contents = new HouseholdContentsProxy(household);

                            if (DownloadContent.StoreHouseholdContents(contents, contentID))
                            {
                                createdPackageFile = DownloadContent.ExportLotContentsToExportBin(contentID);
                            }

                            ThumbnailManager.InvalidateLotThumbnails(lotHome.LotId, contentID, ThumbnailSizeMask.ExtraLarge);
                            ThumbnailManager.InvalidateLotThumbnailsForGroup(lotHome.LotId, contentID, ThumbnailSizeMask.Medium, 0);
                            ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, contentID, sizeMask);

                            try
                            {
                                ths.InvalidateSimThumbnails(household, contentID);
                            }
                            catch (Exception)
                            { if (IsOpenDGSInstalled)
                              {
                                  return(null);
                              }
                            }
                        }
                        household.SetFamilyFunds(householdFunds, false);
                        return(createdPackageFile);
                    }
                    //return createdPackageFile;
                }

                int familyFunds     = household.FamilyFunds;
                int realEstateFunds = 0;
                if (household.RealEstateManager != null)
                {
                    foreach (IPropertyData data in household.RealEstateManager.AllProperties)
                    {
                        realEstateFunds += data.TotalValue;
                    }
                }

                if (household.LotHome != null)
                {
                    int lotWorth = 0;
                    if (isMovingPacked)
                    {
                        lotWorth = World.GetUnfurnishedLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }
                    else
                    {
                        lotWorth = World.GetLotWorth(household.LotHome.LotId) + realEstateFunds;
                    }

                    household.SetFamilyFunds(household.FamilyFunds + lotWorth, false);
                }

                if (household.FamilyFunds < 20000)
                {
                    household.SetFamilyFunds(20000, false);
                }

                ulong gGUID = DownloadContent.GenerateGUID();
                HouseholdContentsProxy householdContents = new HouseholdContentsProxy(household);
                householdContents.Contents.ContentId = gGUID;

                sizeMask = ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium;

                if (!noThum && household.AllSimDescriptions.Count < 12)
                {
                    ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask);
                    ths.GenerateSimThumbnails(household, gGUID, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge);
                }

                if (DownloadContent.StoreHouseholdContents(householdContents, gGUID))
                {
                    createdPackageFile = DownloadContent.ExportLotContentsToExportBin(gGUID);
                }

                ThumbnailManager.InvalidateHouseholdThumbnail(household.HouseholdId, gGUID, sizeMask);

                try
                {
                    ths.InvalidateSimThumbnails(household, gGUID);
                }
                catch (Exception)
                { if (IsOpenDGSInstalled)
                  {
                      return(null);
                  }
                }

                household.SetFamilyFunds(familyFunds, false);
                return(createdPackageFile);
            }
            catch (Exception)
            { return(null); }
        }
Example #54
0
        public override List <Sim> CreateNewborns(float bonusMoodPoints, bool interactive, bool homeBirth)
        {
            SimDescription     alien     = null;
            MiniSimDescription miniAlien = null;

            if (mDad != null && !mDad.HasBeenDestroyed)
            {
                alien = mDad.SimDescription;
            }

            if (alien == null)
            {
                alien = SimDescription.Find(DadDescriptionId);

                if (alien == null)
                {
                    miniAlien = MiniSimDescription.Find(DadDescriptionId);

                    if (miniAlien != null)
                    {
                        alien = miniAlien.UnpackSim();

                        if (alien != null)
                        {
                            Household household = Household.Create(false);

                            if (household != null)
                            {
                                household.AddTemporary(alien);
                                alien.Genealogy.SetSimDescription(alien);
                            }
                        }
                        else
                        {
                            miniAlien = null;
                        }
                    }
                }
            }

            float  averageMoodForBirth = GetAverageMoodForBirth(alien, bonusMoodPoints);
            Random pregoRandom         = new Random(mRandomGenSeed);
            int    numSims             = 0;
            int    numPets             = 0;

            mMom.Household.GetNumberOfSimsAndPets(true, out numSims, out numPets);
            int        numBirth = GetNumForBirth(alien, pregoRandom, numSims, numPets);
            Random     gen      = new Random(mRandomGenSeed);
            List <Sim> list     = new List <Sim>();

            for (int i = 0; i < numBirth; i++)
            {
                DetermineGenderOfBaby(gen);
                CASAgeGenderFlags gender = mGender;
                mGender = CASAgeGenderFlags.None;
                SimDescription babyDescription = AlienUtilsEx.MakeAlienBaby(alien, mMom.SimDescription, gender, averageMoodForBirth, pregoRandom, interactive);
                mMom.Household.Add(babyDescription);
                Sim baby = babyDescription.Instantiate(Vector3.Empty);
                baby.AddInteraction(ReturnAlienBabyEx.Singleton);
                baby.SetPosition(mMom.Position);

                if (homeBirth)
                {
                    TotallyHideBaby(baby);
                }

                list.Add(baby);
                CheckForGhostBaby(baby);

                if (baby.SimDescription.IsPlayableGhost)
                {
                    EventTracker.SendEvent(EventTypeId.kHadGhostBaby, mMom, baby);
                }

                if (i == 0)
                {
                    EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, baby.SimDescription));
                }

                MidlifeCrisisManager.OnHadChild(mMom.SimDescription);
                EventTracker.SendEvent(EventTypeId.kNewOffspring, mMom, baby);
                EventTracker.SendEvent(EventTypeId.kParentAdded, baby, mMom);

                if (mDad != null)
                {
                    EventTracker.SendEvent(EventTypeId.kNewOffspring, mDad, baby);
                    EventTracker.SendEvent(EventTypeId.kParentAdded, baby, mDad);
                }

                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, baby);
            }

            if (miniAlien != null)
            {
                alien.Household.Destroy();
                alien.Household.RemoveTemporary(alien);
                alien.Dispose(true, true);
            }

            if (mMom.Household != null)
            {
                mMom.Household.InvalidateThumbnail();
            }

            switch (numBirth)
            {
            case 2:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabyTwins, mMom.SimDescription));
                break;

            case 3:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabyTriplets, mMom.SimDescription));
                break;

            default:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabySingle, mMom.SimDescription));
                break;
            }

            return(list);
        }
Example #55
0
 protected override OptionResult Run(Lot lot, Household house)
 {
     throw new NotImplementedException();
 }
Example #56
0
 public HouseholdContentsProxy(Household household)
 {
     mContents = new HouseholdContents(household);
 }
Example #57
0
 public static bool IsFull(Scenario scenario, Household house, CASAgeGenderFlags species, int additional, bool testScoring)
 {
     return(IsFull(scenario, house, species, additional, testScoring, RandomUtil.RandomChance(scenario.GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>())));
 }
Example #58
0
 protected Task(Household house)
 {
     mHouse = house;
 }
Example #59
0
 public override void InitialTable()
 {
     Household = new Household();
 }
Example #60
0
        public static bool Household_ImportRelationships(Household _this, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader)
        {
            if (Relationship.sAllRelationships == null)
            {
                return(false);
            }

            uint ccount = 0;

            reader.ReadUint32(308660384u, out ccount, 0);

            if (ccount == 0)
            {
                return(true);
            }
            if (ccount < 0 || ccount == uint.MaxValue)
            {
                return(false);
            }

            for (uint i = 0; i < ccount; i++)
            {
                var child = reader.GetChild(i);

                ulong importID;
                ulong importID2;

                if (child == null || !child.ReadUint64(3385230853u, out importID, 0) || !child.ReadUint64(3205132738u, out importID2, 0))
                {
                    continue;
                }

                ulong simDescID  = importID;
                ulong simDescID2 = importID2;

                if (Household.sOldIdToNewSimDescriptionMap != null)
                {
                    SimDescription outSimDesc;
                    if (Household.sOldIdToNewSimDescriptionMap.TryGetValue(importID, out outSimDesc))
                    {
                        simDescID = outSimDesc.SimDescriptionId;
                    }
                    if (Household.sOldIdToNewSimDescriptionMap.TryGetValue(importID2, out outSimDesc))
                    {
                        simDescID2 = outSimDesc.SimDescriptionId;
                    }
                }

                var relationship = Relationship.Get(
                    _this.mMembers.GetSimDescriptionFromId(simDescID),
                    _this.mMembers.GetSimDescriptionFromId(simDescID2),
                    true
                    );

                if (relationship == null) // if SimDesc is invalid or SimDesc ID == 0. Should EA Bug
                {
                    continue;
                }

                relationship.ImportContent(resKeyTable, objIdTable, child);
            }
            return(true);
        }