示例#1
0
        /// <summary>
        /// Make roommate selectable
        /// </summary>
        /// <param name="roommate"></param>
        private static void RemoveRoommate(SimDescription roommate)
        {
            try
            {
                Door[] doors = roommate.LotHome.GetObjects<Door>();
                List<DoorInfo> doorInfoList = new List<DoorInfo>();
                DoorInfo df;

                for (int i = 0; i < doors.Length; i++)
                {
                    df = new DoorInfo();
                    df.doorId = doors[i].ObjectId;
                    df.doorIndex = i;
                    df.mLockType = doors[i].LockType;

                    //Door locks
                    if (doors[i].mLockOwner != null && doors[i].mLockOwner.SimDescriptionId == roommate.SimDescriptionId)
                    {
                        df.isOwner = true;
                    }

                    if (doors[i].mOwnerList != null && doors[i].mOwnerList.Contains(roommate.SimDescriptionId))
                    {
                        df.isInOwnerList = true;
                    }

                    if (df.isOwner || df.isInOwnerList)
                        doorInfoList.Add(df);
                }

                //Add remove sims from household
                bool success = Household.RoommateManager.RemoveRoommateInternal(roommate);

                Household h = roommate.Household;
                h.Remove(roommate);
                h.Add(roommate);

                //Restore door locks            
                foreach (DoorInfo info in doorInfoList)
                {
                    doors[info.doorIndex].SetLockType(info.mLockType);

                    // CommonMethods.PrintMessage(roommate.FullName + " " + info.mLockType + " owner: " + info.isOwner +  " isOwnerList: " + info.isInOwnerList);

                    if (info.isInOwnerList)
                    {
                        List<SimDescription> list = new List<SimDescription>();
                        if (doors[info.doorIndex].OwnerList != null)
                        {
                            foreach (ulong item in doors[info.doorIndex].OwnerList)
                            {
                                //Find the sim in question 
                                SimDescription sd = roommate.Household.SimDescriptions.Find(delegate(SimDescription sd2) { return sd2.SimDescriptionId == item; });
                                if (sd != null)
                                    list.Add(sd);
                            }
                        }
                        list.Add(roommate);
                        doors[info.doorIndex].SetLockTypeOwnerList(list);
                    }

                    if (info.isOwner)
                    {
                        doors[info.doorIndex].SetLockTypeAndOwner(info.mLockType, roommate);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonMethods.PrintMessage("Remove Roommate: " + ex.Message);
            }
            finally
            {
            }
        }
示例#2
0
        /// <summary>
        /// Make roommate selectable
        /// </summary>
        /// <param name="roommate"></param>
        private static void RemoveRoommate(SimDescription roommate)
        {
            try
            {
                Door[]          doors        = roommate.LotHome.GetObjects <Door>();
                List <DoorInfo> doorInfoList = new List <DoorInfo>();
                DoorInfo        df;

                for (int i = 0; i < doors.Length; i++)
                {
                    df           = new DoorInfo();
                    df.doorId    = doors[i].ObjectId;
                    df.doorIndex = i;
                    df.mLockType = doors[i].LockType;

                    //Door locks
                    if (doors[i].mLockOwner != null && doors[i].mLockOwner.SimDescriptionId == roommate.SimDescriptionId)
                    {
                        df.isOwner = true;
                    }

                    if (doors[i].mOwnerList != null && doors[i].mOwnerList.Contains(roommate.SimDescriptionId))
                    {
                        df.isInOwnerList = true;
                    }

                    if (df.isOwner || df.isInOwnerList)
                    {
                        doorInfoList.Add(df);
                    }
                }

                //Add remove sims from household
                bool success = Household.RoommateManager.RemoveRoommateInternal(roommate);

                Household h = roommate.Household;
                h.Remove(roommate);
                h.Add(roommate);

                //Restore door locks
                foreach (DoorInfo info in doorInfoList)
                {
                    doors[info.doorIndex].SetLockType(info.mLockType);

                    // CommonMethods.PrintMessage(roommate.FullName + " " + info.mLockType + " owner: " + info.isOwner +  " isOwnerList: " + info.isInOwnerList);

                    if (info.isInOwnerList)
                    {
                        List <SimDescription> list = new List <SimDescription>();
                        if (doors[info.doorIndex].OwnerList != null)
                        {
                            foreach (ulong item in doors[info.doorIndex].OwnerList)
                            {
                                //Find the sim in question
                                SimDescription sd = roommate.Household.SimDescriptions.Find(delegate(SimDescription sd2) { return(sd2.SimDescriptionId == item); });
                                if (sd != null)
                                {
                                    list.Add(sd);
                                }
                            }
                        }
                        list.Add(roommate);
                        doors[info.doorIndex].SetLockTypeOwnerList(list);
                    }

                    if (info.isOwner)
                    {
                        doors[info.doorIndex].SetLockTypeAndOwner(info.mLockType, roommate);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonMethods.PrintMessage("Remove Roommate: " + ex.Message);
            }
            finally
            {
            }
        }