Пример #1
0
        private bool CreateAndPlaceJig()
        {
            mJig = (GlobalFunctions.CreateObjectOutOfWorld("vehicleUFO_jig", ProductVersion.EP8) as SocialJigTwoPerson);

            if (mJig == null)
            {
                return(false);
            }

            mJig.RegisterParticipants(Actor, SimToAbduct);

            if (TryPlaceJigOnLot())
            {
                return(true);
            }

            if (TryPlaceJigOnRoad())
            {
                return(true);
            }

            mJig.Destroy();
            mJig = null;

            return(false);
        }
Пример #2
0
        public override bool Run()
        {
            try
            {
                if (!Actor.Inventory.Contains(Target))
                {
                    if (!Actor.RouteToObjectRadiusAndCheckInUse(Target, 0.7f))
                    {
                        return(false);
                    }

                    StandardEntry();
                    BeginCommodityUpdates();
                    Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                    if (!Actor.Inventory.TryToAdd(Target))
                    {
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                }
                else
                {
                    StandardEntry();
                    BeginCommodityUpdates();
                }

                SocialJigTwoPerson person = GlobalFunctions.CreateObjectOutOfWorld(SocialJig.SocialJigMedatorNames.SocialJigTwoPerson.ToString()) as SocialJigTwoPerson;
                person.RegisterParticipants(Actor, null);
                Sim createdSim = null;
                try
                {
                    World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position);
                    fglParams.BooleanConstraints |= FindGoodLocationBooleans.Routable;
                    if (GlobalFunctions.PlaceAtGoodLocation(person, fglParams, true))
                    {
                        Route r = Actor.CreateRoute();
                        r.PlanToSlot(person, person.GetSlotForActor(Actor, true));
                        r.DoRouteFail = true;
                        if (Actor.DoRoute(r))
                        {
                            bool paramValue = false;
                            mSummonGenieBroadcast = new ReactionBroadcaster(Actor, kSummonGenieBroadcastParams, SummonGenieBroadcastCallback);
                            Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.Gameplay.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Gameplay);
                            if (Target.mGenieDescription == null)
                            {
                                Target.mGenieDescription = OccultGenie.CreateGenie(Actor, Target);
                                createdSim = Target.mGenieDescription.CreatedSim;
                                EventTracker.SendEvent(EventTypeId.kCleanLamp, Actor, Target);
                                paramValue = true;
                            }
                            else
                            {
                                createdSim = Target.mGenieDescription.Instantiate(Vector3.OutOfWorld, false);
                                OccultGenie occultType          = null;
                                DateAndTime previousDateAndTime = SimClock.CurrentTime();
                                do
                                {
                                    SpeedTrap.Sleep(0xa);
                                    occultType = createdSim.OccultManager.GetOccultType(OccultTypes.None | OccultTypes.Genie) as OccultGenie;
                                }while ((occultType == null) && (SimClock.ElapsedTime(TimeUnit.Minutes, previousDateAndTime) < 120f));

                                if (occultType != null)
                                {
                                    occultType.SetGenieLampRelations(Actor, createdSim, Target);
                                }
                                else
                                {
                                    createdSim.Destroy();
                                    createdSim = null;
                                }
                            }

                            if (createdSim != null)
                            {
                                createdSim.FadeOut(false, false, 0f);
                                createdSim.GreetSimOnLot(Actor.LotCurrent);
                                createdSim.AddToWorld();
                                Slot slotForActor = person.GetSlotForActor(createdSim, false);
                                createdSim.SetPosition(person.GetSlotPosition(slotForActor));
                                createdSim.SetForward(person.GetForwardOfSlot(slotForActor));
                                IGameObject actor = GlobalFunctions.CreateObject("GenieLamp", ProductVersion.EP6, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null);
                                if (!actor.IsActorUsingMe(Actor))
                                {
                                    actor.AddToUseList(Actor);
                                }
                                EnterStateMachine("GenieLampSummon", "Enter", "x");
                                SetActor("lamp", actor);
                                SetParameter("isFirstTime", paramValue);
                                AnimateSim("Exit");
                                actor.Destroy();
                                createdSim.FadeIn();
                                VisualEffect effect = VisualEffect.Create("ep6GenieAppearSmoke_main");
                                effect.SetPosAndOrient(createdSim.Position, Vector3.UnitX, Vector3.UnitZ);
                                effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);
                                OpportunityManager opportunityManager = Actor.OpportunityManager;
                                if ((opportunityManager != null) && opportunityManager.HasOpportunity(OpportunityNames.EP6_ReleaseGenie_SummonGenie))
                                {
                                    OccultGenie genie2 = createdSim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                                    if (genie2 == null)
                                    {
                                        createdSim.Destroy();
                                        createdSim = null;
                                    }
                                    else
                                    {
                                        OccultGenieEx.OnFreedFromLamp(genie2, Actor, createdSim, true);
                                        if (opportunityManager.GetLastOpportunity(OpportunityCategory.Special) == OpportunityNames.EP6_ReleaseGenie_SummonGenie)
                                        {
                                            opportunityManager.ClearLastOpportunity(OpportunityCategory.Special);
                                        }

                                        EventTracker.SendEvent(EventTypeId.kGrantedWishToFreeGenie, Actor, Target);
                                        if (Target.InInventory)
                                        {
                                            Actor.Inventory.RemoveByForce(Target);
                                            if (Target.IsOnHandTool)
                                            {
                                                Target.RemoveFromWorld();
                                            }
                                        }
                                        else
                                        {
                                            Target.RemoveFromWorld();
                                        }
                                        EnterStateMachine("FreeTheGenie", "Enter", "x");
                                        SetActor("x", createdSim);
                                        AnimateSim("Exit");
                                    }
                                }
                                else
                                {
                                    Target.mGenieSocializingEvent        = EventTracker.AddListener(EventTypeId.kSocialInteraction, OnSocialization);
                                    Target.CheckGenieReturnToLamp        = createdSim.AddAlarmRepeating(1f, TimeUnit.Minutes, Target.CheckGenieReturnToLampCallback, "Genie Check to return to lamp", AlarmType.AlwaysPersisted);
                                    Target.mTimeSinceLastSocialWithGenie = SimClock.CurrentTime();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    person.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit(createdSim == null, createdSim == null);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }