protected override void PrivatePerformAction(bool prompt) { Overwatch.Log(Name); foreach (Sim createdSim in new List <Sim> (LotManager.Actors)) { StuckSimData other; if (!sData.TryGetValue(createdSim.SimDescription.SimDescriptionId, out other)) { other = new StuckSimData(); sData.Add(createdSim.SimDescription.SimDescriptionId, other); } try { bool wasReset = false; if ((createdSim != null) && (createdSim.InWorld) && (createdSim.Proxy != null) && (!SimTypes.IsSelectable(createdSim))) { bool check = true; if (createdSim.Parent is IBed) { check = false; } if (createdSim.OccultManager != null) { OccultRobot bot = createdSim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.Robot) as OccultRobot; if (bot != null && bot.IsShutdown) { check = false; } } if (check) { InteractionInstance interaction = createdSim.CurrentInteraction; bool sameInteraction = (object.ReferenceEquals(other.mLastInteraction, interaction)); other.mLastInteraction = interaction; if (createdSim.LotCurrent.IsRoomHidden(createdSim.RoomId)) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } if ((!wasReset) && (other.mLastPosition != Vector3.Invalid) && (other.mLastPosition == createdSim.Position)) { if ((interaction == null) || (sameInteraction)) { bool success = false; try { success = SimEx.IsPointInLotSafelyRoutable(createdSim, createdSim.LotCurrent, createdSim.PositionOnFloor); } catch (Exception e) { Common.DebugException(createdSim, e); success = false; } if (!success) { ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable"); wasReset = true; } } } if (other.mLastPosition != createdSim.Position) { other.mLastPosition = createdSim.Position; other.mLastPositionTicks = SimClock.CurrentTicks; } else if ((prompt) || ((other.mLastPositionTicks + SimClock.kSimulatorTicksPerSimDay) < SimClock.CurrentTicks)) { if (!wasReset) { bool reset = false; if (sameInteraction) { reset = true; } if (reset) { ResetTask.Perform(createdSim, Vector3.Invalid, "Stationary"); wasReset = true; } } } } } else { wasReset = true; } if (wasReset) { sData.Remove(createdSim.SimDescription.SimDescriptionId); } } catch (Exception e) { Common.Exception(createdSim, e); } } }
protected override bool PrivateUpdate(ScenarioFrame frame) { if (Sim.CreatedSim == null) { Sims.Instantiate(Sim, Sim.LotHome, false); } if (Target.CreatedSim == null) { Sims.Instantiate(Target, Target.LotHome, false); } if ((Sim.CreatedSim == null) || (Target.CreatedSim == null)) { IncStat("Uninstantiated"); return(false); } else { if (Sim.IsRobot) { if ((Sim.LotHome == null) || ((Sim.LotHome.CountObjects <BotMakingStation> () + Sim.LotHome.CountObjects <InventionWorkbench>()) == 0)) { IncStat("No Workbench"); return(false); } SimDescription child = null; if (Sim.IsFrankenstein) { bool reward = Sim.OccultManager.mIsLifetimeReward; if ((Target.IsFrankenstein) && (RandomUtil.CoinFlip())) { reward = Target.OccultManager.mIsLifetimeReward; } Sim childSim = OccultFrankenstein.CreateFrankenStein(Sim.CreatedSim, CASAgeGenderFlags.None, reward); if (childSim == null) { IncStat("Creation Fail"); return(false); } child = childSim.SimDescription; } else { child = OccultRobot.MakeRobot(CASAgeGenderFlags.Adult, CASAgeGenderFlags.None, RobotForms.MaxType); if (child == null) { IncStat("Creation Fail"); return(false); } CASRobotData supernaturalData = child.SupernaturalData as CASRobotData; if (supernaturalData != null) { supernaturalData.CreatorSim = Sim.SimDescriptionId; int quality = 0; int count = 0; CASRobotData parentData = Sim.SupernaturalData as CASRobotData; if (parentData != null) { quality = parentData.BotQualityLevel; count++; } parentData = Target.SupernaturalData as CASRobotData; if (parentData != null) { quality += parentData.BotQualityLevel; count++; } if (count == 2) { quality /= count; } supernaturalData.BotQualityLevel = quality; } } if (child.Genealogy.Parents.Count == 0) { Sim.Genealogy.AddChild(child.Genealogy); } Target.Genealogy.AddChild(child.Genealogy); if (!Households.MoveSim(child, Sim.Household)) { IncStat("Move Fail"); Deaths.CleansingKill(child, true); return(false); } return(true); } else if (Target.IsRobot) { IncStat("Simbot Partner"); return(false); } else { if (CommonSpace.Helpers.Pregnancies.Start(Sim.CreatedSim, Target, false) != null) { ManagerSim.ForceRecount(); if (Sim.IsHuman) { if (OnGatheringScenario != null) { OnGatheringScenario(this, frame); } } if ((!Sim.IsHuman) && (Sim.Partner != Target)) { if ((GetValue <AllowMarriageOption, bool>(Sim)) && (GetValue <AllowMarriageOption, bool>(Target))) { if ((Romances.AllowBreakup(this, Sim, Managers.Manager.AllowCheck.None)) && (Romances.AllowBreakup(this, Target, Managers.Manager.AllowCheck.None))) { RemoveAllPetMateFlags(Sim); RemoveAllPetMateFlags(Target); Relationship.Get(Sim, Target, false).LTR.AddInteractionBit(LongTermRelationship.InteractionBits.Marry); } } } } return(true); } } }
// From OccultManager protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd) { OccultBaseClass newOccult = null; OccultBaseClass oldOccult = ths.VerifyOccultList(type); if (overrideOccultToAdd != null) { newOccult = overrideOccultToAdd; } else { switch (type) { case OccultTypes.Mummy: newOccult = new OccultMummy(); break; case OccultTypes.Frankenstein: newOccult = new OccultFrankenstein(); break; case OccultTypes.Vampire: newOccult = new OccultVampire(); break; case OccultTypes.ImaginaryFriend: OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend; if (oldImFr == null) { newOccult = new OccultImaginaryFriend(); } else { newOccult = new OccultImaginaryFriend(oldImFr); } break; case OccultTypes.Unicorn: newOccult = new OccultUnicorn(); break; case OccultTypes.Fairy: newOccult = new OccultFairy(); break; case OccultTypes.Witch: newOccult = new OccultWitch(); break; case OccultTypes.Genie: newOccult = new OccultGenie(); break; case OccultTypes.Werewolf: newOccult = new OccultWerewolf(); break; case OccultTypes.PlantSim: newOccult = new OccultPlantSim(); break; case OccultTypes.Mermaid: newOccult = new OccultMermaid(); break; case OccultTypes.TimeTraveler: newOccult = new OccultTimeTraveler(); break; case OccultTypes.Robot: newOccult = new OccultRobot(); break; } } if (newOccult == null) { return(false); } OccultTypes originalTypes = ths.mCurrentOccultTypes; Role assignedRole = ths.mOwnerDescription.AssignedRole; float alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage; try { ths.mCurrentOccultTypes = OccultTypes.None; ths.mOwnerDescription.AssignedRole = null; ths.mOwnerDescription.mAlienDNAPercentage = 0f; if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore)) { return(false); } } finally { ths.mCurrentOccultTypes = originalTypes; ths.mOwnerDescription.AssignedRole = assignedRole; ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage; } if ((ths.mOwnerDescription.SupernaturalData == null) || ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) || ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) || ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim))) { ths.mOwnerDescription.AddSupernaturalData(type); } ths.mIsLifetimeReward = isReward; if (type == OccultTypes.Genie) { // Corrections for improper handling of the special outfits by OccultGenie if (ths.mOwnerDescription.mSpecialOutfitIndices == null) { ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary <uint, int>(); } addOutfit = false; } if (type == OccultTypes.Unicorn) { OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit); } ApplyTrait(ths.mOwnerDescription, type); MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager; try { // Inactive mummies don't agree with mid-life crisis managers ths.mOwnerDescription.MidlifeCrisisManager = null; newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore); } finally { ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager; } ths.mOccultList.Add(newOccult); ths.mCurrentOccultTypes |= type; EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type)); if (ths.mOwnerDescription.CreatedSim != null) { if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim)) { Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim); } if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim)) { Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim); } if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim)) { Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim); } } (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged(); ths.ClearOneShot(); ths.UpdateOccultUI(); if (!fromRestore) { EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim); } if (oldOccult != null) { newOccult.MergeOccultData(oldOccult); } if (ths.mOwnerDescription.CreatedSim != null) { Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture; if (standing != null) { standing.SetDefaultIdleAnim(); } } return(true); }
// From OccultManager protected static bool AddOccultType(OccultManager ths, OccultTypes type, bool addOutfit, bool isReward, bool fromRestore, OccultBaseClass overrideOccultToAdd) { OccultBaseClass newOccult = null; OccultBaseClass oldOccult = ths.VerifyOccultList(type); if (overrideOccultToAdd != null) { newOccult = overrideOccultToAdd; } else { switch (type) { case OccultTypes.Mummy: newOccult = new OccultMummy(); break; case OccultTypes.Frankenstein: newOccult = new OccultFrankenstein(); break; case OccultTypes.Vampire: newOccult = new OccultVampire(); break; case OccultTypes.ImaginaryFriend: OccultImaginaryFriend oldImFr = oldOccult as OccultImaginaryFriend; if (oldImFr == null) { newOccult = new OccultImaginaryFriend(); } else { newOccult = new OccultImaginaryFriend(oldImFr); } break; case OccultTypes.Unicorn: newOccult = new OccultUnicorn(); break; case OccultTypes.Fairy: newOccult = new OccultFairy(); break; case OccultTypes.Witch: newOccult = new OccultWitch(); break; case OccultTypes.Genie: newOccult = new OccultGenie(); break; case OccultTypes.Werewolf: newOccult = new OccultWerewolf(); break; case OccultTypes.PlantSim: newOccult = new OccultPlantSim(); break; case OccultTypes.Mermaid: newOccult = new OccultMermaid(); break; case OccultTypes.TimeTraveler: newOccult = new OccultTimeTraveler(); break; case OccultTypes.Robot: newOccult = new OccultRobot(); break; } } if (newOccult == null) { return false; } OccultTypes originalTypes = ths.mCurrentOccultTypes; Role assignedRole = ths.mOwnerDescription.AssignedRole; float alienDNAPercentage = ths.mOwnerDescription.AlienDNAPercentage; try { ths.mCurrentOccultTypes = OccultTypes.None; ths.mOwnerDescription.AssignedRole = null; ths.mOwnerDescription.mAlienDNAPercentage = 0f; if (!newOccult.CanAdd(ths.mOwnerDescription, fromRestore)) { return false; } } finally { ths.mCurrentOccultTypes = originalTypes; ths.mOwnerDescription.AssignedRole = assignedRole; ths.mOwnerDescription.mAlienDNAPercentage = alienDNAPercentage; } if ((ths.mOwnerDescription.SupernaturalData == null) || ((type == OccultTypes.Fairy) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Fairy)) || ((type == OccultTypes.Robot) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.Robot)) || ((type == OccultTypes.PlantSim) && (ths.mOwnerDescription.SupernaturalData.OccultType != OccultTypes.PlantSim))) { ths.mOwnerDescription.AddSupernaturalData(type); } ths.mIsLifetimeReward = isReward; if (type == OccultTypes.Genie) { // Corrections for improper handling of the special outfits by OccultGenie if (ths.mOwnerDescription.mSpecialOutfitIndices == null) { ths.mOwnerDescription.mSpecialOutfitIndices = new Dictionary<uint, int>(); } addOutfit = false; } if (type == OccultTypes.Unicorn) { OccultUnicornEx.OnAddition(newOccult as OccultUnicorn, ths.mOwnerDescription, addOutfit); } ApplyTrait(ths.mOwnerDescription, type); MidlifeCrisisManager midlifeCrisisManager = ths.mOwnerDescription.MidlifeCrisisManager; try { // Inactive mummies don't agree with mid-life crisis managers ths.mOwnerDescription.MidlifeCrisisManager = null; newOccult.OnAddition(ths.mOwnerDescription, addOutfit, ths.mIsLifetimeReward, fromRestore); } finally { ths.mOwnerDescription.MidlifeCrisisManager = midlifeCrisisManager; } ths.mOccultList.Add(newOccult); ths.mCurrentOccultTypes |= type; EventTracker.SendEvent(new BeAnOccultEvent(EventTypeId.kBeAnOccult, ths.mOwnerDescription.CreatedSim, (uint)type)); if (ths.mOwnerDescription.CreatedSim != null) { if (!Cane.IsAllowedToUseCane(ths.mOwnerDescription.CreatedSim)) { Cane.StopUsingAnyActiveCanes(ths.mOwnerDescription.CreatedSim); } if (!Backpack.IsAllowedToUseBackpack(ths.mOwnerDescription.CreatedSim)) { Backpack.StopUsingAnyActiveBackpacks(ths.mOwnerDescription.CreatedSim); } if (!Jetpack.IsAllowedToUseJetpack(ths.mOwnerDescription.CreatedSim)) { Jetpack.StopUsingAnyActiveJetpacks(ths.mOwnerDescription.CreatedSim); } } (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged(); ths.ClearOneShot(); ths.UpdateOccultUI(); if (!fromRestore) { EventTracker.SendEvent(EventTypeId.kBecameOccult, ths.mOwnerDescription.CreatedSim); } if (oldOccult != null) { newOccult.MergeOccultData(oldOccult); } if (ths.mOwnerDescription.CreatedSim != null) { Sim.StandingPosture standing = ths.mOwnerDescription.CreatedSim.Standing as Sim.StandingPosture; if (standing != null) { standing.SetDefaultIdleAnim(); } } return true; }
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); }