public void SampleCodeForGitHubReadMeManuallyConstructingEventObject()
 {
     //create a new EventTracker
     IEventTracker eventTracker = new EventTracker();
     //create a new event to pass to the event tracker
     IUniversalAnalyticsEvent analyticsEvent = new UniversalAnalyticsEvent(
         //Required. The universal analytics tracking id for the property
         // that events will be logged to. If you don't want to pass this every time, set the UniversalAnalytics.TrackingId
         // app setting and use the UniversalAnalyticsEventFactory to get instances of this class.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid for details.
         "UA-52982625-3",
         //Required. Anonymous client id.
         //See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid for details.
         "developer",
         //Required. The event category for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ec for details.
         "test category",
         //Required. The event action for the event.
         //See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ea for details.
         "test action",
         //Optional. The event label for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#el for details.
         "test label",
         //Optional. The event value for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ev for details.
         "10");
     eventTracker.TrackEvent(analyticsEvent);
 }
Exemplo n.º 2
0
 public Participant(string name)
 {
     _name = name;
     _onRecievedMessageTracker = new EventTracker<ChatMessageEventArgs>();
     _onInterceptTracker = new EventTracker<ChatMessageEventArgs>();
     _onEventTracker = new EventTracker<EventArgs>();
 }
        public void ShouldNotFireChangedWhenNonVirtualPropertyChangedOnMadeObject()
        {
            var cat = Notifiable.MakeForClassGeneric<LolCat>(FireOptions.Always, new ProxyGenerator(), new DependencyMap());

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            (cat as INotifyPropertyChanged).PropertyChanged += tracker;

            cat.Color = "purple";

            Assert.IsTrue(tracker.WasNotCalled);
        }
        public void ShouldFireChangedWhenVirtualPropertySetOnMadeObject()
        {
            var cat = Notifiable.MakeForClassGeneric<LolCat>(FireOptions.Always, new ProxyGenerator(), new DependencyMap());

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            (cat as INotifyPropertyChanged).PropertyChanged += tracker;

            cat.Greeting = "buzz off";

            Assert.That(tracker.WasCalled);
        }
        public void ShouldFireChangedWhenPropertyChangedOnMadeObject()
        {
            var greeter = Notifiable.MakeForInterfaceGeneric<IGreeter>(new LolCat(), FireOptions.Always, new ProxyGenerator(), new DependencyMap());

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            (greeter as INotifyPropertyChanged).PropertyChanged += tracker;

            greeter.Greeting = "buzz off";

            Assert.IsTrue(tracker.WasCalled);
        }
        public void ShouldNotFireChangedWhenVirtualPropertySetAndChangedOnMadeObjectWithChangeOnlyOption()
        {
            var cat = Notifiable.MakeForClassGeneric<LolCat>(FireOptions.OnlyOnChange, new ProxyGenerator(), new DependencyMap());

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            cat.Greeting = "value";
            (cat as INotifyPropertyChanged).PropertyChanged += tracker;
            cat.Greeting = "value";

            Assert.IsTrue(tracker.WasNotCalled);
        }
        public void InjectedWhateverWithWhateverInsideIsProperlyDisposed()
        {
            var injectionist = new Injectionist();
            var eventTracker = new EventTracker();

            injectionist.Register(c =>
            {
                var fakeBus = new FakeBus(c.Get<Disposable1>(), c.Get<EventTracker>());

                fakeBus.FakeBusDisposed += () =>
                {
                    foreach (var disposable in c.GetTrackedInstancesOf<IDisposable>().Reverse())
                    {
                        disposable.Dispose();
                    }
                };

                foreach (var disposable in c.GetTrackedInstancesOf<IInitializable>())
                {
                    disposable.Initialize();
                }

                return fakeBus;
            });
            injectionist.Register(c => new Disposable1(c.Get<Disposable2>(), c.Get<EventTracker>()));
            injectionist.Register(c => new Disposable2(c.Get<EventTracker>()));
            injectionist.Register(c => eventTracker);

            using (var bus = injectionist.Get<FakeBus>())
            {
                Console.WriteLine("Using the bus....");

                Console.WriteLine("Disposing it");
            }

            Console.WriteLine(@"Here's what happened:
{0}", string.Join(Environment.NewLine, eventTracker.Events.Select(e => "- " + e)));

            Assert.That(eventTracker.Events, Is.EqualTo(new[]
            {
                "EventTracker initialized",
                "Disposable2 initialized",
                "Disposable1 initialized",
                "Disposable1 disposed",
                "Disposable2 disposed",
                "EventTracker disposed",
                "FakeBus disposed",
            }));
        }
        public void FireOptionsShouldDefaultToOnlyOnChange()
        {
            var cat = Notifiable.MakeForClassGeneric<LolCat>();

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            cat.Greeting = "value";
            (cat as INotifyPropertyChanged).PropertyChanged += tracker;
            cat.Greeting = "value";

            Assert.IsTrue(tracker.WasNotCalled);

            cat.Greeting = "hello";
            Assert.IsTrue(tracker.WasCalled);
        }
        public void UsingFireOptionAlways()
        {
            var container = new Container(config => config.Scan(scanConfig =>
            {
                scanConfig.With(new AutoNotifyAttrConvention());
                scanConfig.TheCallingAssembly();
                scanConfig.WithDefaultConventions();
            }));

            var bar = container.GetInstance<Bar>();

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            bar.Value = "test";
            (bar as INotifyPropertyChanged).PropertyChanged += tracker;
            bar.Value = "test";

            Assert.That(tracker.WasCalled);
        }
        public void UsingFireOptionOnlyOnChange()
        {
            var container = new Container(config => config.Scan(scanConfig =>
            {
                scanConfig.With(new AutoNotifyAttrConvention());
                scanConfig.TheCallingAssembly();
                scanConfig.WithDefaultConventions();
            }));

            var foo = container.GetInstance<Foo>();

            var tracker = new EventTracker<PropertyChangedEventHandler>();

            foo.Value = "test";
            (foo as INotifyPropertyChanged).PropertyChanged += tracker;
            foo.Value = "test";

            Assert.That(tracker.WasNotCalled);
        }
        public void Send100EventsAsQuicklyAsPossibleAndARateLimitStillWontOccur()
        {
            EventTracker eventTracker = new EventTracker();

            for (int i = 1; i <= 100; i++)
            {
                try
                {
                    IUniversalAnalyticsEvent analyticsEvent = eventFactory.MakeUniversalAnalyticsEvent(
                         "rate limit test user",
                         "rate limit test category",
                         "rate limit test action",
                         "rate limit test label",
                         i.ToString());
                    eventTracker.TrackEvent(analyticsEvent);
                }catch(Exception e)
                {
                    Assert.Fail("failed after " + i + " transmissions with the following exeption: "+ e.Message);
                }
            }
        }
        public void CreateForClass()
        {
            var container = new Container(config =>
            {
                config
                    .For<Bar>()
                    .Use(context => Notifiable.MakeForClassGeneric<Bar>(FireOptions.Always, new ProxyGenerator(), new DependencyMap()));
            });

            var bar = container.GetInstance<Bar>();

            // make sure it's wrapped
            Assert.That(bar, Is.InstanceOf<INotifyPropertyChanged>());

            // make sure it fires properly
            var tracker = new EventTracker<PropertyChangedEventHandler>();

            (bar as INotifyPropertyChanged).PropertyChanged += tracker;
            bar.Value = "yo";

            Assert.That(tracker.WasCalled);
        }
 public void SampleCodeForGitHubReadMeUsingFactoryToGetEventObject()
 {
     //create a new EventTracker
     IEventTracker eventTracker = new EventTracker();
     //create a new event to pass to the event tracker
     IUniversalAnalyticsEvent analyticsEvent = eventFactory.MakeUniversalAnalyticsEvent(
         //Required. Anonymous client id.
         //See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid for details.
         "developer",
         //Required. The event category for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ec for details.
         "test category",
         //Required. The event action for the event.
         //See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ea for details.
         "test action",
         //Optional. The event label for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#el for details.
         "test label",
         //Optional. The event value for the event.
         // See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ev for details.
         "10");
     eventTracker.TrackEvent(analyticsEvent);
 }
Exemplo n.º 14
0
        public override bool InRabbitHole()
        {
            BeginCommodityUpdates();

            bool succeeded = false;

            try
            {
                Target.StartPlayerConcert();
                StartStages();
                succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                Target.EndPlayerConcert();
            }
            finally
            {
                EndCommodityUpdates(succeeded);
            }

            if (succeeded)
            {
                EventTracker.SendEvent(EventTypeId.kPerformedConcert, Actor);

                int level = 10;

                Music job = OmniCareer.Career <Music>(Actor.Occupation);
                if (job != null)
                {
                    job.ConcertsPerformed++;

                    OmniCareer omni = Actor.Occupation as OmniCareer;
                    if (omni != null)
                    {
                        if (omni.PaidForConcerts())
                        {
                            level = 0;
                        }
                    }
                    else
                    {
                        level = Music.LevelToGetPaidForConcerts;
                    }
                }

                SkillBasedCareer career = SkillBasedCareerBooter.GetSkillBasedCareer(Actor, SkillNames.Guitar);
                if (career != null)
                {
                    level = NRaas.Careers.Settings.mBuskerLevelToGetPaidForConcerts;
                }

                if (Actor.Occupation.CareerLevel >= level)
                {
                    int concertPayAmount = Target.ConcertPayAmount;

                    Actor.ModifyFunds(concertPayAmount);

                    Actor.ShowTNSIfSelectable(LocalizeString(Actor.SimDescription, "ConcertPay", new object[] { Actor, concertPayAmount }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId);
                }
                else
                {
                    Actor.Occupation.ShowOccupationTNS(OmniCareer.LocalizeString(Actor.SimDescription, "PerformTone:ConcertPerformed", "Gameplay/Careers/Music/PerformTone:ConcertPerformed", new object[] { Actor }));
                }
            }
            return(true);
        }
Exemplo n.º 15
0
        public override bool Run()
        {
            try
            {
                IMagicalDefinition definition = InteractionDefinition as IMagicalDefinition;

                bool succeeded = true;
                Actor.ClearExitReasons();
                if (mIsChallenger || (mChallengerSim == null))
                {
                    mIsChallenger  = true;
                    mChallengerSim = Actor;
                    mDefenderSim   = Target;
                    if (mDefenderSim == null)
                    {
                        return(false);
                    }

                    EventTracker.SendEvent(EventTypeId.kChallengeToSpellcasting, mChallengerSim, mDefenderSim);

                    mJig = GlobalFunctions.CreateObjectOutOfWorld("castSpellDuel_jig", ProductVersion.EP7) as SocialJigTwoPerson;
                    mJig.RegisterParticipants(mDefenderSim, mChallengerSim);
                    mJig.SetOpacity(0f, 0f);

                    Vector3 position      = mDefenderSim.Position;
                    Vector3 forwardVector = mDefenderSim.ForwardVector;
                    if (!GlobalFunctions.FindGoodLocationNearby(mJig, ref position, ref forwardVector))
                    {
                        return(false);
                    }

                    mJig.SetPosition(position);
                    mJig.SetForward(forwardVector);
                    mJig.AddToWorld();
                    if (!Actor.DoRoute(mJig.RouteToJigB(mChallengerSim)))
                    {
                        return(false);
                    }

                    mRouteComplete      = true;
                    mInteractionPersonB = SingletonPersonB.CreateInstance(mChallengerSim, mDefenderSim, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as MagicWand.SpellcastingDuel;
                    mInteractionPersonB.LinkedInteractionInstance = this;
                    mInteractionPersonB.mChallengerSim            = mChallengerSim;
                    mInteractionPersonB.Jig                 = mJig;
                    mInteractionPersonB.mDefenderSim        = mDefenderSim;
                    mInteractionPersonB.IsChallenger        = false;
                    mInteractionPersonB.CancellableByPlayer = false;
                    mDefenderSim.InteractionQueue.AddNext(mInteractionPersonB);
                    PresetDuelResults();
                }
                else
                {
                    if (!Actor.DoRoute(mJig.RouteToJigA(mDefenderSim)))
                    {
                        return(false);
                    }
                    mRouteComplete = true;
                }

                MagicControl controlX = MagicControl.GetBestControl(mChallengerSim, definition);
                if (controlX == null)
                {
                    return(false);
                }

                MagicControl controlY = MagicControl.GetBestControl(mDefenderSim, definition);
                if (controlY == null)
                {
                    return(false);
                }

                StandardEntry(true);
                BeginCommodityUpdates();
                if (mIsChallenger)
                {
                    while ((!mRouteComplete || !mInteractionPersonB.RouteComplete) && (mDefenderSim.InteractionQueue.HasInteraction(mInteractionPersonB) && !Actor.HasExitReason()))
                    {
                        SpeedTrap.Sleep(0x0);
                    }

                    if (mDefenderSim.HasExitReason() || mChallengerSim.HasExitReason())
                    {
                        mDefenderSim.AddExitReason(ExitReason.Canceled);
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }

                    AcquireStateMachine("spellcastingDuel");

                    SetActor("x", mChallengerSim);
                    SetActor("y", mDefenderSim);

                    mWandX = controlX.InitialPrep(mChallengerSim, definition, out mWandXCreated);
                    mWandY = controlY.InitialPrep(mDefenderSim, definition, out mWandYCreated);
                    if ((mWandX == null) || (mWandY == null))
                    {
                        return(false);
                    }

                    mWandX.PrepareForUse(mChallengerSim);
                    if (mWandX is MagicHands)
                    {
                        SetParameter("noWandX", true);
                    }
                    else
                    {
                        SetParameter("noWandX", false);
                    }

                    mWandY.PrepareForUse(mDefenderSim);
                    if (mWandY is MagicHands)
                    {
                        SetParameter("noWandY", true);
                    }
                    else
                    {
                        SetParameter("noWandY", false);
                    }

                    SetActor("wandX", mWandX);
                    SetActor("wandY", mWandY);

                    SetParameter("x:Age", Actor.SimDescription.Age);
                    SetParameter("y:Age", Actor.SimDescription.Age);

                    EnterState("x", "Enter");
                    EnterState("y", "Enter");

                    AddPersistentScriptEventHandler(0x65, CastingEffect);
                    AddPersistentScriptEventHandler(0x66, BlockingEffect);
                    AddPersistentScriptEventHandler(0x67, HitEffect);
                    AddPersistentScriptEventHandler(0x68, BlockingEffectTwo);
                    ReturnToIdle();

                    for (int i = 0x0; i < mTotalRounds; i++)
                    {
                        mCurrResult = mRoundResults[i];
                        mCastType   = (CastingType)RandomUtil.GetInt(0x4);

                        switch (mCurrResult)
                        {
                        case RoundResult.ChallengerHit:
                            AnimateJoinSims("XHit");
                            break;

                        case RoundResult.ChallengerDefend:
                            AnimateJoinSims("XDef");
                            break;

                        case RoundResult.DefenderHit:
                            AnimateJoinSims("YHit");
                            break;

                        case RoundResult.DefenderDefend:
                            AnimateJoinSims("YDef");
                            break;
                        }

                        ReturnToIdle();
                    }

                    switch (mDuelResult)
                    {
                    case DuelResult.ChallengerWin:
                        AnimateJoinSims("XWin");
                        mChallengerSim.BuffManager.AddElement(BuffNames.WonASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mDefenderSim.BuffManager.AddElement(BuffNames.LostASpellcastingDuel, Origin.FromSpellcastingDuel);
                        EventTracker.SendEvent(EventTypeId.kWonASpellcastingDuel, mChallengerSim);
                        break;

                    case DuelResult.DefenderWin:
                        AnimateJoinSims("YWin");
                        mDefenderSim.BuffManager.AddElement(BuffNames.WonASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mChallengerSim.BuffManager.AddElement(BuffNames.LostASpellcastingDuel, Origin.FromSpellcastingDuel);
                        EventTracker.SendEvent(EventTypeId.kWonASpellcastingDuel, mDefenderSim);
                        break;

                    default:
                        AnimateJoinSims("Tie");
                        mChallengerSim.BuffManager.AddElement(BuffNames.DrawnASpellcastingDuel, Origin.FromSpellcastingDuel);
                        mDefenderSim.BuffManager.AddElement(BuffNames.DrawnASpellcastingDuel, Origin.FromSpellcastingDuel);
                        break;
                    }
                    mDefenderSim.AddExitReason(ExitReason.Finished);
                }
                else
                {
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }

                EndCommodityUpdates(succeeded);
                StandardExit(true);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Exemplo n.º 16
0
        public static void Process(ViewPage page, PageRequest request)
        {
            EventTracker tracker = new EventTracker();

            tracker.InternalProcess(page, request);
        }
Exemplo n.º 17
0
        public bool DoWater()
        {
            // Not going to start skill gain until water is at least retrieved.
            // No extra points for that much routing.
            EWHerbLoreSkill skill = EWHerbLoreSkill.StartSkillGain(Actor);

            if (skill != null)
            {
                StandardEntry();
                BeginCommodityUpdates();
                //mCurrentStateMachine = Target.GetStateMachine(Actor, out Soil dummyIk);
                //if (mCurrentStateMachine == null)
                //{
                //	EndCommodityUpdates(succeeded: false);
                //	StandardExit();
                //}
                //mDummyIk = dummyIk;
                AcquireStateMachine("eatharvestablepet");
                mCurrentStateMachine.SetActor("x", Actor);
                mCurrentStateMachine.EnterState("x", "Enter");
                SetParameter("IsEatingOnGround", paramValue: true);
                AnimateSim("EatHarvestable");
                StartWateringSound();
                //AddOneShotScriptEventHandler(1001u, new SacsEventHandler(StartWateringSound));
                AddOneShotScriptEventHandler(201u, new SacsEventHandler(StopWateringSound));
                StartStagesForTendableInteraction(this);
                float duration = Target.GetWaterDuration(Actor);
                if (duration == 0f)
                {
                    duration = 1f;
                }
                float startingWaterLevel = Target.WaterLevel;
                float targetWaterLevel   = 100f;
                Target.AddSimWhoHelpedGrow(Actor);
                EventTracker.SendEvent(EventTypeId.kWateredPlant, Actor, Target);
                bool flag = DoLoop(ExitReason.Default, delegate(StateMachineClient unused, LoopData ld)
                {
                    float num2             = ld.mLifeTime / duration;
                    this.Target.WaterLevel = num2 * targetWaterLevel + (1f - num2) * startingWaterLevel;
                    if (this.Target.WaterLevel > targetWaterLevel)
                    {
                        this.Target.WaterLevel = targetWaterLevel;
                    }
                    if (ld.mLifeTime > duration)
                    {
                        this.Actor.AddExitReason(ExitReason.Finished);
                    }
                }, null);
                //PauseTendGardenInteractionStage(Actor.CurrentInteraction);
                if (flag && Target.WaterLevel < targetWaterLevel)
                {
                    Target.WaterLevel = targetWaterLevel;
                }

                AnimateSim("Exit");
                EventTracker.SendEvent(EventTypeId.kGardened, Actor);
                EndCommodityUpdates(succeeded: true);
                StandardExit();
                skill.StopSkillGain();
                //UpdateTendGardenTimeSpent(this, SetWaterTimeSpent);
                return(flag);
            }
            return(false);
        }
Exemplo n.º 18
0
        public void motive_motive_distress(Sim sim, CommodityKind commodity)
        {
            if (commodity == (CommodityKind)0x44440444)
            {
                return;
            }

            SimDescription simd        = sim.SimDescription;
            BuffManager    buffManager = sim.BuffManager;
            Motives        moves       = sim.Motives;

            switch (commodity)
            {
            case CommodityKind.Bladder:
            {
                bool flag = true;
                InteractionDefinition interactionDefinition;
                switch (simd.Species)
                {
                case CASAgeGenderFlags.Horse:
                    interactionDefinition = Sim.HorsePee.Singleton;
                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    interactionDefinition = (InteractionDefinition)Sim.DogPeeStart.Singleton;
                    break;

                case CASAgeGenderFlags.Cat:
                    interactionDefinition = (InteractionDefinition)Sim.CatPeeStart.Singleton;
                    break;

                default:
                    interactionDefinition = Sim.BladderFailure.Singleton;
                    break;
                }

                foreach (InteractionInstance interaction in sim.InteractionQueue.InteractionList)
                {
                    if (interaction is Sim.DogPee || interaction is Sim.CatPee || interaction.InteractionDefinition == interactionDefinition)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag)
                {
                    SwimmingInPool swimmingInPool = sim.Posture as SwimmingInPool;
                    if (swimmingInPool == null)
                    {
                        InteractionInstance interactionInstance = interactionDefinition.CreateInstance(sim, sim, new InteractionPriority(InteractionPriorityLevel.High), false, false);
                        Sim.DogPeeStart     dogPeeStart         = interactionInstance as Sim.DogPeeStart;
                        if (dogPeeStart != null)
                        {
                            dogPeeStart.DoNotRoute = true;
                        }
                        else
                        {
                            Sim.CatPeeStart catPeeStart = interactionInstance as Sim.CatPeeStart;
                            if (catPeeStart != null)
                            {
                                catPeeStart.DoNotRoute = true;
                            }
                        }
                        if (sim.InteractionQueue.AddNext(interactionInstance) && simd.IsRaccoon)
                        {
                            sim.AddExitReason(ExitReason.BuffFailureState);
                        }
                        else
                        {
                            BuffInstance buffOfSolveCommodity = buffManager.GetBuffOfSolveCommodity(commodity);
                            if (buffOfSolveCommodity != null && buffOfSolveCommodity.EffectValue <= 0)
                            {
                                ThoughtBalloonManager.BalloonData balloonData = new ThoughtBalloonManager.BalloonData(buffOfSolveCommodity.ThumbString);
                                if (balloonData.IsValid)
                                {
                                    balloonData.BalloonType = ThoughtBalloonTypes.kScreamBalloon;
                                    balloonData.mCoolDown   = ThoughtBalloonCooldown.None;
                                    sim.ThoughtBalloonManager.ShowBalloon(balloonData);
                                }
                            }

                            moves.SetMax(CommodityKind.Bladder);

                            if (!simd.IsPet)
                            {
                                PuddleManager.AddPuddle(sim.Position);
                                moves.SetValue(CommodityKind.Hygiene, -100f);
                                if (GlobalFunctions.AreOtherSimsNearby(sim, BuffEmbarrassed.DistanceForEmbarrassedBuff))
                                {
                                    buffManager.AddElement(BuffNames.Embarrassed, Origin.FromPeeingSelf);
                                }
                                ActiveTopic.AddToSim(sim, "Embarrassment");
                            }
                            else
                            {
                                MetaAutonomyVenueType metaAutonomyVenueType = sim.LotCurrent.GetMetaAutonomyVenueType();
                                if ((!simd.IsADogSpecies || metaAutonomyVenueType != MetaAutonomyVenueType.DogPark) && World.GetTerrainType(sim.Position) == TerrainType.LotFloor)
                                {
                                    PuddleManager.AddPuddle(sim.Position);
                                }
                            }
                            EventTracker.SendEvent(EventTypeId.kBladderFailure, sim);
                        }
                        Motive motive = moves.GetMotive(CommodityKind.Bladder);
                        if (motive != null)
                        {
                            motive.PotionBladderDecayOverride = false;
                        }
                    }
                    else
                    {
                        swimmingInPool.ContainerPool.PeeInPool(sim);
                    }
                }
                break;
            }

            case CommodityKind.Hunger:
            case CommodityKind.VampireThirst:

                if (simd.IsFrankenstein)
                {
                    OccultFrankenstein.PushFrankensteinShortOut(sim);
                }
                else if (!simd.IsGhost && !simd.IsDead && !IsCheckKillSimInteraction(sim))
                {
                    if (sim.Posture.Satisfies(CommodityKind.ScubaDiving, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.ScubaDrown);
                    }
                    else if (sim.Posture.Satisfies(CommodityKind.SwimmingInPool, null) && !simd.IsMermaid)
                    {
                        sim.Kill(SimDescription.DeathType.Drown);
                    }
                    else if (SimTemperature.HasFrozenSolidInteraction(sim))
                    {
                        sim.Kill(SimDescription.DeathType.Freeze, null, false);
                    }
                    else if (OccultMermaid.IsDehydrated(sim))
                    {
                        sim.Kill(SimDescription.DeathType.MermaidDehydrated, null, false);
                    }
                    else
                    {
                        sim.Kill(sim.SimDescription.IsVampire ? SimDescription.DeathType.Thirst : SimDescription.DeathType.Starve);
                    }
                }
                break;

            case CommodityKind.Temperature:
            {
                float value = moves.GetValue(CommodityKind.Temperature);
                if (value > 0f)
                {
                    SimTemperature.PushSpontaneouslyCombustInteraction(sim);
                }
                else
                {
                    SimTemperature.PushFreezeInteraction(sim);
                }
                break;
            }

            case CommodityKind.MermaidDermalHydration:
                OccultMermaid.CollapseFromDehydration(sim);
                break;
            }
        }
Exemplo n.º 19
0
        public void SetElement(VisualElement element)
        {
            _requestedScroll = null;
            var oldElement = Element;

            Element = element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                ((ScrollView)oldElement).ScrollToRequested -= OnScrollToRequested;
            }

            if (element != null)
            {
                element.PropertyChanged += HandlePropertyChanged;
                ((ScrollView)element).ScrollToRequested += OnScrollToRequested;
                if (_packager == null)
                {
                    _packager = new VisualElementPackager(this);
                    _packager.Load();

                    _tracker = new VisualElementTracker(this);
                    _tracker.NativeControlUpdated += OnNativeControlUpdated;
                    _events = new EventTracker(this);
                    _events.LoadEvents(this);


#pragma warning disable CS0618 // Type or member is obsolete
                    _insetTracker = new KeyboardInsetTracker(this, () => Window, insets =>
                    {
                        ContentInset = ScrollIndicatorInsets = insets;
                    },
                                                             point =>
                    {
                        var offset = ContentOffset;
                        offset.Y  += point.Y;
                        SetContentOffset(offset, true);
                    }, this);
#pragma warning restore CS0618 // Type or member is obsolete
                }

                UpdateDelaysContentTouches();
                UpdateContentSize();
                UpdateBackgroundColor();
                UpdateBackground();
                UpdateIsEnabled();
                UpdateVerticalScrollBarVisibility();
                UpdateHorizontalScrollBarVisibility();

                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

                if (element != null)
                {
                    element.SendViewInitialized(this);
                }

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    AccessibilityIdentifier = element.AutomationId;
                }
            }
        }
Exemplo n.º 20
0
            protected override void OnPerform()
            {
                mScenario.IncStat("PopulatePartyTask");

                mParty.mPlaceNpcGuestsFunction = null;
                mParty.SomeGuestsHaveArrived   = true;

                Lot lotHome = mParty.Host.LotHome;

                GatheringScenario.PushBuffetInteractions(mScenario, mParty.Host.SimDescription, lotHome);

                List <Sim> sims = new List <Sim>(HouseholdsEx.AllSims(lotHome.Household));

                SimDescription host = mParty.Host.SimDescription;

                foreach (SimDescription sim in mParty.GuestDescriptions)
                {
                    if (!NpcParty.NpcGuestTest(sim, host))
                    {
                        continue;
                    }

                    if (!mScenario.Situations.Allow(mScenario, sim))
                    {
                        mScenario.IncStat("NpcParty Push User Denied");
                        continue;
                    }

                    Sim createdSim = sim.CreatedSim;
                    if (createdSim == null)
                    {
                        createdSim = Instantiation.PerformOffLot(sim, lotHome, null);
                    }

                    if (createdSim != null)
                    {
                        if (createdSim.LotCurrent != lotHome)
                        {
                            if (!mScenario.Situations.PushVisit(mScenario, sim, lotHome))
                            {
                                mScenario.IncStat("NpcParty Push Fail");
                                continue;
                            }
                        }

                        mParty.Guests.Add(createdSim);
                        createdSim.AssignRole(mParty);

                        VisitSituation.SetVisitToGreeted(createdSim);

                        sims.Add(createdSim);
                    }
                }

                foreach (Sim sim in sims)
                {
                    if (sim.LotCurrent == lotHome)
                    {
                        sim.Motives.SetMax(CommodityKind.Energy);
                        sim.Motives.SetMax(CommodityKind.Hygiene);

                        sim.PushSwitchToOutfitInteraction(Sims3.Gameplay.Actors.Sim.ClothesChangeReason.Force, mParty.ClothingStyle);
                    }
                }

                EventTracker.SendEvent(new PartyEvent(EventTypeId.kPartyBegan, mParty.Host, host, mParty));

                mParty.SetState(new NpcParty.Happening(mParty));
            }
 public EventTrackerTest()
 {
     this.eventTracker = new EventTracker();
     this.mockEvent    = new Mock <ICompilerEvent>();
     this.mockObserver = new Mock <IEventObserver>();
 }
Exemplo n.º 22
0
        protected new void TriggerTravelToVacationWorld()
        {
            RemoveTriggerAlarm();

            List <Sim> allTravelers = new List <Sim>(Followers);

            allTravelers.Add(Actor);

            string reason = null;

            // Custom
            if ((TravelingSimGuids.Count == 0) || (Helpers.TravelUtilEx.FinalBoardingCall(Actor.Household, allTravelers, DestinationWorldName, false, ref reason)))
            {
                ForeignVisitorsSituation.ForceKillForeignVisitorsSituation();
                HolographicProjectionSituation.ForceKillHolographicVisitorsSituation();

                int lastTimeOnVacation = -2147483648;
                foreach (Sim sim in allTravelers)
                {
                    if (lastTimeOnVacation < sim.VisaManager.LastTimeOnVacation)
                    {
                        lastTimeOnVacation = sim.VisaManager.LastTimeOnVacation;
                    }
                }
                int numDaysSinceLastInDestWorld = -1;
                if (lastTimeOnVacation > 0)
                {
                    numDaysSinceLastInDestWorld = SimClock.ElapsedCalendarDays() - lastTimeOnVacation;
                }

                Camera.SetView(CameraView.MapView, false, true);
                int tripLength = (TravelUtil.sOverriddenTripLength > 0x0) ? TravelUtil.sOverriddenTripLength : TravelDuration;

                // Custom
                GameStatesEx.TravelToVacationWorld(DestinationWorldName, TravelingSimGuids, tripLength, numDaysSinceLastInDestWorld);

                TelemetryStats.VacationTelemetryInfo vacationTelemetryInfo = new TelemetryStats.VacationTelemetryInfo();
                vacationTelemetryInfo.LeavingHomeWorld = true;
                vacationTelemetryInfo.WorldId          = DestinationWorldName;

                int num2 = 0x0;

                if (TravelingSimGuids.Count > 0)
                {
                    vacationTelemetryInfo.NumberOfSimsInHoushold    = Households.NumSims(Actor.Household);
                    vacationTelemetryInfo.NumberOfSimsThatDidTravel = allTravelers.Count;

                    foreach (Sim sim in Households.AllSims(Actor.Household))
                    {
                        // Custom
                        if (CommonSpace.Helpers.TravelUtilEx.CheckForReasonsToFailTravel(sim.SimDescription, Traveler.Settings.mTravelFilter, DestinationWorldName, false, false) == null)
                        {
                            num2++;
                        }
                    }
                }
                else
                {
                    vacationTelemetryInfo.NumberOfSimsInHoushold    = 0;
                    vacationTelemetryInfo.NumberOfSimsThatDidTravel = 0;
                }

                vacationTelemetryInfo.NumberOfSimsAbleToTravel = num2;
                vacationTelemetryInfo.VisaLevels = new PairedListDictionary <ulong, int>();
                foreach (Sim sim2 in allTravelers)
                {
                    int visaLevel = sim2.VisaManager.GetVisaLevel(DestinationWorldName);
                    vacationTelemetryInfo.VisaLevels.Add(sim2.SimDescription.SimDescriptionId, visaLevel);
                }

                vacationTelemetryInfo.TravelDateAndTime = SimClock.CurrentTime();
                EventTracker.SendEvent(new VacationInfoEvent(EventTypeId.kVacationTelemetryInfo, vacationTelemetryInfo));
            }
            else
            {
                if (DestinationWorldName == WorldName.FutureWorld)
                {
                    Actor.ShowTNSIfSelectable(TravelUtil.LocalizeString(Actor.IsFemale, "CantTravelFutureTNS", new object[] { TravelCost }), StyledNotification.NotificationStyle.kSystemMessage, ObjectGuid.InvalidObjectGuid);
                }
                else
                {
                    Actor.ShowTNSIfSelectable(TravelUtil.LocalizeString(Actor.IsFemale, "CantTravelTNS", new object[] { TravelCost }) + Common.NewLine + Common.NewLine + reason, StyledNotification.NotificationStyle.kSystemMessage, ObjectGuid.InvalidObjectGuid);
                }

                Actor.ModifyFunds(TravelCost);

                foreach (Sim sim3 in allTravelers)
                {
                    if (!sim3.IsDying())
                    {
                        sim3.AddExitReason(ExitReason.CanceledByScript);
                    }
                }
            }
        }
Exemplo n.º 23
0
        public override void HourlyCallback()
        {
            if (GameUtils.IsOnVacation() || GameUtils.IsUniversityWorld())
            {
                Common.DebugNotify("AlienPregnancy.HourlyCallback - Pregnancy paused");
                return;
            }

            mHourOfPregnancy++;

            string msg = mMom.FullName + Common.NewLine
                         + "AlienPregnancy.HourlyCallback" + Common.NewLine
                         + " - Hour: " + mHourOfPregnancy + Common.NewLine;

            if (mHourOfPregnancy == Aliens.Settings.mPregnancyShow)
            {
                msg += " - Showing Pregnancy";

                InteractionInstance instance = ShowAlienPregnancy.Singleton.CreateInstance(mMom, mMom,
                                                                                           new InteractionPriority(InteractionPriorityLevel.ESRB), false, false);
                instance.Hidden = true;
                mMom.InteractionQueue.AddNext(instance);

                Common.DebugNotify(msg);

                return;
            }

            if (mMom.Household.IsTouristHousehold)
            {
                msg += " - Mother is Tourist" + Common.NewLine;

                ForeignVisitorsSituation situation = ForeignVisitorsSituation.TryGetForeignVisitorsSituation(mMom);

                if (mHourOfPregnancy == Aliens.Settings.mForeignShowTNS && situation != null)
                {
                    StyledNotification.Show(new StyledNotification.Format(
                                                Localization.LocalizeString("Gameplay/ActorSystems/Pregnancy:ForeignBabyIsComingTNS",
                                                                            new object[] { mMom }), StyledNotification.NotificationStyle.kGameMessagePositive));
                }

                if (mHourOfPregnancy == Aliens.Settings.mForeignLeaves)
                {
                    msg += " - Sending Pregnant Tourist Home";

                    if (situation != null)
                    {
                        situation.MakeGuestGoHome(mMom);
                    }
                    else if (mMom.SimDescription.AssignedRole != null)
                    {
                        mMom.SimDescription.AssignedRole.RemoveSimFromRole();
                    }

                    Common.DebugNotify(msg);
                }

                if (mHourOfPregnancy > Aliens.Settings.mForeignLeaves)
                {
                    msg += " - Walking Back 1 Hour";

                    mHourOfPregnancy--;

                    Common.DebugNotify(msg);

                    return;
                }
            }

            if (mHourOfPregnancy >= Aliens.Settings.mStartWalk)
            {
                ActiveTopic.AddToSim(mMom, "Pregnant", mMom.SimDescription);
                RequestPregnantWalkStyle();
            }

            if (mHourOfPregnancy == Aliens.Settings.mStartLabor)
            {
                msg += " - Beginning Labor" + Common.NewLine;

                for (int i = 0; i < Aliens.Settings.mNumPuddles; i++)
                {
                    PuddleManager.AddPuddle(mMom.PositionOnFloor);
                }

                if (mMom.IsSelectable)
                {
                    StyledNotification.Show(new StyledNotification.Format(Localization.LocalizeString("Gameplay/ActorSystems/Pregnancy:BabyIsComingTNS",
                                                                                                      new object[] { mMom }), StyledNotification.NotificationStyle.kGameMessageNegative), "glb_tns_baby_coming_r2");
                }

                mMom.BuffManager.RemoveElement(BuffsAndTraits.sXenogenesis);
                mMom.BuffManager.AddElement(BuffsAndTraits.sAlienBabyIsComing, Origin.FromPregnancy);

                if (mContractionBroadcast != null)
                {
                    mContractionBroadcast.Dispose();
                }

                mContractionBroadcast = new ReactionBroadcaster(mMom, kContractionBroadcasterParams,
                                                                new ReactionBroadcaster.BroadcastCallback(StartReaction), new ReactionBroadcaster.BroadcastCallback(CancelReaction));
                mMom.AddInteraction(TakeToHospitalEx.Singleton);
                InteractionInstance entry = HaveContraction.Singleton.CreateInstance(mMom, mMom,
                                                                                     new InteractionPriority(InteractionPriorityLevel.High, 10f), false, false);
                mMom.InteractionQueue.Add(entry);
                mContractionsAlarm = mMom.AddAlarmRepeating(5f, TimeUnit.Minutes, new AlarmTimerCallback(TriggerContraction), 5f, TimeUnit.Minutes,
                                                            "Trigger Contractions Alarm", AlarmType.AlwaysPersisted);
                EventTracker.SendEvent(EventTypeId.kPregnancyContractionsStarted, mMom);
            }

            if (mHourOfPregnancy >= Aliens.Settings.mPregnancyDuration)
            {
                msg += " - Delivering Baby" + Common.NewLine;
                HaveTheBaby();
            }

            SetPregoBlendShape();

            Common.DebugNotify(msg);
        }
Exemplo n.º 24
0
 public TrackerWithItsEvents(EventTracker tracker, IReadOnlyCollection <Event> events)
 {
     Tracker = tracker;
     Events  = events;
 }
Exemplo n.º 25
0
 void Awake()
 {
     Time.timeScale = 1;
     instance       = this;
     tracker        = GetComponent <EventTracker>();
 }
Exemplo n.º 26
0
        protected void HandleHomework(Sim sim, bool fromRabbithole)
        {
            if (sim == null)
            {
                return;
            }

            if (sim.School == null)
            {
                return;
            }

            if ((SimTypes.IsSelectable(sim)) &&
                (sim.School.OwnersHomework != null) &&
                (sim.School.OwnersHomework.PercentComplete == 0f))
            {
                Notify(sim, Common.Localize("HomeSchooling:HaveHomework", sim.IsFemale, new object[] { sim }));
            }
            else
            {
                bool bExistingHomework = false;

                if (sim.School.OwnersHomework != null)
                {
                    float perfGain = NRaas.Careers.Settings.mPerformancePerHomework * ((sim.School.OwnersHomework.PercentComplete - 50f) / 100f);

                    sim.School.AddPerformance(perfGain);

                    if (sim.SimDescription.CareerManager != null)
                    {
                        sim.SimDescription.CareerManager.UpdatePerformanceUI(this);
                    }

                    sim.School.OwnersHomework.Dispose();

                    sim.School.OwnersHomework = null;

                    bExistingHomework = true;
                }

                if (sim.School.OwnersHomework == null)
                {
                    sim.School.OwnersHomework = GlobalFunctions.CreateObjectOutOfWorld("Homework") as Homework;
                    sim.School.OwnersHomework.OwningSimDescription = sim.SimDescription;

                    sim.Inventory.TryToAdd(sim.School.OwnersHomework, false);
                }

                sim.School.OwnersHomework.PercentComplete = 0f;
                sim.School.OwnersHomework.Cheated         = false;

                mLastHomeworkDay = SimClock.ElapsedCalendarDays();

                string suffix = null;
                if (fromRabbithole)
                {
                    suffix = "Rabbithole";
                }

                if (bExistingHomework)
                {
                    Notify(sim, Common.Localize("HomeSchooling:ExistingHomework" + suffix, sim.IsFemale, new object[] { sim }));
                }
                else
                {
                    Notify(sim, Common.Localize("HomeSchooling:NewHomework" + suffix, sim.IsFemale, new object[] { sim }));
                }

                if (SchoolTuning != null)
                {
                    if (sim.School.Performance >= SchoolTuning.GradeThresholdA)
                    {
                        sim.School.mConsecutiveDaysWithA++;
                        if (sim.School.mConsecutiveDaysWithA >= SchoolTuning.DaysWithAForHonorRoll)
                        {
                            sim.BuffManager.AddElement(BuffNames.HonorStudent, Origin.FromGoodGrades);
                        }
                    }
                    else
                    {
                        ActiveTopic.AddToSim(sim, "Complain About School");
                        sim.School.mConsecutiveDaysWithA = 0;
                        if (sim.School.Performance <= SchoolTuning.GradeThresholdF)
                        {
                            sim.BuffManager.AddElement(BuffNames.Failing, Origin.FromBadGrades);
                        }
                    }
                }

                EventTracker.SendEvent(EventTypeId.kFinishedSchool, sim);
            }
        }
 public FakeBus(Disposable1 disposable1, EventTracker tracker)
 {
     _tracker = tracker;
 }
Exemplo n.º 28
0
        public override void PregnancyComplete(List <Sim> newborns, List <Sim> followers)
        {
            if (mMom.IsSelectable)
            {
                Audio.StartObjectSound(mMom.ObjectId, "sting_baby_born_alien", false);
            }

            Tutorialette.TriggerLesson(Lessons.Babies, mMom);
            EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, mMom, mDad, this, newborns));

            mMom.BuffManager.RemoveElement(AbductionBuffs.sXenogenesis);
            mMom.BuffManager.RemoveElement(AbductionBuffs.sAlienBabyIsComing);
            mMom.RemoveInteractionByType(TakeToHospitalEx.Singleton);

            UnrequestPregnantWalkStyle();

            if (!mMom.SimDescription.IsVampire)
            {
                Motive motive = mMom.Motives.GetMotive(CommodityKind.Hunger);

                if (motive != null)
                {
                    motive.PregnantMotiveDecay = false;
                }
            }

            Motive motive2 = mMom.Motives.GetMotive(CommodityKind.Bladder);

            if (motive2 != null)
            {
                motive2.PregnantMotiveDecay = false;
            }

            BuffNames buffName = BuffNames.ItsABoy;

            switch (newborns.Count)
            {
            case 1:
                buffName = newborns[0].IsFemale ? BuffNames.ItsAGirl : BuffNames.ItsABoy;
                break;

            case 2:
                buffName = BuffNames.ItsTwins;
                break;

            case 3:
                buffName = BuffNames.ItsTriplets;
                break;
            }

            mMom.BuffManager.AddElement(buffName, Origin.FromNewBaby);

            if (mMom.TraitManager.HasElement(TraitNames.Dramatic))
            {
                mMom.PlayReaction(ReactionTypes.JoyousCrying, ReactionSpeed.NowOrLater);
            }

            if (followers != null)
            {
                foreach (Sim current in followers)
                {
                    if (current.SimDescription.ToddlerOrAbove)
                    {
                        current.BuffManager.AddElement(buffName, Origin.FromNewBaby);
                    }
                }
            }

            bool flag = !mMom.Household.IsActive;

            foreach (Sim current2 in newborns)
            {
                if (flag)
                {
                    current2.SimDescription.AgingState.AgeUpWithinNDays(Pregnancy.kMaxDaysAsNPCBaby);
                }

                current2.SimDescription.PushAgingEnabledToAgingManager();
            }

            mMom.SimDescription.NullOutPregnancy();
        }
Exemplo n.º 29
0
 public static void Process(ViewPage page, PageRequest request)
 {
     EventTracker tracker = new EventTracker();
     tracker.InternalProcess(page, request);
 }
Exemplo n.º 30
0
        public override List <Sim> CreateNewborns(float bonusMoodPoints, bool interactive, bool homeBirth)
        {
            SimDescription     alien     = null;
            MiniSimDescription miniAlien = null;

            if (mDad != null && !mDad.HasBeenDestroyed)
            {
                alien = mDad.SimDescription;
            }

            if (alien == null)
            {
                alien = SimDescription.Find(DadDescriptionId);

                if (alien == null)
                {
                    miniAlien = MiniSimDescription.Find(DadDescriptionId);

                    if (miniAlien != null)
                    {
                        alien = miniAlien.UnpackSim();

                        if (alien != null)
                        {
                            Household household = Household.Create(false);

                            if (household != null)
                            {
                                household.AddTemporary(alien);
                                alien.Genealogy.SetSimDescription(alien);
                            }
                        }
                        else
                        {
                            miniAlien = null;
                        }
                    }
                }
            }

            float  averageMoodForBirth = GetAverageMoodForBirth(alien, bonusMoodPoints);
            Random pregoRandom         = new Random(mRandomGenSeed);
            int    numSimMembers       = 0;
            int    numPetMembers       = 0;

            mMom.Household.GetNumberOfSimsAndPets(true, out numSimMembers, out numPetMembers);
            int        numForBirth = GetNumForBirth(alien, pregoRandom, numSimMembers, numPetMembers);
            Random     gen         = new Random(mRandomGenSeed);
            List <Sim> list        = new List <Sim>();

            for (int i = 0; i < numForBirth; i++)
            {
                DetermineGenderOfBaby(gen);
                CASAgeGenderFlags gender = mGender;
                mGender = CASAgeGenderFlags.None;
                SimDescription babyDescription = AlienUtilsEx.MakeAlienBaby(alien, mMom.SimDescription, gender, averageMoodForBirth, pregoRandom, interactive);
                mMom.Household.Add(babyDescription);
                Sim baby = babyDescription.Instantiate(Vector3.Empty);
                baby.SetPosition(mMom.Position);

                if (homeBirth)
                {
                    TotallyHideBaby(baby);
                }

                list.Add(baby);
                CheckForGhostBaby(baby);

                if (baby.SimDescription.IsPlayableGhost)
                {
                    EventTracker.SendEvent(EventTypeId.kHadGhostBaby, mMom, baby);
                }

                if (i == 0)
                {
                    EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, baby.SimDescription));
                }

                MidlifeCrisisManager.OnHadChild(mMom.SimDescription);
                EventTracker.SendEvent(EventTypeId.kNewOffspring, mMom, baby);
                //EventTracker.SendEvent(EventTypeId.kParentAdded, baby, mMom);

                if (mDad != null)
                {
                    EventTracker.SendEvent(EventTypeId.kNewOffspring, mDad, baby);
                    EventTracker.SendEvent(EventTypeId.kParentAdded, baby, mDad);
                }

                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, baby);
            }

            if (miniAlien != null)
            {
                alien.Household.Destroy();
                alien.Household.RemoveTemporary(alien);
                alien.Dispose(true, true);
            }

            if (mMom.Household != null)
            {
                mMom.Household.InvalidateThumbnail();
            }

            switch (numForBirth)
            {
            case 1:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabySingle, mMom.SimDescription));
                break;

            case 2:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabyTwins, mMom.SimDescription));
                break;

            case 3:
                EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBabyTriplets, mMom.SimDescription));
                break;
            }

            return(list);
        }
Exemplo n.º 31
0
 public static void Process(ActionArgs args, ControllerConfiguration config)
 {
     if ((args.CommandName == "Update") || (args.CommandName == "Insert"))
     {
         EventTracker tracker = new EventTracker();
         tracker.InternalProcess(args, config);
     }
 }
Exemplo n.º 32
0
        public Option <ISingleTrackerFact> Calculate(IReadOnlyCollection <Event> events, EventTracker tracker, DateTimeOffset now)
        {
            if (!CanCalculate(events))
            {
                return(Option <ISingleTrackerFact> .None);
            }

            var(lastEventBeforeBreak, firstEventAfterBreak) = GetFirstAndLastEventOfTheLongestBreak(events);
            var maxDurationInDays = (firstEventAfterBreak.HappensDate - lastEventBeforeBreak.HappensDate).Days;
            var priority          = Math.Sqrt(maxDurationInDays);
            var description       =
                $"Самый большой перерыв в {tracker.Name} произошёл с {lastEventBeforeBreak}" +
                $" до {firstEventAfterBreak}, он занял {maxDurationInDays} дней";
            const string factName = "Самый долгий перерыв";

            return(Option <ISingleTrackerFact> .Some(new LongestBreakTrackerFact(
                                                         factName,
                                                         description,
                                                         priority,
                                                         maxDurationInDays,
                                                         lastEventBeforeBreak.HappensDate,
                                                         firstEventAfterBreak.HappensDate)));
        }
Exemplo n.º 33
0
        public void SetElement(TElement element)
        {
            var oldElement = Element;

            Element = element;

            Performance.Start(out string reference);

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= _propertyChangedHandler;
            }

            if (element != null)
            {
                if (element.BackgroundColor != Color.Default || (oldElement != null && element.BackgroundColor != oldElement.BackgroundColor))
                {
                    SetBackgroundColor(element.BackgroundColor);
                }

                if (element.Background != null && (!element.Background.IsEmpty || (oldElement != null && element.Background != oldElement.Background)))
                {
                    SetBackground(element.Background);
                }

                UpdateClipToBounds();

                if (_tracker == null)
                {
                    _tracker = new VisualElementTracker(this);
                    _tracker.NativeControlUpdated += (sender, e) => UpdateNativeWidget();
                }

                if (AutoPackage && _packager == null)
                {
                    _packager = new VisualElementPackager(this);
                    _packager.Load();
                }

                if (AutoTrack && _events == null)
                {
                    _events = new EventTracker(this);
                    _events.LoadEvents(this);
                }

                element.PropertyChanged += _propertyChangedHandler;
            }

            OnElementChanged(new ElementChangedEventArgs <TElement>(oldElement, element));

            if (element != null)
            {
                SendVisualElementInitialized(element, this);
            }

            EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);

            if (Element != null && !string.IsNullOrEmpty(Element.AutomationId))
            {
                SetAutomationId(Element.AutomationId);
            }

            if (element != null)
            {
                SetAccessibilityLabel();
            }

            SetAccessibilityHint();
            SetIsAccessibilityElement();
            Performance.Stop(reference);
        }
Exemplo n.º 34
0
        protected override DereferenceResult Perform(VisitSituation reference, FieldInfo field, List <ReferenceWrapper> objects)
        {
            ReferenceWrapper result;

            if (Matches(reference, "mLastHostRemoved", field, objects, out result) != MatchResult.Failure)
            {
                if (Performing)
                {
                    if (result.Valid)
                    {
                        try
                        {
                            reference.Exit();
                        }
                        catch
                        { }

                        Remove(ref reference.mLastHostRemoved);
                    }
                }
                return(DereferenceResult.End);
            }

            if (Matches(reference, "mMostFriendlyHost", field, objects, out result) != MatchResult.Failure)
            {
                if (Performing)
                {
                    try
                    {
                        reference.Exit();
                    }
                    catch
                    { }

                    if (result.Valid)
                    {
                        Remove(ref reference.mMostFriendlyHost);
                    }
                }
                return(DereferenceResult.End);
            }

            if (Matches(reference, "mPreviousHost", field, objects, out result) != MatchResult.Failure)
            {
                if (Performing)
                {
                    try
                    {
                        reference.Exit();
                    }
                    catch
                    { }

                    if (result.Valid)
                    {
                        Remove(ref reference.mPreviousHost);
                    }
                }
                return(DereferenceResult.End);
            }

            if (Matches(reference, "mHosts", field, objects))
            {
                if (Performing)
                {
                    try
                    {
                        reference.Exit();
                    }
                    catch
                    { }

                    Remove(reference.mHosts, objects);
                }
                return(DereferenceResult.End);
            }

            if (Matches(reference, "mGuest", field, objects))
            {
                if (Performing)
                {
                    try
                    {
                        reference.Exit();
                    }
                    catch
                    { }

                    Remove(ref reference.mGuest);
                }
                return(DereferenceResult.End);
            }

            if (Matches(reference, "mEventListeners", field, objects))
            {
                if (Performing)
                {
                    try
                    {
                        reference.Exit();
                    }
                    catch
                    { }

                    List <List <EventListener> > events = RemoveKeys(reference.mEventListeners, objects);

                    foreach (List <EventListener> list in events)
                    {
                        foreach (EventListener e in list)
                        {
                            EventTracker.RemoveListener(e);
                        }
                    }

                    return(DereferenceResult.End);
                }
                else
                {
                    return(DereferenceResult.Found);
                }
            }

            return(DereferenceResult.Failure);
        }
Exemplo n.º 35
0
        public override bool Run()
        {
            if (Target.InUse)
            {
                return(false);
            }

            mNPCAbductor = (SimToAbduct != null);

            if (!mNPCAbductor)
            {
                SimToAbduct = GetSelectedObject() as Sim;
            }

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

            StandardEntry();

            if (!SetupAbductee())
            {
                StandardExit();
                return(false);
            }

            Animation.ForceAnimation(Actor.ObjectId, true);
            Animation.ForceAnimation(Target.ObjectId, true);
            Target.mTakeOffPos = Actor.Position;

            if (!Target.RouteToUFOAndTakeOff(Actor))
            {
                StandardExit();
                return(false);
            }

            Camera.FocusOnGivenPosition(mJig.Position, CarUFO.kAbductLerpParams, true);
            BeginCommodityUpdates();
            bool flag = AbductSim();

            EndCommodityUpdates(true);
            Sim[] sims;

            if (flag)
            {
                EventTracker.SendEvent(EventTypeId.kAbductSimUFO, Actor, SimToAbduct);
                sims = new Sim[] { Actor, SimToAbduct };

                if (mNPCAbductor)
                {
                    DoTimedLoop(AlienUtils.kAbductionLength, ExitReason.None);
                }
            }
            else
            {
                sims = new Sim[] { Actor };
            }

            DateAndTime previous   = SimClock.CurrentTime();
            Vector3     landRefPos = GetLandingRefPos(mNPCAbductor);

            while (!Target.TryLandUFOAndExitSims(sims, landRefPos, true))
            {
                Simulator.Sleep(30u);

                if (SimClock.ElapsedTime(TimeUnit.Minutes, previous) > 30f)
                {
                    Target.ForceExitUFODueToLandingFailure(sims);
                    break;
                }
            }

            mFromInventory = (mFromInventory || mNPCAbductor);

            if (mFromInventory)
            {
                mFromInventory = Actor.Inventory.TryToAdd(Target);
            }

            if (!mFromInventory)
            {
                Target.ParkUFO(Actor.LotHome, Actor);
            }

            if (flag)
            {
                if (mNPCAbductor)
                {
                    SimToAbduct.BuffManager.AddElement(BuffsAndTraits.sAbductedEx, Origin.FromAbduction);
                    ThoughtBalloonManager.BalloonData data = new ThoughtBalloonManager.BalloonData(Actor.GetThumbnailKey());
                    data.BalloonType = ThoughtBalloonTypes.kThoughtBalloon;
                    data.LowAxis     = ThoughtBalloonAxis.kDislike;
                    data.Duration    = ThoughtBalloonDuration.Medium;
                    data.mPriority   = ThoughtBalloonPriority.High;
                    SimToAbduct.ThoughtBalloonManager.ShowBalloon(data);
                    SimToAbduct.PlayReaction(AlienUtils.kAbductionReactions[RandomUtil.GetInt(0, AlienUtils.kAbductionReactions.Length - 1)], ReactionSpeed.NowOrLater);
                    SimToAbduct.ShowTNSIfSelectable(CarUFO.LocalizeString(SimToAbduct.IsFemale, "NPCAbductionTNS", new object[] { SimToAbduct.ObjectId }),
                                                    StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, SimToAbduct.ObjectId);
                }
                else
                {
                    Sim.ForceSocial(Actor, SimToAbduct, "Reveal Prank", InteractionPriorityLevel.High, true);
                }

                FinishLinkedInteraction(true);
            }

            StandardExit();

            if (flag)
            {
                WaitForSyncComplete();
            }

            return(flag);
        }
 public Disposable1(Disposable2 innerDisposable, EventTracker tracker)
 {
     _tracker = tracker;
 }
Exemplo n.º 37
0
        public static void EnsureTrackingFields(ViewPage page, ControllerConfiguration config)
        {
            EventTracker tracker = new EventTracker();

            tracker.InternalEnsureTrackingFields(page, config);
        }
        public Option <ISingleTrackerFact> Calculate(IReadOnlyCollection <Event> events, EventTracker tracker, DateTimeOffset now)
        {
            if (!CanCalculate(events))
            {
                return(Option <ISingleTrackerFact> .None);
            }

            const string factName    = "Количество событий";
            var          eventsCount = events.Count;
            var          description = $"Событие {tracker.Name} произошло {eventsCount} раз";
            var          priority    = Math.Log(eventsCount);

            return(Option <ISingleTrackerFact>
                   .Some(new SingleTrackerEventsCountFact(factName, description, priority, eventsCount)));
        }
Exemplo n.º 39
0
        public override bool Run()
        {
            try
            {
                string str;
                mTimeTravelDef = InteractionDefinition as Definition;
                if (!Target.RouteToMachine(Actor, false, null))
                {
                    return(false);
                }

                if (!TimePortalTravelEx.PreTimeTravel1(this))
                {
                    return(false);
                }

                if (!TimePortalTravelEx.PreTimeTravel2(this))
                {
                    return(false);
                }

                Actor.SimDescription.Contactable = false;
                EnterStateMachine("TimeMachine", "Enter", "x");
                SetActor("timeMachine", Target);
                SetParameter("isFuture", mTimeTravelDef.TimePeriod == TimeMachine.TravelTimePeriod.Future);
                AddOneShotScriptEventHandler(0x3ee, OnEnterAnimationEvent);
                AddOneShotScriptEventHandler(0x66, ToggleHiddenAnimationEvent);
                AnimateSim("GetIn");
                Target.EnableRoutingFootprint(Actor);

                mTimeTravelAlarm = AlarmManager.Global.AddAlarmRepeating(RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, new AlarmTimerCallback(TimeTravelCallback), RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, "Time Travel Alarm For:" + Actor.SimDescription.FullName, AlarmType.AlwaysPersisted, Actor);
                Target.SetMaterial("InUse");

                bool succeeded = true;
                if (!GameUtils.IsFutureWorld())
                {
                    // Custom
                    succeeded = TimePortalEx.TravelToFuture(null, Actor, new List <Sim>(), new List <ulong>());
                }

                succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                EndCommodityUpdates(succeeded);
                Target.PickExitStateAndSound(mTimeTravelDef.TimePeriod, out str, out mExitSound);
                AddOneShotScriptEventHandler(0x3e9, OnExitAnimationEvent);
                AddOneShotScriptEventHandler(0x3ef, OnExitAnimationEvent);
                AddOneShotScriptEventHandler(0x67, ToggleHiddenAnimationEvent);
                AnimateSim(str);

                if (!TimePortalTravelEx.PostTimeTravel1(this, succeeded))
                {
                    return(false);
                }

                Target.SetMaterial("default");
                AnimateSim("Exit");
                if (!string.IsNullOrEmpty(mTravelSummary))
                {
                    Actor.ShowTNSIfSelectable(mTravelSummary, StyledNotification.NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId);
                }

                StandardExit();
                Target.Repairable.UpdateBreakage(Actor);
                InventingSkill skill = Actor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                if (succeeded && (skill != null))
                {
                    skill.RegisterTimeTravelDone();
                }

                if (GameUtils.IsFutureWorld())
                {
                    EventTracker.SendEvent(EventTypeId.kTravelToPresent, Actor);

                    // Custom
                    GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld();
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
            finally
            {
                TravelUtil.PlayerMadeTravelRequest = false;
            }
        }
Exemplo n.º 40
0
 public Disposable2(EventTracker tracker)
 {
     _tracker = tracker;
 }
Exemplo n.º 41
0
        public override bool Run()
        {
            try
            {
                if (!StartSync())
                {
                    return(false);
                }

                StandardEntry(false);
                BeginCommodityUpdates();
                if (IsMaster)
                {
                    ReturnInstance.EnsureMaster();
                    StartSocial("Kiss");
                    InitiateSocialUI(Actor, Target);
                    (LinkedInteractionInstance as NestedCuddleInteraction).Rejected = Rejected;

                    // Custom
                    mReactToSocialBroadcaster = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventMedium);
                    //SocialComponent.SendCheatingEvents(Actor, Target, !Rejected);

                    if (Rejected)
                    {
                        ReturnInstance.mCurrentStateMachine.RequestState(null, "KissReject");
                        ReturnInstance.mCurrentStateMachine.RequestState(null, "ExitSitting");
                        FinishSocial("Kiss", true);
                        FinishSocialContext();
                    }
                    else
                    {
                        ReturnInstance.mCurrentStateMachine.RequestState(null, "Kiss");
                        FinishSocial("Kiss", true);
                    }
                }
                else
                {
                    DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }

                FinishLinkedInteraction(IsMaster);
                EndCommodityUpdates(!Rejected);
                StandardExit(false, false);
                EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Kiss", !IsMaster, !Rejected, false, CommodityTypes.Undefined));
                if (Rejected)
                {
                    InvokeDoResumeOnCleanup = false;
                }
                else
                {
                    Actor.SimDescription.SetFirstKiss(Target.SimDescription);
                    if (SimClock.IsNightTime() && SimClock.IsFullMoon())
                    {
                        Actor.BuffManager.AddElement(BuffNames.KissedUnderFullMoon, Origin.None);
                        EventTracker.SendEvent(EventTypeId.kKissedUnderFullMoon, Actor);
                    }
                }

                WaitForSyncComplete();
                return(!Rejected);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Exemplo n.º 42
0
        private Container BuildContainer()
        {
            var documentStore = new DocumentStore
            {
                Url = "http://localhost:8080",
                DefaultDatabase = "Todo"
            };
            
            documentStore.Initialize();

            var container = new Container(cfg =>
            {
                cfg.Scan(scanner =>
                {
                    scanner.AssemblyContainingType<CreateTodoItem>();
                    scanner.AssemblyContainingType<IMediator>();
                    scanner.AddAllTypesOf(typeof(IRequestHandler<,>));
                    scanner.AddAllTypesOf(typeof(IEventHandler<>));
                    scanner.AddAllTypesOf(typeof(IPreRequestHandler<>));
                    scanner.AddAllTypesOf(typeof(IPostRequestHandler<,>));
                    scanner.WithDefaultConventions();
                });
                cfg.For<IDocumentStore>()
                    .Use(documentStore).Singleton();

                cfg.For<IDocumentSession>()
                    .Use(ctx => ctx.GetInstance<IDocumentStore>()
                        .OpenSession());
                
                cfg.For<IManageUnitOfWork>()
                    .Use<RavenDbUnitOfWork>();

                //var handlerType = cfg.For(typeof(IRequestHandler<,>));                  
                //handlerType.DecorateAllWith(typeof(DomainEventDispatcherHandler<,>));

                cfg.For(typeof(IRequestHandler<,>))
                    .DecorateAllWith(typeof(MediatorPipeline<,>));

                var eventTracker = new EventTracker();

                cfg.For<IDocumentStoreListener>()
                    .Use(eventTracker);
                cfg.For<ITrackEvents>()
                    .Use(eventTracker);
                
                documentStore.RegisterListener(eventTracker);

                
            });

            return container;
        }
Exemplo n.º 43
0
 private void Update()
 {
     var toViewPortSquared = (Universe.Current.ViewPort.Shiftable.GetAbsoluteUniversePosition() - Shiftable.GetAbsoluteUniversePosition()).sqrMagnitude;
     if (_lastDistanceSquared > _triggerRadiusSquared)
     {
         if (toViewPortSquared < _triggerRadiusSquared)
         {
             Trigger();
         }
     }
     if (UseTracker)
     {
         if (_tracker == null)
         {
             if (_lastDistanceSquared > _trackerRadiusSquared)
             {
                 if (toViewPortSquared < _trackerRadiusSquared)
                 {
                     _tracker = gameObject.AddComponent<EventTracker>();
                     _tracker.ArrowCursorImage = ArrowCursorImage;
                     _tracker.TrackerCursorImage = TrackerCursorImage;
                     _tracker.LabelFont = LabelFont;
                 }
             }
         }
         if (_tracker != null)
         {
             if (_lastDistanceSquared < _trackerRadiusSquared)
             {
                 if (toViewPortSquared > _trackerRadiusSquared)
                 {
                     _tracker.SelfDestroy();
                 }
             }
         }
     }
     _lastDistanceSquared = toViewPortSquared;
 }
 public Disposable2(EventTracker tracker)
 {
     _tracker = tracker;
 }
Exemplo n.º 45
0
 public Disposable1(Disposable2 innerDisposable, EventTracker tracker)
 {
     _tracker = tracker;
 }
Exemplo n.º 46
0
        public void OnWorldLoadFinished()
        {
            kDebugging = Settings.Debugging;
            FilterHelper.kFilterCacheTime = Tagger.Settings.mFilterCacheTime;

            EventTracker.AddListener(EventTypeId.kEnterInWorldSubState, new ProcessEventDelegate(this.OnLiveMode));
            EventTracker.AddListener(EventTypeId.kSimInstantiated, new ProcessEventDelegate(this.OnSimInstantiated));

            List <ulong> invalidIds = new List <ulong>();

            foreach (ulong lotId in Tagger.Settings.mAddresses.Keys)
            {
                Lot lot;
                if (LotManager.sLots.TryGetValue(lotId, out lot))
                {
                    lot.mAddressLocalizationKey = Tagger.Settings.mAddresses[lotId];
                }
                else
                {
                    invalidIds.Add(lotId);
                }
            }
            foreach (ulong id in invalidIds)
            {
                Tagger.Settings.mAddresses.Remove(id);

                BooterLogger.AddTrace("Removed: " + id);
            }

            List <ulong> invalidSims = new List <ulong>();

            foreach (ulong descId in Tagger.Settings.mTaggedSims)
            {
                SimDescription     desc  = SimDescription.Find(descId);
                MiniSimDescription desc2 = MiniSimDescription.Find(descId);
                if (desc == null && desc2 == null)
                {
                    invalidSims.Add(descId);
                }
            }

            foreach (KeyValuePair <ulong, List <string> > pair in Tagger.Settings.mCustomSimTitles)
            {
                SimDescription     desc  = SimDescription.Find(pair.Key);
                MiniSimDescription desc2 = MiniSimDescription.Find(pair.Key);
                if (desc == null && desc2 == null)
                {
                    invalidSims.Add(pair.Key);
                }
            }

            // stop KeyNotFoundExceptions... in hindsight should have wrapped these in a get function...
            foreach (TagDataHelper.TagDataType flag in Enum.GetValues(typeof(TagDataHelper.TagDataType)))
            {
                if (!Tagger.Settings.mTagDataSettings.ContainsKey(flag))
                {
                    Tagger.Settings.mTagDataSettings.Add(flag, false);
                }
            }

            Tagger.Settings.ValidateActiveFilters(true);
        }
Exemplo n.º 47
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool success = false;

            List <IFishContainer> bowls = new List <IFishContainer>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Sim))
            {
                bowls.AddRange(lot.GetObjects <IFishContainer>());
            }

            List <GameObject> inventory = GetInventory(Sim);

            Dictionary <FishType, Fish> perfect = new Dictionary <FishType, Fish>();

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    if (perfect.ContainsKey(fish.Type))
                    {
                        continue;
                    }

                    perfect.Add(fish.Type, fish);
                }
            }

            foreach (Fish fish in inventory)
            {
                if (fish == null)
                {
                    continue;
                }

                if (fish.GetQuality() == Sims3.Gameplay.Objects.Quality.Perfect)
                {
                    bool moved = false;

                    foreach (IFishContainer obj in bowls)
                    {
                        FishBowlBase bowl = obj as FishBowlBase;
                        if (bowl != null)
                        {
                            if (bowl.HasFish())
                            {
                                continue;
                            }

                            Inventories.ParentInventory(fish).TryToRemove(fish);

                            bowl.SetFishInBowl(fish);

                            bowl.StartFishFx();
                            bowl.FishFed();

                            EventTracker.SendEvent(EventTypeId.kPutFishInFishbowl, Sim.CreatedSim, bowl);

                            IncStat("Stored in Bowl");
                            moved = true;
                            break;
                        }
                        else
                        {
                            FishTank tank = obj as FishTank;
                            if (tank != null)
                            {
                                if (tank.Inventory == null)
                                {
                                    continue;
                                }

                                if (tank.Inventory.IsFull())
                                {
                                    continue;
                                }

                                tank.Inventory.TryToMove(fish);

                                IncStat("Stored in Tank");
                                moved = true;
                                break;
                            }
                        }
                    }

                    if (perfect[fish.Type] == fish)
                    {
                        moved = true;

                        IncStat("Perfect Retained");
                    }

                    if (moved)
                    {
                        continue;
                    }
                }

                int value = Money.Sell(Sim, fish);
                mFunds += value;

                AddStat("Sold", value);
                success = true;
            }

            return(success);
        }
Exemplo n.º 48
0
 void Awake()
 {
     Debug.Log("Instance !");
     instance = this;
 }
Exemplo n.º 49
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <PropertyData> properties = new List <PropertyData>();

            int max = Maximum;
            int min = Minimum;

            foreach (PropertyData property in Sim.Household.RealEstateManager.AllProperties)
            {
                int cost = GetCost(property);
                if (cost <= 0)
                {
                    continue;
                }

                if (cost < min)
                {
                    continue;
                }

                if (cost > max)
                {
                    continue;
                }

                properties.Add(property);
            }

            if (properties.Count == 0)
            {
                return(false);
            }

            mFail = IsFail(Sim, Target);

            if (!mFail)
            {
                PropertyData choice = RandomUtil.GetRandomObjectFromList(properties);

                mObjectName  = choice.LocalizedName;
                mObjectValue = GetCost(choice);

                if (ActualTransfer)
                {
                    ManagerMoney.TransferProperty(Sim.Household, Target.Household, choice);
                }
                else
                {
                    Money.AdjustFunds(Target, "PropertyTransfer", -mObjectValue);

                    Money.AdjustFunds(Sim, "PropertyTransfer", mObjectValue);
                }

                if (Delta < 0)
                {
                    TraitFunctions.ItemStolenCallback(Target.Household, Origin.FromTheft);

                    foreach (Sim sim in HouseholdsEx.AllSims(Target.Household))
                    {
                        EventTracker.SendEvent(EventTypeId.kWasRobbed, sim);
                    }
                }
            }

            if (Delta < 0)
            {
                if (OnInvestigateScenario != null)
                {
                    OnInvestigateScenario(this, frame);
                }
            }

            return(true);
        }
Exemplo n.º 50
0
 public static void EnsureTrackingFields(ViewPage page, ControllerConfiguration config)
 {
     EventTracker tracker = new EventTracker();
     tracker.InternalEnsureTrackingFields(page, config);
 }
Exemplo n.º 51
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                UIManager.BlackBackground(false);

                msg += "A1";
                Traveler.InsanityWriteLog(msg);

                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;

                // InWorldSubState:Startup()
                while (sDelayNextStateStartupCount > 0x0)
                {
                    SpeedTrap.Sleep();
                }

                msg += "A2";
                Traveler.InsanityWriteLog(msg);

                EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

                //base.Startup();

                msg += "A3";
                Traveler.InsanityWriteLog(msg);

                ShowUI(true);

                if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning())
                {
                    CameraController.EnableCameraMapView(true);
                }

                msg += "B";
                Traveler.InsanityWriteLog(msg);

                CASExitLoadScreen.Close();

                bool traveling = false;
                if (GameStates.IsTravelling)
                {
                    if (GameStates.sTravelData == null)
                    {
                        GameStates.ClearTravelStatics();
                    }
                    else
                    {
                        traveling = true;
                        GameStatesEx.OnArrivalAtVacationWorld();
                    }
                }

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                if (GameStates.sNextSimToSelect != null)
                {
                    DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true);
                    GameStates.sNextSimToSelect = null;
                }

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                bool flag2 = false;
                if (LoadingScreenController.Instance != null)
                {
                    if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null))
                    {
                        msg += "D1";
                        Traveler.InsanityWriteLog(msg);

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                    }
                    else if (traveling)
                    {
                        msg += "D2";
                        Traveler.InsanityWriteLog(msg);

                        uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex();
                        if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0))
                        {
                            msg += "D3";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, false);
                            ShowUI(false);
                            ShowMaptags(false);

                            msg += "D4";
                            Traveler.InsanityWriteLog(msg);

                            AudioManager.MusicMode = MusicMode.Flyby;
                            CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent;
                            CameraController.StartFlyThrough(customFlyThroughIndex, false);
                            flag2 = true;

                            msg += "D5";
                            Traveler.InsanityWriteLog(msg);

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            while (LoadingScreenController.Instance != null)
                            {
                                Sleep(0.0);
                            }
                        }
                        else
                        {
                            msg += "D6";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, true);
                            Camera.SetView(CameraView.SimView, true, true);
                        }
                    }
                    else
                    {
                        msg += "D7";
                        Traveler.InsanityWriteLog(msg);

                        Camera.RestorePersistedState();

                        msg += "D8";
                        Traveler.InsanityWriteLog(msg);

                        WaitForLotLoad(false, true);
                    }
                }
                else if (traveling)
                {
                    msg += "D9";
                    Traveler.InsanityWriteLog(msg);

                    WaitForLotLoad(!GameUtils.IsUniversityWorld(), true);
                    Camera.SetView(CameraView.SimView, true, true);
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
                if (!flag2)
                {
                    GameUtils.Unpause();
                }

                if (AudioManager.MusicMode != MusicMode.Flyby)
                {
                    AudioManager.MusicMode = MusicMode.None;
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                InWorldSubState.EdgeScrollCheck();
                InWorldSubState.OpportunityDialogCheck();

                try
                {
                    DreamsAndPromisesManager.ValidateLifetimeWishes();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }

                LifeEventManager.ValidatePendingLifeEvents();
                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor);
                }

                if (GameUtils.GetCurrentWorldType() == WorldType.Base)
                {
                    Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor);
                }

                if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson)
                {
                    Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor);
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);

                Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor);

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        WorldData.MergeFromCrossWorldData();
                    }

                    if (selectedActor.LotHome != null)
                    {
                        if (selectedActor.LotHome.HasVirtualResidentialSlots)
                        {
                            Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor);
                        }
                    }
                    else
                    {
                        Lot lot = Helpers.TravelUtilEx.FindLot();
                        if (lot != null)
                        {
                            lot.MoveIn(selectedActor.Household);

                            foreach (SimDescription sim in Households.All(selectedActor.Household))
                            {
                                if (sim.CreatedSim == null)
                                {
                                    FixInvisibleTask.Perform(sim, false);
                                }
                                else
                                {
                                    bool replace = (sim.CreatedSim == selectedActor);

                                    ResetSimTask.Perform(sim.CreatedSim, false);

                                    if (replace)
                                    {
                                        selectedActor = sim.CreatedSim;
                                    }
                                }
                            }

                            msg += "MoveIn";
                        }
                    }

                    if (selectedActor.Household != null)
                    {
                        foreach (SimDescription description in Households.Humans(selectedActor.Household))
                        {
                            // Custom
                            if (GameStates.sMovingWorldData != null)
                            {
                                CrossWorldControl.Restore(description);
                            }

                            if (description.Child || description.Teen)
                            {
                                Tutorialette.TriggerLesson(Lessons.Pranks, null);
                                break;
                            }
                        }
                    }

                    if (selectedActor.BuffManager != null)
                    {
                        BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                        if (element != null)
                        {
                            BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false);
                        }
                    }

                    if (selectedActor.CareerManager != null)
                    {
                        selectedActor.CareerManager.UpdateCareerUI();
                    }

                    if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8))
                    {
                        Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone();
                    }
                }

                msg += "H";
                Traveler.InsanityWriteLog(msg);

                // Custom
                if (GameStates.sMovingWorldData != null)
                {
                    GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims());

                    foreach (SimDescription sim in Households.All(Household.ActiveHousehold))
                    {
                        MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                            if (miniSim.HomeWorld != GameUtils.GetCurrentWorld())
                            {
                                miniSim.HomeWorld = GameUtils.GetCurrentWorld();
                            }
                        }

                        if (sim.HomeWorld != GameUtils.GetCurrentWorld())
                        {
                            sim.HomeWorld = GameUtils.GetCurrentWorld();
                        }
                    }
                }

                GameStates.SetupPostMoveData();
                GameStates.ClearMovingData();
                MovingWorldsWizardCheck();

                // Custom
                Household.IsTravelImport = false;

                InWorldSubStateEx.PlaceLotWizardCheck(this);

                msg += "I";
                Traveler.InsanityWriteLog(msg);

                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.HasBeenDestroyed)
                        {
                            continue;
                        }

                        OccultManager occultManager = sim.OccultManager;
                        if (occultManager != null)
                        {
                            occultManager.RestoreOccultIfNecessary();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += "J";
                Traveler.InsanityWriteLog(msg);

                // Custom
                foreach (SimDescription description in SimListing.GetResidents(false).Values)
                {
                    if (description.LotHome == null)
                    {
                        continue;
                    }

                    MiniSimDescription miniSimDescription = description.GetMiniSimDescription();
                    if (miniSimDescription != null)
                    {
                        miniSimDescription.LotHomeId = description.LotHome.LotId;
                    }
                }

                msg += "K";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                CASExitLoadScreen.Close();
            }
        }
        public void SendingEventsFromTwoDifferentUsersShowsUpAsTwoActiveSessionsInUniversalAnalytics()
        {
            //you actually have to watch the analytics property to see this one happening. No assertion necessary.
            EventTracker eventTracker = new EventTracker();

            IUniversalAnalyticsEvent analyticsEventForUser1 = eventFactory.MakeUniversalAnalyticsEvent(
                    "test user 1",
                    "rate limit test category",
                    "rate limit test action",
                    "rate limit test lable");
            eventTracker.TrackEvent(analyticsEventForUser1);

            IUniversalAnalyticsEvent analyticsEventForUser2 = eventFactory.MakeUniversalAnalyticsEvent(
                "test user 2",
                "test category",
                "test action",
                "test label");
            eventTracker.TrackEvent(analyticsEventForUser2);
        }