コード例 #1
0
ファイル: SimEx.cs プロジェクト: pepoluan/NRaas
        public static bool GetSimToSimHome(SimDescription simDesc, Sim requester, Callback success)
        {
            Sim createdSim = simDesc.CreatedSim;

            if (createdSim == null)
            {
                createdSim = Instantiation.Perform(simDesc, null);
            }
            if (createdSim != null && createdSim.InteractionQueue != null)
            {
                createdSim.InteractionQueue.CancelAllInteractions();

                bool flag = false;
                if (createdSim.Household == requester.Household)
                {
                    GoToLot entry = GoToLot.Singleton.CreateInstanceWithCallbacks(requester.LotHome, createdSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true, null, success, null) as GoToLot;
                    flag = createdSim.InteractionQueue.Add(entry);
                }
                else
                {
                    createdSim.SocialComponent.SetInvitedOver(requester.LotHome);
                    if (!requester.LotHome.IsBaseCampLotType)
                    {
                        Sims3.Gameplay.Core.VisitLot lot2 = Sims3.Gameplay.Core.VisitLot.Singleton.CreateInstanceWithCallbacks(requester.LotHome, createdSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true, null, success, null) as Sims3.Gameplay.Core.VisitLot;
                        flag = createdSim.InteractionQueue.Add(lot2);
                    }
                    else
                    {
                        GoToLot lot3 = GoToLot.Singleton.CreateInstanceWithCallbacks(requester.LotHome, createdSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true, null, success, null) as GoToLot;
                        flag = createdSim.InteractionQueue.Add(lot3);
                    }
                }
                if (flag)
                {
                    GroupingSituation situationOfType = createdSim.GetSituationOfType <GroupingSituation>();
                    if (situationOfType != null)
                    {
                        Sim leader = situationOfType.Leader;
                        if ((leader == null) || leader.IsNPC)
                        {
                            situationOfType.LeaveGroup(createdSim);
                        }
                    }
                    EventTracker.SendEvent(EventTypeId.kInvitedSimOver, requester, createdSim);

                    return(true);
                }
            }
            else
            {
                AcceptCancelDialog.Show(Common.LocalizeEAString("Gameplay/Objects/Electronics/Phone/Call/InviteOver:TestFailed"));
                //AcceptCancelDialog.Show(Woohooer.Localize("InviteOverForWoohooFail:Prompt"));
            }
            return(false);
        }
コード例 #2
0
        public static Sim CreateAnNPCPerformer(ShowStage ths)
        {
            Sim createdSim = null;
            Lot lotCurrent = null;

            OccupationNames[]           randomList           = new OccupationNames[] { OccupationNames.SingerCareer, OccupationNames.MagicianCareer, OccupationNames.PerformanceArtistCareer };
            AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(RandomUtil.GetRandomObjectFromList(randomList), false, true);
            bool flag = RandomUtil.CoinFlip();

            // Custom
            List <SimDescription> list = Household.AllTownieSimDescriptions(ValidPerformer);

            if (list.Count != 0)
            {
                SimDescription randomObjectFromList = RandomUtil.GetRandomObjectFromList(list);
                if (randomObjectFromList.CreatedSim == null)
                {
                    lotCurrent = ths.LotCurrent;
                    createdSim = randomObjectFromList.Instantiate(lotCurrent);
                }
                else
                {
                    createdSim = randomObjectFromList.CreatedSim;
                }
            }
            else
            {
                Sim servicePerformer = CreateServicePerformer(ths);
                if (servicePerformer != null)
                {
                    createdSim = servicePerformer;
                }
            }

            if (createdSim == null)
            {
                return(null);
            }

            GoToLot interaction = GoToLot.Singleton.CreateInstanceWithCallbacks(ths.LotCurrent, createdSim, new InteractionPriority(InteractionPriorityLevel.CriticalNPCBehavior), false, true, null, new Callback(GoToLotSuccess), new Callback(GoToLotFailure)) as GoToLot;

            if (createdSim.InteractionQueue != null)
            {
                Common.DebugNotify("Pushing GoToLot on " + createdSim.FullName);
                createdSim.InteractionQueue.Add(interaction);
            }

            if (createdSim.CareerManager == null)
            {
                return(null);
            }

            if (createdSim.CareerManager.OccupationAsPerformanceCareer == null)
            {
                try
                {
                    if (createdSim.WasCreatedByAService)
                    {
                        switch (createdSim.Service.ServiceType)
                        {
                        case ServiceType.Magician:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.MagicianCareer, false, true);
                            break;

                        case ServiceType.Singer:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.SingerCareer, false, true);
                            break;

                        case ServiceType.PerformanceArtist:
                            occupationParameters = new AcquireOccupationParameters(OccupationNames.PerformanceArtistCareer, false, true);
                            break;

                        default:
                            break;
                        }
                    }

                    createdSim.AcquireOccupation(occupationParameters);

                    int num = flag ? RandomUtil.GetInt(0x0, 0x5) : RandomUtil.GetInt(0x5, createdSim.Occupation.HighestLevel);
                    for (int i = 0x1; i < num; i++)
                    {
                        createdSim.CareerManager.Occupation.PromoteSim();
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(createdSim, e);
                    return(null);
                }
            }
            return(createdSim);
        }