public static void OnTest(Event e) { if (!Overwatch.Settings.mInstantationCheck) { return; } sTracer.Perform(); if (!sTracer.mAllow) { return; } bool reset = false; Sim sim = e.TargetObject as Sim; if (sim == null) { return; } SimDescription simDesc = sim.SimDescription; GreyedOutTooltipCallback callback = null; if (!RecoverMissingSimTask.Allowed(simDesc, true, ref callback)) { reset = true; } if (reset) { string notice = Common.Localize("InstantationCheck:Reset", sim.IsFemale, new object[] { sim }); if (!sAlreadyShown.ContainsKey(sim.SimDescription.SimDescriptionId)) { sAlreadyShown.Add(sim.SimDescription.SimDescriptionId, true); Common.Notify(sim, notice); } sim.Destroy(); Overwatch.Log(notice); } }
public AlienAbductionSituationEx(SimDescription alien, Sim abductee, Lot lot) : base(lot) { if (alien == null || abductee == null || lot == null) { if (alien == null) { Common.DebugNotify("Alien Abduction Situation Ex: Alien is null"); } if (abductee == null) { Common.DebugNotify("Alien Abduction Situtaion Ex: Abductee is null"); } if (lot == null) { Common.DebugNotify("Alien Abduction Situation Ex: Lot is null"); } Exit(); return; } Alien = alien.InstantiateOffScreen(LotManager.GetFarthestLot(lot)); Alien.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday, 0); Abductee = abductee; if (Alien != null && Abductee != null) { Alien.AssignRole(this); Abductee.AssignRole(this); SetState(new AbductSim(this)); return; } Alien.Destroy(); Exit(); }
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 ((sim.Partner != null) && (sim.Partner.CreatedSim != null)) { myBed.ClaimOwnership(sim, 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 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 Run() { try { if (!Actor.Inventory.Contains(Target)) { if (!Actor.RouteToObjectRadiusAndCheckInUse(Target, 0.7f)) { return(false); } StandardEntry(); BeginCommodityUpdates(); Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true); if (!Actor.Inventory.TryToAdd(Target)) { EndCommodityUpdates(false); StandardExit(); return(false); } } else { StandardEntry(); BeginCommodityUpdates(); } SocialJigTwoPerson person = GlobalFunctions.CreateObjectOutOfWorld(SocialJig.SocialJigMedatorNames.SocialJigTwoPerson.ToString()) as SocialJigTwoPerson; person.RegisterParticipants(Actor, null); Sim createdSim = null; try { World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position); fglParams.BooleanConstraints |= FindGoodLocationBooleans.Routable; if (GlobalFunctions.PlaceAtGoodLocation(person, fglParams, true)) { Route r = Actor.CreateRoute(); r.PlanToSlot(person, person.GetSlotForActor(Actor, true)); r.DoRouteFail = true; if (Actor.DoRoute(r)) { bool paramValue = false; mSummonGenieBroadcast = new ReactionBroadcaster(Actor, kSummonGenieBroadcastParams, SummonGenieBroadcastCallback); Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.Gameplay.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Gameplay); if (Target.mGenieDescription == null) { Target.mGenieDescription = OccultGenie.CreateGenie(Actor, Target); createdSim = Target.mGenieDescription.CreatedSim; EventTracker.SendEvent(EventTypeId.kCleanLamp, Actor, Target); paramValue = true; } else { createdSim = Target.mGenieDescription.Instantiate(Vector3.OutOfWorld, false); OccultGenie occultType = null; DateAndTime previousDateAndTime = SimClock.CurrentTime(); do { SpeedTrap.Sleep(0xa); occultType = createdSim.OccultManager.GetOccultType(OccultTypes.None | OccultTypes.Genie) as OccultGenie; }while ((occultType == null) && (SimClock.ElapsedTime(TimeUnit.Minutes, previousDateAndTime) < 120f)); if (occultType != null) { occultType.SetGenieLampRelations(Actor, createdSim, Target); } else { createdSim.Destroy(); createdSim = null; } } if (createdSim != null) { createdSim.FadeOut(false, false, 0f); createdSim.GreetSimOnLot(Actor.LotCurrent); createdSim.AddToWorld(); Slot slotForActor = person.GetSlotForActor(createdSim, false); createdSim.SetPosition(person.GetSlotPosition(slotForActor)); createdSim.SetForward(person.GetForwardOfSlot(slotForActor)); IGameObject actor = GlobalFunctions.CreateObject("GenieLamp", ProductVersion.EP6, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null); if (!actor.IsActorUsingMe(Actor)) { actor.AddToUseList(Actor); } EnterStateMachine("GenieLampSummon", "Enter", "x"); SetActor("lamp", actor); SetParameter("isFirstTime", paramValue); AnimateSim("Exit"); actor.Destroy(); createdSim.FadeIn(); VisualEffect effect = VisualEffect.Create("ep6GenieAppearSmoke_main"); effect.SetPosAndOrient(createdSim.Position, Vector3.UnitX, Vector3.UnitZ); effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition); OpportunityManager opportunityManager = Actor.OpportunityManager; if ((opportunityManager != null) && opportunityManager.HasOpportunity(OpportunityNames.EP6_ReleaseGenie_SummonGenie)) { OccultGenie genie2 = createdSim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie; if (genie2 == null) { createdSim.Destroy(); createdSim = null; } else { OccultGenieEx.OnFreedFromLamp(genie2, Actor, createdSim, true); if (opportunityManager.GetLastOpportunity(OpportunityCategory.Special) == OpportunityNames.EP6_ReleaseGenie_SummonGenie) { opportunityManager.ClearLastOpportunity(OpportunityCategory.Special); } EventTracker.SendEvent(EventTypeId.kGrantedWishToFreeGenie, Actor, Target); if (Target.InInventory) { Actor.Inventory.RemoveByForce(Target); if (Target.IsOnHandTool) { Target.RemoveFromWorld(); } } else { Target.RemoveFromWorld(); } EnterStateMachine("FreeTheGenie", "Enter", "x"); SetActor("x", createdSim); AnimateSim("Exit"); } } else { Target.mGenieSocializingEvent = EventTracker.AddListener(EventTypeId.kSocialInteraction, OnSocialization); Target.CheckGenieReturnToLamp = createdSim.AddAlarmRepeating(1f, TimeUnit.Minutes, Target.CheckGenieReturnToLampCallback, "Genie Check to return to lamp", AlarmType.AlwaysPersisted); Target.mTimeSinceLastSocialWithGenie = SimClock.CurrentTime(); } } } } } finally { person.Destroy(); } EndCommodityUpdates(true); StandardExit(createdSim == null, createdSim == null); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static bool Perform(SimDescription me, SimDescription.DeathType deathType) { if (me == null) { return(false); } Sim createdSim = me.CreatedSim; if (createdSim == PlumbBob.SelectedActor) { IntroTutorial.ForceExitTutorial(); LotManager.SelectNextSim(); } if (createdSim != null) { createdSim = Households.Reset.ResetSim(createdSim, false); if ((createdSim != null) && (createdSim.BuffManager != null)) { createdSim.BuffManager.RemoveAllElements(); } } Urnstone urnstone = Urnstones.CreateGrave(me, deathType, true, true); if (urnstone == null) { SimpleMessageDialog.Show(Common.Localize("ForceKill:MenuName"), Common.Localize("ForceKill:Error")); return(false); } if (createdSim != null) { if ((createdSim.Autonomy != null) && (createdSim.Autonomy.SituationComponent != null)) { List <Situation> situations = new List <Situation>(createdSim.Autonomy.SituationComponent.Situations); foreach (Situation situation in situations) { situation.Exit(); } } if (createdSim.LotCurrent != null) { Lot lotCurrent = createdSim.LotCurrent; lotCurrent.LastDiedSim = me; lotCurrent.NumDeathsOnLot++; } if (createdSim.InteractionQueue != null) { createdSim.InteractionQueue.CancelAllInteractions(); } urnstone.GhostCleanup(createdSim, true); createdSim.Destroy(); } return(true); }