/// <summary> /// Registers the elements. /// </summary> /// <param name="elements">The elements.</param> public void RegisterElements(IEnumerable <string> elements) { if (_bedStatusPalette == null || _genderPalette == null) { throw new InvalidOperationException("BedStatusPalette and GenderPalette must be set before calling this method."); } _hospitalFloorData = new Dictionary <string, MapElementViewModel>(elements.Count()); IEnumerable <BedData> floorData = BedData.Load(); int freeBedsCount = 0; foreach (string id in elements) { string id1 = id; BedData data = floorData.FirstOrDefault(x => x.Id == id1); if (data != null && data.BedStatus == BedStatus.Free) { ++freeBedsCount; } _hospitalFloorData.Add(id, new MapElementViewModel(id, data, BedStatusPalette, GenderPalette)); } MapElements = _hospitalFloorData.Values; Filter = new FilterViewModel(_hospitalFloorData.Where(x => !x.Value.IsStub).Select(x => x.Value.BedData)); Filter.FilterChanged += OnFilterChanged; TotalNumberOfBeds = _hospitalFloorData.Count; TotalNumberOfFreeBeds = freeBedsCount; }
/// <summary> /// Filters the item. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public bool FilterItem(BedData item) { bool result = BedStatusFilter.Any(x => x.IsChecked && x.BedStatus == item.BedStatus); if (item.BedStatus != BedStatus.Free) { result &= GenderFilter.Any(x => x.IsChecked && x.Gender == item.Patient.Gender); if (item.BedStatus != BedStatus.Assigned) { int days = (Today - item.Patient.AdmissionDate).Days; result &= days >= MinDays && days <= MaxDays; } if (SearchByName != null) { string searchByNameLower = _searchByName.ToLower(); result &= item.Patient.Name.ToLower().Contains(searchByNameLower); } } result &= (!HasVitalSignsMonitor || item.HasVitalSignsMonitor) && (!HasXRay || item.HasXRay); return(result); }
// EA is genius... fix for genius coding in Bed.RelinquishOwnershipOfBed public static void HandleDoubleBed(Sim newOwner, Bed bed, BedData entryPart) { if (newOwner != null && bed != null && entryPart != null) { // from BedMultiPart:ClaimOwnership bool flag = (newOwner.Service != null) && (newOwner.Service.ServiceType == ServiceType.Butler); if (flag || ((newOwner.Household != null) && ((newOwner.Household.LotHome == bed.LotCurrent) || bed.IsTent))) { bed.RelinquishOwnershipOfBeds(newOwner, false); entryPart.Owner = newOwner; if (!flag) { newOwner.Household.HouseholdSimsChanged += new Household.HouseholdSimsChangedCallback(bed.HouseholdSimsChanged); } if (flag) { BedData otherPart = bed.PartComponent.GetOtherPart(entryPart) as BedData; if ((otherPart != null) && (otherPart.Owner == null)) { otherPart.Owner = newOwner; } } newOwner.Bed = bed; } } }
private void SetBedData(BedData bd) { // container.PartComp.GetPartSimIsIn(base.Actor).SetPartParameters(base.mCurrentStateMachine); PartArea area = bd.Area; switch (area) { case PartArea.Left: bd.StateNameSuffix = "Route0"; bd.IkSuffix = ""; bd.IsMirrored = false; bd.AnimationPriority = AnimationPriority.kAPNormal; break; case PartArea.Right: bd.StateNameSuffix = "Route1"; bd.IkSuffix = ""; bd.IsMirrored = true; bd.AnimationPriority = AnimationPriority.kAPNormalPlus; break; } base.mCurrentStateMachine.SetParameter("IsMirrored", bd.IsMirrored); base.mCurrentStateMachine.SetParameter("IkSuffix", bd.IkSuffix); base.mCurrentStateMachine.SetParameter("IsBedMade", bd.BedMade); base.mCurrentStateMachine.SetParameter("IsTent", false); }
public void Given_BedId_When_BedId_Field_Assigned_Expected_Same_Value_As_Given() { BedData bedData = new BedData(); bedData.BedID = 10; int expected_value = 10; int actual_value = bedData.BedID; Assert.AreEqual(actual_value, expected_value); }
public void Given_BedAvailibility_When_BedId_Field_Assigned_Expected_Same_Value_As_Given() { BedData bedData = new BedData(); bedData.BedAvailability = true; bool actual_value = bedData.BedAvailability; bool expected_value = true; Assert.AreEqual(actual_value, expected_value); }
public List <BedData> ConfigureBeds(int totalNumbersOfBeds) { List <BedData> bedsList = new List <BedData>(); BedData obj1 = new BedData(0); for (int i = 1; i <= totalNumbersOfBeds; i++) { BedData bedDataObj = new BedData(); bedsList.Add(bedDataObj); } return(bedsList); }
public void Given_PatientID_When_DischargeandDeallocateBed_Then_Patient_Is_Not_Available() { int patientID = 1; List <BedData> bedListObj = new List <BedData>(); BedData bedData = new BedData(); bedListObj.Add(bedData); List <PatientInfo> patientsListObj = new List <PatientInfo>(); PatientInfo newPatient = new PatientInfo(); patientsListObj.Add(newPatient); DischargePatient dischargePatient = new DischargePatient(); dischargePatient.DischargeandDeallocateBed(patientID, bedListObj, patientsListObj); }
public void Given_PatientID_When_AllocateBed_Invoked_Expetected_AvailableBedsDecreased() { int patientID = 0; List <BedData> listOfBeds = new List <BedData>(); BedData bedData = new BedData(); listOfBeds.Add(bedData); List <PatientInfo> patientsList = new List <PatientInfo>(); PatientInfo newPatient = new PatientInfo(); patientsList.Add(newPatient); int initial_value = (listOfBeds.FindAll(x => x.BedAvailability.Equals(true))).Count; BedAllocatorLib.BedAllocator bedAllocator = new BedAllocatorLib.BedAllocator(); bedAllocator.AllocateBed(patientID, listOfBeds, patientsList); int actual_value = (listOfBeds.FindAll(x => x.BedAvailability.Equals(true))).Count; int expected_value = initial_value - 1; Assert.AreEqual(actual_value, expected_value); }
public void Given_PatientID_When_AllocateBed_Invoked_Expetected_PatientList_Increased_By_One() { int patientID2 = 0; List <BedData> listOfBeds2 = new List <BedData>(); BedData bedDataObj = new BedData(); listOfBeds2.Add(bedDataObj); List <PatientInfo> patientsList2 = new List <PatientInfo>(); PatientInfo newPatient2 = new PatientInfo(); patientsList2.Add(newPatient2); int initial_value = patientsList2.Count; BedAllocatorLib.BedAllocator bedAllocatorObj2 = new BedAllocatorLib.BedAllocator(); bedAllocatorObj2.AllocateBed(patientID2, listOfBeds2, patientsList2); int actual_Value = patientsList2.Count; int expected_Value = initial_value + 1; Assert.AreEqual(actual_Value, expected_Value); }
public void Given_PatientID_When_AllocateBed_Invoked_Expetected_PatientList_Increased_By_One() { int patientID = 0; List <BedData> listOfBeds = new List <BedData>(); BedData bedData = new BedData(); listOfBeds.Add(bedData); List <PatientInfo> patientsList = new List <PatientInfo>(); PatientInfo newPatient = new PatientInfo(); patientsList.Add(newPatient); int initial_value = patientsList.Count; BedAllocatorLib.BedAllocator bedAllocator = new BedAllocatorLib.BedAllocator(); bedAllocator.AllocateBed(patientID, listOfBeds, patientsList); int actual_value = patientsList.Count; int expected_value = initial_value + 1; Assert.AreEqual(actual_value, expected_value); }
public void Given_PatientID_When_DischargeandDeallocateBed_Then_Patient_List_Size_Will_Decreazed_By_1() { int patientID = 1; List <BedData> listOfBeds = new List <BedData>(); BedData bedData = new BedData(); bedData.BedAvailability = false; bedData.PatientID = patientID; listOfBeds.Add(bedData); List <PatientInfo> listOfPatient = new List <PatientInfo>(); PatientInfo newPatient = new PatientInfo(); newPatient.PatientID = patientID; newPatient.BedID = 1; listOfPatient.Add(newPatient); DischargePatient dischargePatient = new DischargePatient(); dischargePatient.DischargeandDeallocateBed(patientID, listOfBeds, listOfPatient); int expectedValue = 0; int actualValue = listOfPatient.Count; Assert.AreEqual(expectedValue, actualValue); }
/// <summary> /// Initializes a new instance of the <see cref="MapElementViewModel"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="bedData">The bed data.</param> /// <param name="fillBrushes">The fill brushes.</param> /// <param name="strokeBrushes">The stroke brushes.</param> public MapElementViewModel(string name, BedData bedData, BrushCollection fillBrushes, BrushCollection strokeBrushes) { Name = name; if (bedData != null) { BedData = bedData; _fill = fillBrushes[(int)(BedData.BedStatus) + 1]; _inactiveFill = fillBrushes[0]; var strokeIndex = BedData.BedStatus != BedStatus.Free ? ((int)(BedData.Patient.Gender) + 1) : 0; _stroke = strokeBrushes[strokeIndex]; _strokeThickness = strokeIndex == 0 ? new Thickness(0) : new Thickness(3); _inactiveStroke = strokeBrushes[0]; } else { IsStub = true; _fill = fillBrushes[0]; _stroke = strokeBrushes[0]; _strokeThickness = new Thickness(1); } }
public override bool CanShareBed(Sim s, BedData entryPart, CommodityKind use, out Sim incompatibleSim) { return BedController.CanShareBed(this, s, use, out incompatibleSim); }
public void AddBed([FromBody] BedData entity) { _bedsRepository.Add(entity); }
public void UpdateBedData(string bedId, [FromBody] BedData entity) { _bedsRepository.Update(bedId, entity); }
public override bool Run() { try { Actor.GreetSimOnMyLotIfPossible(Target); if (StartBedCuddleA.GetCuddleType(Actor, Target) == StartBedCuddleA.CuddleType.CuddleTargetOnDifferentBed) { ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget }); Actor.InteractionQueue.PushAsContinuation(this, true); return(true); } BedMultiPart container = null; try { if (Actor.Posture == null) { return(false); } if (!Actor.Posture.Satisfies(CommodityKind.Relaxing, null)) { return(false); } if (!SafeToSync()) { return(false); } container = Actor.Posture.Container as BedMultiPart; if (container == null) { return(false); } if (IsMaster && ReturnInstance == null) { EnterStateMachine("BedSocials", "FromRelax", "x", "y"); AddPersistentScriptEventHandler(0x0, EventCallbackChangeVisibility); SetActor("bed", container); container.PartComp.GetPartSimIsIn(Actor).SetPartParameters(mCurrentStateMachine); WooHoo interaction = InteractionDefinition.CreateInstance(Actor, Target, GetPriority(), false, CancellableByPlayer) as WooHoo; interaction.IsMaster = false; interaction.LinkedInteractionInstance = this; ChildUtils.SetPosturePrecondition(interaction, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget }); Target.InteractionQueue.AddNext(interaction); if (Target.Posture.Container != Actor.Posture.Container) { Actor.LookAtManager.SetInteractionLookAt(Target, 0xc8, LookAtJointFilter.TorsoBones); Actor.Posture.CurrentStateMachine.RequestState("x", "callOver"); } Actor.SynchronizationLevel = Sim.SyncLevel.Started; Actor.SynchronizationTarget = Target; Actor.SynchronizationRole = Sim.SyncRole.Initiator; if (!StartSync(IsMaster)) { return(false); } if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, 30f)) { return(false); } Actor.SocialComponent.StartSocializingWith(Target); } else if (!StartSync(IsMaster)) { return(false); } } catch (ResetException) { throw; } catch (Exception e) { Common.DebugException(Actor, Target, e); return(false); } StandardEntry(false); BeginCommodityUpdates(); bool succeeded = false; try { if (IsMaster) { if (CommonWoohoo.NeedPrivacy(container.InherentlyProvidesPrivacy, Actor, Target)) { mSituation = new WooHooPrivacySituation(this); if (!mSituation.Start()) { FinishLinkedInteraction(); PostLoop(); if (ReturnInstance == null) { InteractionInstance instance = BedRelax.Singleton.CreateInstance(Actor.Posture.Container, Actor, GetPriority(), true, true); Actor.InteractionQueue.PushAsContinuation(instance, true); } else { DoResume(); } WooHoo linkedInteractionInstance = LinkedInteractionInstance as WooHoo; if (linkedInteractionInstance != null) { if (ReturnInstance == null) { InteractionInstance instance2 = BedRelax.Singleton.CreateInstance(Target.Posture.Container, Target, GetPriority(), true, true); Target.InteractionQueue.PushAsContinuation(instance2, true); } else { linkedInteractionInstance.DoResume(); } linkedInteractionInstance.Failed = true; } WaitForSyncComplete(); return(false); } } IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition; Actor.LookAtManager.ClearInteractionLookAt(); Target.LookAtManager.ClearInteractionLookAt(); if (ReturnInstance != null) { ReturnInstance.EnsureMaster(); mCurrentStateMachine = ReturnInstance.mCurrentStateMachine; } StartSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this))); InitiateSocialUI(Actor, Target); WooHoo linked = LinkedInteractionInstance as WooHoo; if (linked != null) { linked.Rejected = Rejected; } if (Rejected) { if (Actor.Posture.Container == Target.Posture.Container) { ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.DoubleBalloonData("balloon_woohoo", "balloon_question"); bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon; Actor.ThoughtBalloonManager.ShowBalloon(bd); AddOneShotScriptEventHandler(0x194, ShowRejectBalloonAndEnqueueRouteAway); mCurrentStateMachine.RequestState(false, "x", "WooHooReject"); mCurrentStateMachine.RequestState(true, "y", "WooHooReject"); mCurrentStateMachine.RequestState(true, null, "ToRelax"); } } else { mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, OnPregnancyEvent); mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, EventCallbackChangeClothes); string wooHooEffectName = container.TuningBed.WooHooEffectName; if (!string.IsNullOrEmpty(wooHooEffectName)) { mWooHooEffect = VisualEffect.Create(wooHooEffectName); mWooHooEffect.ParentTo(container, Slots.Hash("_FX_0")); AddOneShotScriptEventHandler(0xc8, EventCallbackWooHoo); AddOneShotScriptEventHandler(0xc9, EventCallbackWooHoo); } if (container is BedDreamPod) { AddOneShotScriptEventHandler(0xc8, EventCallbackDreamPodWooHoo); AddOneShotScriptEventHandler(0xc9, EventCallbackDreamPodWooHoo); } Sim.ClothesChangeReason reason = Sim.ClothesChangeReason.GoingToBed; if ((Woohooer.Settings.mNakedOutfitBed) && (!container.IsOutside)) { reason = Sim.ClothesChangeReason.GoingToBathe; Woohooer.Settings.AddChange(Actor); Woohooer.Settings.AddChange(Target); } mHelperX = new Sim.SwitchOutfitHelper(Actor, reason); mHelperY = new Sim.SwitchOutfitHelper(Target, reason); mHelperX.Start(); mHelperY.Start(); mJealousyAlarm = AlarmManager.Global.AddAlarm(kJealousyBroadcasterDelay, TimeUnit.Minutes, StartJealousyBroadcaster, "StartJealousyBroadcaster", AlarmType.DeleteOnReset, container); container.PreWooHooBehavior(Actor, Target, this); mCurrentStateMachine.RequestState(false, "x", "WooHoo"); mCurrentStateMachine.RequestState(true, "y", "WooHoo"); container.PostWooHooBehavior(Actor, Target, this); Relationship.Get(Actor, Target, true).STC.Update(Actor, Target, CommodityTypes.Amorous, kSTCIncreaseAfterWoohoo); if (CanSleep(Actor, container)) { SleepAfter = true; } else { SleepAfter = false; container.PartComp.GetPartSimIsIn(Actor).BedMade = true; } if (CanSleep(Target, container)) { (LinkedInteractionInstance as WooHoo).SleepAfter = true; } else { (LinkedInteractionInstance as WooHoo).SleepAfter = false; container.PartComp.GetPartSimIsIn(Target).BedMade = true; } /* * if (SleepAfter) * { * mCurrentStateMachine.RequestState(null, "ToSleep"); * } * else*/ { mCurrentStateMachine.RequestState(null, "ToRelax"); } CommonWoohoo.RunPostWoohoo(Actor, Target, container, definition.GetStyle(this), definition.GetLocation(container), true); if (container is BedDoubleHover) { Actor.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed); Target.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed); } if (container is BedDreamPod) { Actor.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod); Target.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod); } } FinishSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this)), true); CleanupSituation(); Actor.AddExitReason(ExitReason.Finished); } else { container = Target.Posture.Container as BedMultiPart; if (container == null) { return(false); } PartComponent <BedData> partComp = container.PartComp; if (partComp.GetSimInOtherPart(Target) == null) { int num; BedData otherPart = partComp.GetOtherPart(partComp.GetPartSimIsIn(Target)); if (!Actor.RouteToSlotListAndCheckInUse(container, otherPart.RoutingSlot, out num)) { Actor.AddExitReason(ExitReason.RouteFailed); return(false); } Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (Rejected) { Actor.PlaySoloAnimation("a2a_bed_relax_cuddle_reject_standing_y", true); Actor.RouteAway(kMinDistanceToMoveAwayWhenRejected, kMaxDistanceToMoveAwayWhenRejected, true, new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference); return(true); } if (!otherPart.RelaxOnBed(Actor, "Enter_BedRelax_" + otherPart.StateNameSuffix)) { return(false); } } else { Actor.SynchronizationLevel = Sim.SyncLevel.Routed; } DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); if (!Actor.HasExitReason(ExitReason.Finished)) { PostLoop(); WaitForMasterInteractionToFinish(); } } PostLoop(); WaitForSyncComplete(); succeeded = !Failed && !Rejected; } finally { EndCommodityUpdates(succeeded); StandardExit(false, false); } if (succeeded) { VisitSituation situation = VisitSituation.FindVisitSituationInvolvingGuest(Actor); VisitSituation situation2 = VisitSituation.FindVisitSituationInvolvingGuest(Target); if (situation != null && situation2 != null) { situation.GuestStartingInappropriateAction(Actor, 3.5f); situation2.GuestStartingInappropriateAction(Target, 3.5f); } } if (succeeded && SleepAfter) { if (!Actor.InteractionQueue.HasInteractionOfType(BedSleep.Singleton)) { InteractionInstance instance = BedSleep.Singleton.CreateInstance(container, Actor, GetPriority(), Autonomous, CancellableByPlayer); Actor.InteractionQueue.PushAsContinuation(instance, true); } if (VisitSituation.FindVisitSituationInvolvingGuest(Target) != null && Actor.IsAtHome) { SocialCallback.OnStayOver(Actor, Target, false); } else if (VisitSituation.FindVisitSituationInvolvingGuest(Actor) != null && Target.IsAtHome) { SocialCallback.OnStayOver(Target, Actor, false); } } else if (!IsOwner(Actor, container)) { InteractionInstance instance = Actor.Posture.GetStandingTransition(); if (instance != null) { Actor.InteractionQueue.Add(instance); } } return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Woohooer.Settings.AddChange(Actor); Woohooer.Settings.AddChange(Target); Common.Exception(Actor, Target, e); return(false); } }
public override bool CanShareBed(Sim s, BedData entryPart, CommodityKind use, out Sim incompatibleSim) { return(BedController.CanShareBed(this, s, use, out incompatibleSim)); }
public static Sim Perform(Sim sim, bool fadeOut) { if (sim == null) { return(null); } try { SimDescription simDesc = sim.SimDescription; if (Simulator.GetProxy(sim.ObjectId) == null) { if (simDesc != null) { sim.Destroy(); } //sim.mSimDescription = null; return(null); } if (simDesc == null) { sim.mSimDescription = new SimDescription(); sim.Destroy(); return(null); } if (sim.LotHome != null) { simDesc.IsZombie = false; if (simDesc.CreatedSim != sim) { sim.Destroy(); simDesc.CreatedSim = null; return(null); } else { Bed myBed = null; BedData myBedData = null; foreach (Bed bed in sim.LotHome.GetObjects <Bed>()) { myBedData = bed.GetPartOwnedBy(sim); if (myBedData != null) { myBed = bed; break; } } ResetPosture(sim); if (simDesc.TraitManager == null) { simDesc.mTraitManager = new TraitManager(); } try { simDesc.Fixup(); Corrections.CleanupBrokenSkills(simDesc, null); ResetCareer(simDesc); simDesc.ClearSpecialFlags(); if (simDesc.Pregnancy == null) { try { if (simDesc.mMaternityOutfits == null) { simDesc.mMaternityOutfits = new OutfitCategoryMap(); } simDesc.SetPregnancy(0, false); simDesc.ClearMaternityOutfits(); } catch (Exception e) { Common.Exception(sim, null, "Pregnancy", e); } } if (sim.CurrentCommodityInteractionMap == null) { try { LotManager.PlaceObjectOnLot(sim, sim.ObjectId); if (sim.CurrentCommodityInteractionMap == null) { sim.ChangeCommodityInteractionMap(sim.LotHome.Map); } } catch (Exception e) { Common.Exception(sim, null, "ChangeCommodityInteractionMap", e); } } } catch (Exception e) { Common.Exception(sim, null, "Fixup", e); } ResetSituations(sim); CleanupSlots(sim); ResetInventory(sim); if (fadeOut) { bool active = (Sim.ActiveActor == sim); if (sSimReset.Valid) { sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId }); } ResetRouting(sim); using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false)) { sim.Destroy(); Common.Sleep(); sim = FixInvisibleTask.InstantiateAtHome(simDesc, null); } if (sim != null) { if (active) { try { foreach (Sim member in Households.AllSims(sim.Household)) { if (member.CareerManager == null) { continue; } Occupation occupation = member.CareerManager.Occupation; if (occupation == null) { continue; } occupation.FormerBoss = null; } using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true)) { PlumbBob.DoSelectActor(sim, true); } } catch (Exception e) { Common.Exception(sim, null, "DoSelectActor", e); } } if ((myBed != null) && (myBedData != null)) { if (!(myBed is BedMultiPart) || (myBed is BedMultiPart && ((sim.Partner != null) && (sim.Partner.CreatedSim != null)))) { myBed.ClaimOwnership(sim, myBedData); } else { HandleDoubleBed(sim, myBed, myBedData); } } } } else { if (sim.Inventory == null) { sim.AddComponent <InventoryComponent>(new object[0x0]); } if (Instantiation.AttemptToPutInSafeLocation(sim, false)) { ResetRouting(sim); sim.SetObjectToReset(); // This is necessary to clear certain types of interactions // (it is also called in SetObjectToReset(), though doesn't always work there) if (sim.InteractionQueue != null) { sim.InteractionQueue.OnReset(); } } } ResetSkillModifiers(simDesc); ResetRole(sim); if (simDesc.IsEnrolledInBoardingSchool()) { simDesc.BoardingSchool.OnRemovedFromSchool(); } MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId); if (miniSim != null) { miniSim.Instantiated = true; } UpdateInterface(sim); return(sim); } } else if (simDesc.Service is Butler) { if (Instantiation.AttemptToPutInSafeLocation(sim, true)) { sim.Motives.RecreateMotives(sim); sim.SetObjectToReset(); } return(sim); } else if (simDesc.IsImaginaryFriend) { OccultImaginaryFriend friend; if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend)) { if (Simulator.GetProxy(friend.mDollId) != null) { friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner); return(null); } } } else if (simDesc.IsBonehilda) { foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>()) { if (coffin.mBonehilda == simDesc) { coffin.mBonehildaSim = null; break; } } } if (fadeOut) { sim.Destroy(); } return(null); } catch (Exception exception) { Common.Exception(sim, exception); return(sim); } }
public override bool CanShareBed(Sim s, BedData entryPart, Sims3.Gameplay.Autonomy.CommodityKind use, out Sim incompatibleSim) { incompatibleSim = null; return(true); }
public override void ClaimOwnership(Sim newOwner, BedData entryPart) { base.ClaimOwnership(newOwner, entryPart); }
protected bool Run(Sim client, Sim solicitor) { bool flag3 = false; ObjectGuid bedId = new ObjectGuid(); #region Initialize relationship data //Increase the relationship for a moment, so sims can relax on the same bed Relationship rRelationship = Relationship.Get(base.Actor, base.Target, true); float originalLTR = 0; Boolean changeLTR = false; Boolean lover = false; Boolean clientHasLFMoodlet = CommonMethods.HasMoodlet(client, BuffNames.LostAFriend, Origin.FromSocialization); Boolean soliciterHasLFMoodlet = CommonMethods.HasMoodlet(solicitor, BuffNames.LostAFriend, Origin.FromSocialization); #endregion try { this.Actor.GreetSimOnMyLotIfPossible(this.Target); if (StartBedCuddleA.GetCuddleType(this.Actor, this.Target) == StartBedCuddleA.CuddleType.CuddleTargetOnDifferentBed) { ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget }); this.Actor.InteractionQueue.PushAsContinuation(this, true); return(true); } if (!this.Actor.Posture.Satisfies(CommodityKind.Relaxing, null)) { return(false); } if (!base.SafeToSync()) { return(false); } BedMultiPart bedMultiPart = this.Actor.Posture.Container as BedMultiPart; bedId = bedMultiPart.ObjectId; if (this.IsMaster && this.ReturnInstance == null) { base.EnterStateMachine("BedSocials", "FromRelax", "x", "y"); base.AddPersistentScriptEventHandler(0u, new SacsEventHandler(this.EventCallbackChangeVisibility)); base.SetActor("bed", bedMultiPart); BedData partSimIsIn = bedMultiPart.PartComp.GetPartSimIsIn(this.Actor); partSimIsIn.SetPartParameters(this.mCurrentStateMachine); WooHoo wooHoo = base.InteractionDefinition.CreateInstance(this.Actor, this.Target, base.GetPriority(), false, base.CancellableByPlayer) as WooHoo; wooHoo.IsMaster = false; wooHoo.LinkedInteractionInstance = this; ChildUtils.SetPosturePrecondition(wooHoo, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget }); this.Target.InteractionQueue.AddNext(wooHoo); if (this.Target.Posture.Container != this.Actor.Posture.Container) { this.Actor.LookAtManager.SetInteractionLookAt(this.Target, 200, LookAtJointFilter.TorsoBones); this.Actor.Posture.CurrentStateMachine.RequestState("x", "callOver"); } this.Actor.SynchronizationLevel = Sim.SyncLevel.Started; this.Actor.SynchronizationTarget = this.Target; this.Actor.SynchronizationRole = Sim.SyncRole.Initiator; if (!base.StartSync(this.IsMaster)) { return(false); } if (!this.Actor.WaitForSynchronizationLevelWithSim(this.Target, Sim.SyncLevel.Routed, 30f)) { return(false); } base.StartSocialContext(); } else { if (!base.StartSync(this.IsMaster)) { return(false); } } base.StandardEntry(false); base.BeginCommodityUpdates(); if (this.IsMaster) { if (!bedMultiPart.InherentlyProvidesPrivacy) { this.mSituation = new WooHoo.WooHooPrivacySituation(this); if (!this.mSituation.Start()) { base.FinishLinkedInteraction(); base.PostLoop(); if (this.ReturnInstance == null) { InteractionInstance instance = BedRelax.Singleton.CreateInstance(this.Actor.Posture.Container, this.Actor, base.GetPriority(), true, true); this.Actor.InteractionQueue.PushAsContinuation(instance, true); } else { base.DoResume(); } WooHoo wooHoo2 = this.LinkedInteractionInstance as WooHoo; if (wooHoo2 != null) { if (this.ReturnInstance == null) { InteractionInstance instance2 = BedRelax.Singleton.CreateInstance(this.Target.Posture.Container, this.Target, base.GetPriority(), true, true); this.Target.InteractionQueue.PushAsContinuation(instance2, true); } else { wooHoo2.DoResume(); } wooHoo2.Failed = true; } base.WaitForSyncComplete(); base.EndCommodityUpdates(false); base.StandardExit(false, false); return(false); } } this.Actor.LookAtManager.ClearInteractionLookAt(); this.Target.LookAtManager.ClearInteractionLookAt(); if (this.ReturnInstance != null) { this.ReturnInstance.EnsureMaster(); this.mCurrentStateMachine = this.ReturnInstance.mCurrentStateMachine; } base.StartSocial(this.SocialName); base.InitiateSocialUI(this.Actor, this.Target); this.Rejected = false; (this.LinkedInteractionInstance as WooHoo).Rejected = this.Rejected; if (this.Rejected) { if (this.Actor.Posture.Container == this.Target.Posture.Container) { ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.DoubleBalloonData("balloon_woohoo", "balloon_question"); balloonData.BalloonType = ThoughtBalloonTypes.kSpeechBalloon; this.Actor.ThoughtBalloonManager.ShowBalloon(balloonData); base.AddOneShotScriptEventHandler(404u, new SacsEventHandler(this.ShowRejectBalloonAndEnqueueRouteAway)); this.mCurrentStateMachine.RequestState(false, "x", "WooHooReject"); this.mCurrentStateMachine.RequestState(true, "y", "WooHooReject"); this.mCurrentStateMachine.RequestState(true, null, "ToRelax"); } this.Actor.BuffManager.AddElement(BuffNames.WalkOfShame, Origin.FromRejectedWooHooOffHome); } else { if (this.BabyMade()) { this.mCurrentStateMachine.AddOneShotScriptEventHandler(110u, new SacsEventHandler(this.EventCallbackPlayBabySound)); } this.mCurrentStateMachine.AddOneShotScriptEventHandler(110u, new SacsEventHandler(this.EventCallbackChangeClothes)); string wooHooEffectName = bedMultiPart.TuningBed.WooHooEffectName; if (!string.IsNullOrEmpty(wooHooEffectName)) { this.mWooHooEffect = VisualEffect.Create(wooHooEffectName); this.mWooHooEffect.ParentTo(bedMultiPart, Slots.Hash("_FX_0")); base.AddOneShotScriptEventHandler(200u, new SacsEventHandler(this.EventCallbackWooHoo)); base.AddOneShotScriptEventHandler(201u, new SacsEventHandler(this.EventCallbackWooHoo)); } this.mHelperX = new Sim.SwitchOutfitHelper(this.Actor, Sim.ClothesChangeReason.GoingToBed); this.mHelperY = new Sim.SwitchOutfitHelper(this.Target, Sim.ClothesChangeReason.GoingToBed); this.mHelperX.Start(); this.mHelperY.Start(); this.mJealousyAlarm = AlarmManager.Global.AddAlarm(WooHoo.kJealousyBroadcasterDelay, TimeUnit.Minutes, new AlarmTimerCallback(this.StartJealousyBroadcaster), "StartJealousyBroadcaster", AlarmType.DeleteOnReset, bedMultiPart); bedMultiPart.PreWooHooBehavior(this.Actor, this.Target, this); this.mCurrentStateMachine.RequestState(false, "x", "WooHoo"); this.mCurrentStateMachine.RequestState(true, "y", "WooHoo"); bedMultiPart.PostWooHooBehavior(this.Actor, this.Target, this); Relationship relationship = Relationship.Get(this.Actor, this.Target, true); relationship.STC.Update(this.Actor, this.Target, CommodityTypes.Amorous, WooHoo.kSTCIncreaseAfterWoohoo); InteractionInstance nextInteraction = this.Actor.InteractionQueue.GetNextInteraction(); bool flag = nextInteraction != null; bool flag2 = flag && nextInteraction.PosturePreconditions != null && nextInteraction.PosturePreconditions.ContainsPosture(CommodityKind.Sleeping); nextInteraction = this.Target.InteractionQueue.GetNextInteraction(); flag = (flag || nextInteraction != null); flag2 = (flag2 && nextInteraction != null && nextInteraction.PosturePreconditions != null && nextInteraction.PosturePreconditions.ContainsPosture(CommodityKind.Sleeping)); if ((this.mSituation != null && this.mSituation.SomeoneDidIntrude) || (flag && !flag2)) { this.SleepAfter = false; } else { this.SleepAfter = (BedSleep.CanSleep(this.Actor, true) && BedSleep.CanSleep(this.Target, true)); } (this.LinkedInteractionInstance as WooHoo).SleepAfter = this.SleepAfter; if (this.SleepAfter) { this.mCurrentStateMachine.RequestState(null, "ToSleep"); } else { this.mCurrentStateMachine.RequestState(null, "ToRelax"); bedMultiPart.PartComp.GetPartSimIsIn(this.Actor).BedMade = true; bedMultiPart.PartComp.GetPartSimIsIn(this.Target).BedMade = true; } SocialCallback.RunPostWoohoo(this.Actor, this.Target, bedMultiPart); if (bedMultiPart is BedDoubleHover) { this.Actor.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed); this.Target.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed); } } base.FinishSocial(this.SocialName, true); this.CleanupSituation(); this.Actor.AddExitReason(ExitReason.Finished); } else { bedMultiPart = (this.Target.Posture.Container as BedMultiPart); if (bedMultiPart == null) { return(false); } PartComponent <BedData> partComp = bedMultiPart.PartComp; if (partComp.GetSimInOtherPart(this.Target) == null) { BedData otherPart = partComp.GetOtherPart(partComp.GetPartSimIsIn(this.Target)); int num; if (!this.Actor.RouteToSlotListAndCheckInUse(bedMultiPart, otherPart.RoutingSlot, out num)) { this.Actor.AddExitReason(ExitReason.RouteFailed); return(false); } this.Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (this.Rejected) { this.Actor.PlaySoloAnimation("a2a_bed_relax_cuddle_reject_standing_y", true); this.Actor.RouteAway(WooHoo.kMinDistanceToMoveAwayWhenRejected, WooHoo.kMaxDistanceToMoveAwayWhenRejected, true, new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference); return(true); } if (!otherPart.RelaxOnBed(this.Actor, "Enter_BedRelax_" + otherPart.StateNameSuffix)) { return(false); } } else { this.Actor.SynchronizationLevel = Sim.SyncLevel.Routed; } base.DoLoop(ExitReason.Default); if (!this.Actor.HasExitReason(ExitReason.Finished)) { base.PostLoop(); base.WaitForMasterInteractionToFinish(); } } base.PostLoop(); base.WaitForSyncComplete(); flag3 = true;// !this.Failed && !this.Rejected; base.EndCommodityUpdates(flag3); base.StandardExit(false, false); if (flag3) { VisitSituation visitSituation = VisitSituation.FindVisitSituationInvolvingGuest(this.Actor); VisitSituation visitSituation2 = VisitSituation.FindVisitSituationInvolvingGuest(this.Target); if (visitSituation != null && visitSituation2 != null) { visitSituation.GuestStartingInappropriateAction(this.Actor, 3.5f); visitSituation2.GuestStartingInappropriateAction(this.Target, 3.5f); } } if (flag3 && this.SleepAfter) { bedMultiPart.GetPartContaining(this.Actor).StateMachine = null; if (!this.Actor.InteractionQueue.HasInteractionOfType(BedSleep.Singleton)) { InteractionInstance instance3 = BedSleep.Singleton.CreateInstance(bedMultiPart, this.Actor, base.GetPriority(), base.Autonomous, base.CancellableByPlayer); this.Actor.InteractionQueue.PushAsContinuation(instance3, true); } VisitSituation visitSituation3 = VisitSituation.FindVisitSituationInvolvingGuest(this.Target); if (visitSituation3 != null && this.Actor.IsAtHome) { SocialCallback.OnStayOver(this.Actor, this.Target, false); } else { visitSituation3 = VisitSituation.FindVisitSituationInvolvingGuest(this.Actor); if (visitSituation3 != null && this.Target.IsAtHome) { SocialCallback.OnStayOver(this.Target, this.Actor, false); } } } } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format(ex.ToString(), StyledNotification.NotificationStyle.kGameMessageNegative)); } finally { try { if (flag3) { #region Ge Payed and such CommonMethods.HandlePostWoohoo(client, solicitor, bedId); #endregion } #region Restore LTR if (rRelationship != null && changeLTR) { rRelationship.LTR.SetLiking(originalLTR); //Remove the lost friend moodlets if we didn't have them before, but have them now if (!clientHasLFMoodlet && CommonMethods.HasMoodlet(client, BuffNames.LostAFriend, Origin.FromSocialization)) { client.BuffManager.RemoveElement(BuffNames.LostAFriend); } if (!soliciterHasLFMoodlet && CommonMethods.HasMoodlet(solicitor, BuffNames.LostAFriend, Origin.FromSocialization)) { solicitor.BuffManager.RemoveElement(BuffNames.LostAFriend); } //If we were not lovers, before but are now, remove the icon if (lover) { rRelationship.LTR.RemoveInteractionBit(LongTermRelationship.InteractionBits.Romantic); } } } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format("finally: " + ex.Message, StyledNotification.NotificationStyle.kGameMessageNegative)); } #endregion } return(flag3); }
public override bool Run() { try { Actor.GreetSimOnMyLotIfPossible(Target); if (GetCuddleType(Actor, Target) == CuddleType.CuddleTargetOnDifferentBed) { ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget }); Actor.InteractionQueue.PushAsContinuation(this, true); return(true); } if (!SafeToSync()) { return(false); } // Custom mReactToSocialBroadcaster = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventMedium); //SocialComponent.SendCheatingEvents(Actor, Target, !Rejected); StartBedCuddleB entry = StartBedCuddleB.Singleton.CreateInstance(Actor, Target, GetPriority(), false, CancellableByPlayer) as StartBedCuddleB; LinkedInteractionInstance = entry; Target.InteractionQueue.Add(entry); if (Target.Posture.Container != Actor.Posture.Container) { Actor.LookAtManager.SetInteractionLookAt(Target, 0xc8, LookAtJointFilter.TorsoBones); Actor.Posture.CurrentStateMachine.RequestState("x", "callOver"); } Actor.SynchronizationLevel = Sim.SyncLevel.Started; Actor.SynchronizationTarget = Target; Actor.SynchronizationRole = Sim.SyncRole.Initiator; if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Started, Bed.kTimeToWaitForOtherToArriveForCuddling)) { return(false); } Actor.Posture.CurrentStateMachine.RequestState("x", "ExitRelaxing"); StartSocial("Cuddle"); entry.Rejected = Rejected; Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, Bed.kTimeToWaitForOtherToArriveForCuddling)) { return(false); } if (Rejected) { if (Actor.Posture.Container == Target.Posture.Container) { BedMultiPart container = Actor.Posture.Container as BedMultiPart; BedData partSimIsIn = container.PartComp.GetPartSimIsIn(Actor); EnterStateMachine("BedSocials", "FromRelax", "x", "y"); mCurrentStateMachine.EnterState("y", "FromRelax"); mCurrentStateMachine.EnterState("bed", "FromRelax"); SetActor("bed", container); partSimIsIn.SetPartParameters(mCurrentStateMachine); mCurrentStateMachine.RequestState(false, "x", "CuddleReject"); mCurrentStateMachine.RequestState(false, "bed", "CuddleReject"); mCurrentStateMachine.RequestState(true, "y", "CuddleReject"); mCurrentStateMachine.RequestState(null, "ToRelax"); Target.RouteAway(kMinDistanceToMoveAwayWhenRejected, kMaxDistanceToMoveAwayWhenRejected, true, new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference); } else { Actor.Posture.CurrentStateMachine.RequestState(true, "x", "CallOverReject"); } return(false); } if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Completed, Bed.kTimeToWaitForOtherToArriveForCuddling)) { return(false); } InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.Zero); CuddleRelaxing relaxing = CuddleRelaxing.Singleton.CreateInstance(Target, Actor, priority, false, CancellableByPlayer) as CuddleRelaxing; relaxing.IsMaster = true; relaxing.AdoptSocialEffect(this); CuddleRelaxing relaxing2 = CuddleRelaxing.Singleton.CreateInstance(Actor, Target, priority, false, CancellableByPlayer) as CuddleRelaxing; relaxing2.IsMaster = false; relaxing.LinkedInteractionInstance = relaxing2; EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Cuddle", false, !Rejected, false, CommodityTypes.Undefined)); EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Cuddle", true, !Rejected, false, CommodityTypes.Undefined)); Actor.InteractionQueue.Add(relaxing); Target.InteractionQueue.Add(relaxing2); return(!Rejected); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
private bool Route() { Slot slot; // Sim sim; BedData partContaining = base.Target.GetPartContaining(base.Actor); if (partContaining != null) { //if (base.Actor.Posture is SleepingPosture) if (base.Actor.Posture.Satisfies(CommodityKind.Sleeping, null)) { StateMachineClient stateMachine = partContaining.StateMachine; if (stateMachine != null) { stateMachine.RequestState("x", "ExitRelax"); partContaining.StateMachine = null; } partContaining.BedMade = true; } this.mEntryStateName = "Enter_OnBed_" + partContaining.StateNameSuffix; this.mEntryPart = partContaining; return(true); } if (base.Target.SimLine != null) { ExitReason exitReasons = ~(ExitReason.MidRoutePushRequested | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached); if (!base.Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, exitReasons, 30f) || base.Actor.HasExitReason(exitReasons)) { return(false); } this.mbInLine = true; } PartData partClosestToHit = base.GetPartClosestToHit(); List <PartData> parts = new List <PartData>(); foreach (PartData data3 in base.Target.PartComp.PartDataList.Values) { parts.Add(data3); } if (!base.Actor.RouteToUnusedPart(parts, partClosestToHit, out slot)) { return(false); } BedData entryPart = null; // Label_017C: foreach (BedData data5 in base.Target.PartComp.PartDataList.Values) { for (int i = 0; i < data5.RoutingSlot.Length; i++) { if ((data5.RoutingSlot[i] == slot) && !data5.InUse) { entryPart = data5; } } } if (!base.Target.SetContainedObject(entryPart, base.Actor)) { base.Actor.AddExitReason(ExitReason.FailedToStart); return(false); } this.mEntryStateName = "Enter_BedRelax_" + entryPart.StateNameSuffix; this.mEntryPart = entryPart; return(true); }