public override bool Run() { try { if (!Actor.RouteToSlotAndCheckInUse(Target, BotMakingStation.kOperatorRoutingSlot)) { return(false); } StandardEntry(); BeginCommodityUpdates(); CASAgeGenderFlags adult = CASAgeGenderFlags.Adult; CASAgeGenderFlags gender = CASAgeGenderFlags.None | CASAgeGenderFlags.Male; RobotForms humanoid = RobotForms.Humanoid; SimDescription simDescription = OccultRobot.MakeRobot(adult, gender, humanoid); if (simDescription == null) { StandardExit(); return(false); } FutureSkill.SetupReactToFutureTech(Target); EnterStateMachine("BotMakingStation", "Enter", "x"); SetActor("BotMakingStation", Target); Target.SetGeometryState("on"); Animate("x", "CreateServoBot"); bool flag = false; Household.NpcHousehold.Add(simDescription); try { new Sims.Advanced.EditInCAS(true).Perform(new GameHitParameters <SimDescriptionObject>(Sim.ActiveActor, new SimDescriptionObject(simDescription), GameObjectHit.NoHit)); while (GameStates.NextInWorldStateId != InWorldState.SubState.LiveMode) { SpeedTrap.Sleep(); } flag |= CASChangeReporter.Instance.CasCancelled; Household.NpcHousehold.Remove(simDescription); Target.LotCurrent.SetDisplayLevel(LotManager.GetBestLevelToDisplayForSim(Actor, Target.LotCurrent)); Household household = Actor.Household; /* Overstuffed * if (!household.CanAddSimDescriptionToHousehold(simDescription)) * { * flag = true; * } */ if (flag) { AnimateSim("CancelCreateServoBot"); simDescription.Dispose(); AnimateSim("Exit"); } else { CASRobotData supernaturalData = simDescription.SupernaturalData as CASRobotData; supernaturalData.CreatorSim = Actor.SimDescription.SimDescriptionId; supernaturalData.BotQualityLevel = Target.GetCreationLevel(Actor); household.Add(simDescription); Sim sim = null; Slot[] containmentSlots = Target.GetContainmentSlots(); if ((containmentSlots != null) && (containmentSlots.Length > 0x0)) { Vector3 slotPosition = Target.GetSlotPosition(containmentSlots[0x0]); Vector3 forwardOfSlot = Target.GetForwardOfSlot(containmentSlots[0x0]); sim = Genetics.InstantiateRobotAndGrantPhone(simDescription, slotPosition); sim.SetPosition(slotPosition); sim.SetForward(forwardOfSlot); } else { Vector3 position = Actor.Position; Vector3 forwardVector = Actor.ForwardVector; sim = simDescription.Instantiate(position); GlobalFunctions.FindGoodLocationNearby(sim, ref position, ref forwardVector); sim.SetPosition(position); sim.SetForward(forwardVector); } Actor.Genealogy.AddChild(sim.Genealogy); InteractionQueue interactionQueue = sim.InteractionQueue; mLinkedInteraction = BotMakingStation.BeCreated.Singleton.CreateInstance(Target, sim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, false) as BotMakingStation.BeCreated; mLinkedInteraction.SyncTarget = Actor; interactionQueue.AddNext(mLinkedInteraction); Actor.SynchronizationRole = Sim.SyncRole.Initiator; Actor.SynchronizationTarget = sim; Actor.SynchronizationLevel = Sim.SyncLevel.Routed; if (!Actor.WaitForSynchronizationLevelWithSim(sim, Sim.SyncLevel.Started, 40f)) { Actor.ClearSynchronizationData(); AnimateJoinSims("CompleteCreateServoBot"); AnimateSim("ExitWithBot"); Target.SetGeometryState("off"); EndCommodityUpdates(false); StandardExit(); return(false); } SetActorAndEnter("y", sim, "BotEnter"); CASRobotData data2 = simDescription.SupernaturalData as CASRobotData; if (data2 != null) { SetParameter("IsHoverBot", data2.Form == RobotForms.Hovering); } else { SetParameter("IsHoverBot", false); } Actor.ModifyFunds(-BotMakingStation.kCostToBuildServoBot); AnimateJoinSims("CompleteCreateServoBot"); AnimateSim("ExitWithBot"); BotBuildingSkill element = Actor.SkillManager.GetElement(SkillNames.BotBuilding) as BotBuildingSkill; sim.SimDescription.TraitChipManager.UpgradeNumTraitChips(element.GetSimMaxAllowedUpgradeSlots()); EventTracker.SendEvent(EventTypeId.kCreatedBot, Actor, sim); element.OnBotCreated(); } } catch { simDescription.Dispose(); } Target.SetGeometryState("off"); EndCommodityUpdates(!flag); StandardExit(); return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); } return(false); }
public static void MergeTravelInformation(SimDescription dest, SimDescription source, bool destHomeworld) { Common.StringBuilder msg = new Common.StringBuilder("MergeTravelInformation " + dest.FullName + Common.NewLine); try { msg += "A"; Traveler.InsanityWriteLog(msg); OccupationNames sourceGuid = OccupationNames.Undefined; if (source.Occupation != null) { sourceGuid = source.Occupation.Guid; } OccupationNames destGuid = OccupationNames.Undefined; if (dest.Occupation != null) { destGuid = dest.Occupation.Guid; } if ((!destHomeworld) || (sourceGuid != destGuid)) { msg += "A1"; Traveler.InsanityWriteLog(msg); if ((!destHomeworld) || (source.Occupation != null)) { dest.CareerManager.mJob = source.Occupation; if (dest.Occupation != null) { dest.Occupation.OwnerDescription = dest; } source.CareerManager.mJob = null; } } else { msg += "A2"; Traveler.InsanityWriteLog(msg); // Update career piece-wise foreach (ICareerMerger merger in Common.DerivativeSearch.Find <ICareerMerger>()) { msg += Common.NewLine + merger.GetType().ToString(); Traveler.InsanityWriteLog(msg); merger.IPerform(dest.Occupation, source.Occupation); } } msg += Common.NewLine + "B"; Traveler.InsanityWriteLog(msg); // Custom // The MergeOccults in MergeTravelInformation can fail when removing occults OccultManagerEx.MergeOccults(dest.OccultManager, source.OccultManager); msg += "C"; Traveler.InsanityWriteLog(msg); // Original Function dest.MergeTravelInformation(source); msg += "D"; Traveler.InsanityWriteLog(msg); TrickSkill sourceTrickSkill = source.SkillManager.GetSkill <TrickSkill>(SkillNames.Trick); if (sourceTrickSkill != null) { TrickSkill destTrickSkill = dest.SkillManager.AddElement(SkillNames.Trick) as TrickSkill; if (destTrickSkill != null) { destTrickSkill.mExhibitionsPerformed = sourceTrickSkill.mExhibitionsPerformed; destTrickSkill.mMoneyEarnedFromExhibitions = sourceTrickSkill.mMoneyEarnedFromExhibitions; destTrickSkill.mTricks = sourceTrickSkill.mTricks; } } msg += "E"; Traveler.InsanityWriteLog(msg); CatHuntingSkill sourceCatSkill = source.SkillManager.GetSkill <CatHuntingSkill>(SkillNames.CatHunting); if (sourceCatSkill != null) { CatHuntingSkill destCatSkill = dest.SkillManager.AddElement(SkillNames.CatHunting) as CatHuntingSkill; if (destCatSkill != null) { destCatSkill.mOppCreepingAndCrawlingIsNew = sourceCatSkill.mOppCreepingAndCrawlingIsNew; destCatSkill.mOppSlitherStalkerIsNew = sourceCatSkill.mOppSlitherStalkerIsNew; destCatSkill.mOppFelineFisherIsNew = sourceCatSkill.mOppFelineFisherIsNew; destCatSkill.mOppHomingWhiskersIsNew = sourceCatSkill.mOppHomingWhiskersIsNew; } } msg += "F"; Traveler.InsanityWriteLog(msg); DogHuntingSkill sourceDogSkill = source.SkillManager.GetSkill <DogHuntingSkill>(SkillNames.DogHunting); if (sourceDogSkill != null) { DogHuntingSkill destDogSkill = dest.SkillManager.AddElement(SkillNames.DogHunting) as DogHuntingSkill; if (destDogSkill != null) { destDogSkill.mOppGemFinderIsNew = sourceDogSkill.mOppGemFinderIsNew; destDogSkill.mOppMetalFinderIsNew = sourceDogSkill.mOppMetalFinderIsNew; destDogSkill.mOppRockFinderIsNew = sourceDogSkill.mOppRockFinderIsNew; destDogSkill.mNumFragmentedItemsCompelted = sourceDogSkill.mNumFragmentedItemsCompelted; destDogSkill.mNumUniqueCollectablesFound = sourceDogSkill.mNumUniqueCollectablesFound; destDogSkill.mNumRGMFound = sourceDogSkill.mNumRGMFound; } } FutureSkill sourceFutureSkill = source.SkillManager.GetSkill <FutureSkill>(SkillNames.Future); if (sourceFutureSkill != null) { FutureSkill destFutureSkill = dest.SkillManager.AddElement(SkillNames.Future) as FutureSkill; if (destFutureSkill != null) { destFutureSkill.mFoodSynthesized = sourceFutureSkill.mFoodSynthesized; } } msg += "G"; Traveler.InsanityWriteLog(msg); } catch (Exception e) { Common.Exception(source, null, msg, e); } }