Esempio n. 1
0
        public override bool InRabbitHole()
        {
            string msg = "HaveAlienBabyHospital.InRabbitHole" + Common.NewLine;

            bool result;

            try
            {
                while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.CanceledByScript) && !BabyShouldBeBorn)
                {
                }

                msg += "A";

                if (!BabyShouldBeBorn && Actor.HasExitReason(ExitReason.CanceledByScript))
                {
                    result = false;
                }
                else
                {
                    msg += "B";

                    AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);

                    if (Actor.IsSelectable)
                    {
                        Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                    }

                    mNewborns = pregnancy.CreateNewborns(Pregnancy.HaveBabyHospital.kBonusMoodPointsForHospitalBirth, Actor.IsSelectable, false);

                    for (int i = 0; i < mNewborns.Count; i++)
                    {
                        Relationship.Get(Actor, mNewborns[i], true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    }

                    msg += "C";

                    Actor.SimDescription.SetPregnancy(0f);
                    List <Sim> followers = SimFollowers;
                    pregnancy.PregnancyComplete(mNewborns, followers);

                    msg += "D";

                    SpeedTrap.Sleep(0u);
                    List <Sim> list2 = new List <Sim>();
                    list2.Add(Actor);

                    if (followers != null)
                    {
                        foreach (Sim sim in followers)
                        {
                            if (sim.SimDescription.TeenOrAbove && sim.GetObjectInRightHand() == null)
                            {
                                list2.Add(sim);
                            }
                        }
                    }

                    msg += "E";

                    if (mNewborns.Count <= list2.Count)
                    {
                        for (int i = 0; i < mNewborns.Count; i++)
                        {
                            Sim     target  = list2[i];
                            Posture posture = target.Posture;
                            target.Posture = null;
                            Sim actor = mNewborns[i];
                            InteractionInstance entry = Pregnancy.PregnancyPlaceholderInteraction.Singleton.CreateInstance(target, actor,
                                                                                                                           new InteractionPriority(InteractionPriorityLevel.Zero), false, false);
                            actor.InteractionQueue.Add(entry);

                            while (actor.CurrentInteraction != entry && actor.InteractionQueue.HasInteraction(entry))
                            {
                                SpeedTrap.Sleep();
                            }

                            try
                            {
                                ChildUtils.CarryChild(target, actor, false);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(actor, target, e);
                            }

                            target.Posture = posture;
                            AddFollower(mNewborns[i]);
                        }
                    }
                    else
                    {
                        BabyBasket basket = GlobalFunctions.CreateObject("BabyBasket", Vector3.OutOfWorld, 0, Vector3.UnitZ) as BabyBasket;
                        basket.AddBabiesToBasket(mNewborns);
                        CarrySystem.EnterWhileHolding(Actor, basket);
                        CarrySystem.VerifyAnimationParent(basket, Actor);
                    }

                    msg += "F";

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                    }

                    result = true;
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, msg, e);
                result = false;
            }

            Common.DebugNotify(msg);

            return(result);
        }
Esempio n. 2
0
        public override bool Run()
        {
            bool result;

            try
            {
                if (Actor.LotCurrent != Target)
                {
                    Vector3 point = World.LotGetPtInside(Target.LotId);

                    if (point == Vector3.Invalid)
                    {
                        return(false);
                    }

                    if (!Actor.RouteToPointRadius(point, 3f) &&
                        (!GlobalFunctions.PlaceAtGoodLocation(Actor, new World.FindGoodLocationParams(point), false) ||
                         !SimEx.IsPointInLotSafelyRoutable(Actor, Target, Actor.Position)))
                    {
                        Actor.AttemptToPutInSafeLocation(true);
                    }
                }

                if (Actor.Posture is SwimmingInPool && !(Actor.Posture as SwimmingInPool).ContainerPool.RouteToEdge(Actor))
                {
                    if (Actor.BridgeOrigin != null)
                    {
                        Actor.BridgeOrigin.MakeRequest();
                    }

                    Actor.PopPosture();
                    IGameObject reservedTile = null;
                    Actor.FindRoutablePointInsideNearFrontDoor(Actor.Household.LotHome, out reservedTile);
                    Vector3 position            = reservedTile.Position;
                    Terrain.TeleportMeHere here = Terrain.TeleportMeHere.Singleton.CreateInstance(Terrain.Singleton, Actor,
                                                                                                  new InteractionPriority(InteractionPriorityLevel.Pregnancy), false, false) as Terrain.TeleportMeHere;
                    here.SetAndReserveDestination(reservedTile);

                    try
                    {
                        here.RunInteractionWithoutCleanup();
                    }
                    catch
                    {
                        Actor.SetPosition(position);
                    }
                    finally
                    {
                        here.Cleanup();
                    }

                    Actor.LoopIdle();
                }

                AlienPregnancyProxy pregnancy = new AlienPregnancyProxy(Actor.SimDescription.Pregnancy);
                Sims3.Gameplay.Gameflow.Singleton.DisableSave(this, "Gameplay/ActorSystems/Pregnancy:DisableSave");
                mNewborns            = pregnancy.CreateNewborns(0f, Actor.IsSelectable, true);
                mCurrentStateMachine = StateMachineClient.Acquire(Actor, "Pregnancy");
                mCurrentStateMachine.SetActor("x", Actor);

                for (int i = 0; i < mNewborns.Count; i++)
                {
                    Sim baby = mNewborns[i];
                    Relationship.Get(Actor, baby, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);

                    if (baby.BridgeOrigin != null)
                    {
                        baby.BridgeOrigin.MakeRequest();
                        baby.BridgeOrigin = null;
                    }

                    HaveAlienBabyHomeInternal instance = HaveAlienBabyHomeInternal.Singleton.CreateInstance(baby, Actor, GetPriority(),
                                                                                                            Autonomous, CancellableByPlayer) as HaveAlienBabyHomeInternal;
                    instance.TotalCount           = mNewborns.Count;
                    instance.BabyIndex            = i + 1;
                    instance.mCurrentStateMachine = mCurrentStateMachine;
                    Actor.InteractionQueue.PushAsContinuation(instance, true);
                }

                if (Actor.IsSelectable)
                {
                    OccultImaginaryFriend.DeliverDollToHousehold(mNewborns);
                }

                result = true;
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);

                result = false;
            }

            return(result);
        }