Пример #1
0
        public override bool InRabbitHole()
        {
            try
            {
                ResourceKey key;
                Definition  interactionDefinition = InteractionDefinition as Definition;
                if (Horse == null)
                {
                    return(false);
                }

                BeginCommodityUpdates();
                if (ThumbnailManager.GeneratePromPicture(Horse.ObjectId.Value, Actor.ObjectId.Value, ThumbnailSizeMask.ExtraLarge, out key))
                {
                    mEquestrianRaceThumbnail = key;
                }

                mCompetitionType  = interactionDefinition.CompetitionType;
                mCompetitionLevel = interactionDefinition.CompetitionLevel;
                mCompetitionName  = Target.GetCompetitionName(mCompetitionType, mCompetitionLevel);
                SetCompetitorsNames();
                ShowCompetitionTNS(mCompetitionType, mCompetitionLevel, mCompetitionName);
                Target.mSimInEquestrianCompetition = true;

                // Custom
                if (SimTypes.IsSelectable(Actor))
                {
                    mbShowCompetitionUI = true;
                    Responder.Instance.HudModel.ShowCompetitionPanel();
                }

                if (!DoTimedLoop(EquestrianCenter.kTimeBeforeCompetitionStartsAfterEntering))
                {
                    Target.mSimInEquestrianCompetition = false;
                    mbShowCompetitionUI = false;
                    Actor.ShowTNSIfSelectable(TNSNames.EquestrianCenterLeftBeforeFinish, null, Actor, new object[] { Actor, Horse });
                    Target.mSimInEquestrianCompetition = false;
                    EndCommodityUpdates(false);
                    return(false);
                }

                if (Actor.IsActiveSim)
                {
                    Audio.StartSound("rhole_eques_comp_start");
                }
                FreezeRiderMotives(Actor);
                FreezeHorseMotives(Horse);
                Responder.Instance.HudModel.TriggerProgressBarGlow(this);
                EventTracker.SendEvent(new HorseCompetitionEvent(Actor, Horse, EventTypeId.kEnteredHorseCompetition, mCompetitionType, mCompetitionLevel));
                EventTracker.SendEvent(new HorseCompetitionEvent(Horse, Actor, EventTypeId.kEnteredHorseCompetition, mCompetitionType, mCompetitionLevel));
                mMoodScoreBonus = CalculateMoodBonus();
                mStartTime      = SimClock.CurrentTime();
                bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), CalculateScoreForRace, mCurrentStateMachine, 0.5f);
                EndCommodityUpdates(succeeded);
                ResumeMotives(Horse);
                ResumeMotives(Actor);

                if (Actor.HasExitReason(ExitReason.Canceled))
                {
                    Actor.ShowTNSIfSelectable(TNSNames.EquestrianCenterLeftBeforeFinish, null, Actor, new object[] { Actor, Horse });
                    Target.mSimInEquestrianCompetition = false;

                    // Custom
                    if (SimTypes.IsSelectable(Actor))
                    {
                        mbShowCompetitionUI = false;
                        Responder.Instance.HudModel.HideCompetitionPanel();
                    }

                    return(false);
                }

                Responder.Instance.HudModel.TriggerProgressBarGlow(this);
                ShowCompetitionEndScoreEx(mCompetitionType, mCompetitionLevel, mCompetitionName);
                DoTimedLoop(EquestrianCenter.kTimeAfterCompetitionForUI, ExitReason.Canceled);
                Target.mSimInEquestrianCompetition = false;

                // Custom
                if (SimTypes.IsSelectable(Actor))
                {
                    mbShowCompetitionUI = false;
                    Responder.Instance.HudModel.HideCompetitionPanel();
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }