コード例 #1
0
        public static bool Run(Pregnancy.HaveBabyHome ths)
        {
            try
            {
                if (ths.Actor.LotCurrent != ths.Target)
                {
                    Vector3 point = World.LotGetPtInside(ths.Target.LotId);
                    if (point == Vector3.Invalid)
                    {
                        return(false);
                    }

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

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

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

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

                Pregnancy pregnancy = ths.Actor.SimDescription.Pregnancy;
                if (pregnancy != null)
                {
                    // Custom
                    EnsureForeignFather(pregnancy);
                }

                ths.GetNewBorns();

                ths.AcquirePregnancyStateMachine();

                ths.mCurrentStateMachine.SetActor("x", ths.Actor);
                for (int i = 0x0; i < ths.mNewborns.Count; i++)
                {
                    Sim sim = ths.mNewborns[i];
                    Relationship.Get(ths.Actor, sim, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    if (sim.BridgeOrigin != null)
                    {
                        sim.BridgeOrigin.MakeRequest();
                        sim.BridgeOrigin = null;
                    }

                    Pregnancy.InternalHaveBabyHome instance = Pregnancy.InternalHaveBabyHome.Singleton.CreateInstance(sim, ths.Actor, ths.GetPriority(), ths.Autonomous, ths.CancellableByPlayer) as Pregnancy.InternalHaveBabyHome;
                    instance.TotalCount           = ths.mNewborns.Count;
                    instance.BabyIndex            = i + 0x1;
                    instance.mCurrentStateMachine = ths.mCurrentStateMachine;
                    ths.Actor.InteractionQueue.PushAsContinuation(instance, true);
                }

                ths.TryDeliverImaginaryFriend();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
                return(false);
            }
        }
コード例 #2
0
ファイル: HaveAlienBabyHome.cs プロジェクト: Duglarogg/Sims3
        public override bool Run()
        {
            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) ||
                                                                 Actor.IsPointInLotSafelyRoutable(Target, Actor.Position)))
                    {
                        Actor.AttemptToPutInSafeLocation(true);
                    }
                }

                if (Actor.Posture is SwimmingInPool)
                {
                    SwimmingInPool posture = Actor.Posture as SwimmingInPool;

                    if (!posture.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();
                    }
                }

                Pregnancy pregnancy = Actor.SimDescription.Pregnancy;
                GetNewBorns();
                AcquirePregnancyStateMachine();
                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;
                    }

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

                TryDeliverImaginaryFriend();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Logger.WriteExceptionLog(e, this, "HaveAlienBabyHome.Run() Error");
                return(false);
            }
        }
コード例 #3
0
ファイル: HaveAlienBabyHome.cs プロジェクト: Duglarogg/Sims3
        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);
        }