Ejemplo n.º 1
0
        private new bool DoReadBook()
        {
            Book target = ChooseBook(Actor, Inventories.QuickFind <Book>(Actor.Inventory));

            if (target != null)
            {
                InteractionInstance instance = ReadBookChooserEx.Singleton.CreateInstance(target, Actor, mPriority, Autonomous, CancellableByPlayer);
                BeginCommodityUpdates();

                bool succeeded = false;
                try
                {
                    succeeded = instance.RunInteraction();
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                return(succeeded);
            }

            Target.AddExitReason(ExitReason.FailedToStart);
            return(false);
        }
Ejemplo n.º 2
0
            public bool __DoReadBook()
            {
                BookGeneral bookGeneral = Actor.Inventory.Find <BookGeneral>();

                if (bookGeneral == null)
                {
                    bookGeneral = Book.CreateBookAndPlaceInInventory(Actor);
                }
                if (bookGeneral != null)
                {
                    InteractionInstance interactionInstance = ReadBookChooser.Singleton.CreateInstance(bookGeneral, Actor, mPriority, base.Autonomous, base.CancellableByPlayer);
                    BeginCommodityUpdates();
                    bool flag = interactionInstance.RunInteraction();
                    EndCommodityUpdates(flag);
                    return(flag);
                }
                Target.AddExitReason(ExitReason.FailedToStart);
                return(false);
            }
Ejemplo n.º 3
0
            public bool __DoReadNewspaper()
            {
                INewspaper newspaper = Actor.Inventory.Find <INewspaper>();

                if (newspaper == null)
                {
                    newspaper = (GlobalFunctions.CreateObjectOutOfWorld("Newspaper") as INewspaper);
                    Actor.Inventory.TryToAdd(newspaper);
                }
                if (newspaper != null)
                {
                    newspaper.SetFromReadSomethingInInventory();
                    InteractionInstance readInteraction = newspaper.GetReadInteraction(Actor);
                    BeginCommodityUpdates();
                    bool flag = readInteraction.RunInteraction();
                    EndCommodityUpdates(flag);
                    return(flag);
                }
                Target.AddExitReason(ExitReason.FailedToStart);
                return(false);
            }
Ejemplo n.º 4
0
 public override bool Run()
 {
     if (!Actor.IsInActiveHousehold && base.Autonomous)
     {
         //Vector3 maotia = Vector3.Invalid;
         Actor.LoopIdle();
         try
         {
             Simulator.Sleep(500);
         }
         catch
         { }
         List <Sim> sims = new List <Sim>();
         foreach (Sim targetsim in Actor.LotCurrent.GetAllActors())
         //foreach (Sim targetsim in LotManager.Actors)
         {
             if (targetsim != Actor)
             {
                 sims.Add(targetsim);
             }
         }
         if (sims.Count == 0)
         {
             if (Household.ActiveHousehold != null)
             {
                 foreach (Sim targetsim in Household.ActiveHousehold.Sims)
                 {
                     if (targetsim != Actor)
                     {
                         sims.Add(targetsim);
                     }
                 }
             }
             if (sims.Count == 0)
             {
                 return(false);
             }
         }
         bool flag = false;
         Sim  randomObjectFromList = RandomUtil.GetRandomObjectFromList(sims);
         InteractionInstance interactionInstance = Terrain.GoHere.GetSingleton(Actor, randomObjectFromList.Position).CreateInstance(Terrain.Singleton, Actor, new InteractionPriority((InteractionPriorityLevel)10), false, false);
         if (interactionInstance != null)
         {
             (interactionInstance as Terrain.GoHere).SetDestination(randomObjectFromList.Position, false);
             flag = interactionInstance.RunInteraction();
         }
         InteractionInstance helloChatESRBi3;
         helloChatESRBi3 = new SocialInteractionA.Definition("Chat", new string[0], null, false).CreateInstance(randomObjectFromList, Actor, base.GetPriority(), base.Autonomous, base.CancellableByPlayer);
         if (randomObjectFromList != null && randomObjectFromList.HasBeenDestroyed)
         {
             randomObjectFromList = RandomUtil.GetRandomObjectFromList(sims);
             helloChatESRBi3      = new SocialInteractionA.Definition("Chat", new string[0], null, false).CreateInstance(randomObjectFromList, Actor, base.GetPriority(), base.Autonomous, base.CancellableByPlayer);
         }
         if (randomObjectFromList != null && randomObjectFromList.HasBeenDestroyed)
         {
             return(false);
         }
         Actor.InteractionQueue.Add(helloChatESRBi3);
         return(flag);
     }
     if (Actor.Posture.Satisfies(CommodityKind.Relaxing, null) || (!Actor.Motives.HasMotive(CommodityKind.BeSuspicious) && RandomUtil.RandomChance(Sim.ChanceOfReadingBookRatherThanNewsaperWhenReadingOutdoors)))
     {
         return(__DoReadBook());
     }
     return(__DoReadNewspaper());
 }
Ejemplo n.º 5
0
        public override bool Run()
        {
            try
            {
                Definition interactionDefinition = InteractionDefinition as Definition;

                mIsJoin = interactionDefinition.IsJoin;
                if (!Actor.RoutingComponent.RouteToObjectRadialRange(Target, WeatherStone.kSummonWeatherRouteDistance[0], WeatherStone.kSummonWeatherRouteDistance[1], AlwaysRoute ? new Route.RouteOption[] { Route.RouteOption.DoNotEmitDegenerateRoutesForRadialRangeGoals } : null))
                {
                    return(false);
                }

                if ((interactionDefinition.mType == WeatherStone.SummonWeatherType.HuntersStorm) && !Actor.BuffManager.HasElement(BuffNames.Werewolf))
                {
                    InteractionInstance instance = OccultWerewolf.TransformationToWerewolf.Singleton.CreateInstance(Actor, Actor, GetPriority(), Autonomous, CancellableByPlayer);
                    if (instance != null)
                    {
                        if (instance.RunInteraction())
                        {
                            Actor.ClearExitReasons();
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                if (!Target.TryStartSummoningWeather(Actor, interactionDefinition.mType, mIsJoin))
                {
                    if (mIsJoin || !Target.TryStartSummoningWeather(Actor, interactionDefinition.mType, true))
                    {
                        Sim createdSim = null;
                        if (Target.mSummoningSimDescriptionId != 0L)
                        {
                            createdSim = SimDescription.GetCreatedSim(Target.mSummoningSimDescriptionId);
                        }
                        Actor.PlayRouteFailure(createdSim);
                        return(false);
                    }
                    mIsJoin = true;
                }

                StandardEntry();
                EnterStateMachine("SummonWeather", "Enter", "x");
                if (Target.mSummonWeatherType == WeatherStone.SummonWeatherType.BewitchingRain)
                {
                    StartLightningEffects();
                }

                AnimateSim(interactionDefinition.mType.ToString());
                BeginCommodityUpdates();
                if (mIsJoin)
                {
                    mSummonWeatherTimeRemaining = WeatherStone.kSummonWeatherDetermineOutcomeTime[1] + 10f;
                }
                else
                {
                    mSummonWeatherTimeRemaining = RandomUtil.GetFloat(WeatherStone.kSummonWeatherDetermineOutcomeTime[0], WeatherStone.kSummonWeatherDetermineOutcomeTime[1]);
                }

                bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), SummonLoop, mCurrentStateMachine);
                EndCommodityUpdates(succeeded);
                StandardExit();
                switch (Target.CurrentWeatherStoneState)
                {
                case WeatherStone.WeatherStoneState.AfterSuccessfulSummon:
                    AnimateSim("Success");
                    BuffNames buffNameFromSummonWeatherType = WeatherStone.GetBuffNameFromSummonWeatherType(Target.mSummonWeatherType);
                    if (buffNameFromSummonWeatherType != BuffNames.Undefined)
                    {
                        Actor.BuffManager.AddElement(buffNameFromSummonWeatherType, Origin.FromWeatherStone);
                    }
                    if (!mIsJoin)
                    {
                        Target.StopElectrifiedEffect();
                    }
                    break;

                case WeatherStone.WeatherStoneState.AfterFailureSummon:
                    if (!Target.mUseExtremeFailure)
                    {
                        AnimateSim("FailureNormal");
                    }
                    else
                    {
                        BuffSinged.SingeViaInteraction(this, Origin.FromLightning);
                        AnimateSim("FailureExtreme");
                    }

                    if (!HasOtherSimsSummoning(Actor))
                    {
                        Target.AnimateChangeWeatherStoneState(false, WeatherStone.WeatherStoneState.Resting);
                    }
                    break;

                default:
                    if (!mIsJoin)
                    {
                        Target.OnSummoningStoppedEarly();
                    }
                    AnimateSim("FailureNormal");
                    break;
                }

                AnimateSim("Exit");
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public ActionResult NM_PerformAction()
        {
            if (dontCall)
            {
                return(ActionResult.Continue);
            }

            Vehicle vehicle = null;

            try
            {
                var simRoutingComponentx = mRoutingSim.SimRoutingComponent;

                mRoutingSim.PopHoverboardPostureIfNecessary();

                simRoutingComponentx.DisallowBeingPushed = true;
                simRoutingComponentx.TriggerOnCarSequenceStartedEvent();

                if (mRoutingSim.HasExitReason((ExitReason)mOriginalRoute.ExitReasonsInterrupt))
                {
                    AddFailureExplanation(FailureExplanation.CancelledByScript);
                    return(ActionResult.Terminate);
                }

                Lot lot = (mOriginalRoute == null) ? mRoutingSim.LotCurrent : LotManager.GetLotAtPoint(mOriginalRoute.GetOriginalStartPoint());
                vehicle = Sim_GetVehicle(mRoutingSim, lot, GameUtils.IsInstalled(ProductVersion.EP8));
                if (vehicle == null || vehicle.HasBeenDestroyed)
                {
                    AddFailureExplanation(FailureExplanation.VehicleSequenceFailure);
                    return(ActionResult.Terminate);
                }


                mOriginalRoute.SetOption(Route.RouteOption.EnableUFOPlanning, vehicle is CarUFO);
                Household household = mRoutingSim.Household;
                if (household != null)
                {
                    CarOwnable carOwnable = vehicle as CarOwnable;
                    if (carOwnable != null && carOwnable.GeneratedOwnableForNpc)
                    {
                        Lot lotHome = household.LotHome;
                        if (lotHome != null)
                        {
                            int cost = carOwnable.Cost;
                            if (household.FamilyFunds >= cost)
                            {
                                household.ModifyFamilyFunds(-cost);
                            }
                            else
                            {
                                household.UnpaidBills += cost;
                            }
                            carOwnable.GeneratedOwnableForNpc = (lotHome == null);
                            carOwnable.DestroyOnRelease       = (lotHome == null);
                            carOwnable.LotHome = lotHome;
                        }
                    }
                }


                Vector3 pt;
                mOriginalRoute.GetSegmentStartPoint(0u, out pt);
                Vector3 dir;
                mOriginalRoute.GetSegmentStartDirection(0u, out dir);

                ItemComponent itemComp = vehicle.ItemComp;
                if (itemComp != null && itemComp.InventoryParent != null)
                {
                    itemComp.InventoryParent.RemoveByForce(vehicle);
                }

                vehicle.PlaceAt(pt, dir, mRoutingSim);

                if (vehicle is Bicycle && mRoutingSim.Posture.Satisfies(CommodityKind.CarryingObject, null))
                {
                    InteractionInstance standingTransition = mRoutingSim.Posture.GetStandingTransition();
                    if (standingTransition != null)
                    {
                        standingTransition.RunInteraction();
                    }
                }

                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    mRoutingSim.PopBackpackPostureIfNecessary();
                    if (mRoutingSim.SimDescription.IsPlantSim)
                    {
                        (mRoutingSim.RoutingComponent as SimRoutingComponent).StopPlantSimRoutingVFX();
                    }
                }

                mRoutingSim.PopJetpackPostureIfNecessary();
                mRoutingSim.FadeOut(true, 0.5f, null);

                if (vehicle.Driver == null)
                {
                    vehicle.PutInDriver(mRoutingSim);
                }
                else
                {
                    vehicle.PutInPassenger(mRoutingSim);
                }

                mRoutingSim.FadeIn(true, 0.5f);

                var objectInRightHand = mRoutingSim.GetObjectInRightHand();
                if (objectInRightHand != null && !(objectInRightHand is Sim))
                {
                    objectInRightHand.SetHiddenFlags(HiddenFlags.Model);
                }

                simRoutingComponentx.ClearPush();

                var followSubPathRouteAction = new VehicleFollowSubPathRouteAction(vehicle, mOriginalRoute);
                followSubPathRouteAction.AssociatedSim = mRoutingSim;

                mRoutingSim.RoutingComponent.InsertRouteActionAfter(this, followSubPathRouteAction);

                return(ActionResult.Continue);
            }
            catch
            {
                if (vehicle != null && vehicle.DestroyOnRelease)
                {
                    vehicle.Destroy();
                }
                throw;
            }
            finally
            {
                mRoutingSim.SimRoutingComponent.DisallowBeingPushed = false;
            }
        }