Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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);
        }