Exemplo n.º 1
0
        public InteractionInstance.InsideLoopFunction LoopDelegate(GoToSchoolInRabbitHole interaction, AfterschoolActivity activity)
        {
            try
            {
                if (mLoop != null)
                {
                    InteractionInstance.InsideLoopFunction del = (InteractionInstance.InsideLoopFunction)mLoop.Invoke(null, new object[] { interaction, activity });
                    if (del != null)
                    {
                        return(del);
                    }
                }

                return(interaction.AfterschoolActivityLoopDelegate);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(interaction.Actor, interaction.Target, e);
                return(null);
            }
        }
Exemplo n.º 2
0
            public override bool InRabbitHole()
            {
                try
                {
                    if (!GoToSchoolInRabbitHoleHelper.PreInRabbitholeLoop(this, true))
                    {
                        return(false);
                    }

                    bool succeeded = DoLoop(ExitReason.StageComplete, LoopDelegate, null);

                    AfterschoolActivity activity = null;
                    bool hasAfterschoolActivity  = false;

                    bool detention = false;
                    bool fieldTrip = false;

                    GoToSchoolInRabbitHoleHelper.PostInRabbitHoleLoop(this, ref succeeded, ref detention, ref fieldTrip, ref activity, ref hasAfterschoolActivity);

                    if (detention && !fieldTrip)
                    {
                        succeeded = DoLoop(ExitReason.StageComplete, LoopDelegate, null);
                    }

                    InteractionInstance.InsideLoopFunction afterSchoolLoop = null;
                    GoToSchoolInRabbitHoleHelper.PostDetentionLoop(this, succeeded, detention, fieldTrip, activity, hasAfterschoolActivity, ref afterSchoolLoop);

                    if (afterSchoolLoop != null)
                    {
                        succeeded = DoLoop(ExitReason.StageComplete, afterSchoolLoop, mCurrentStateMachine);
                    }
                    else
                    {
                        succeeded = DoLoop(ExitReason.StageComplete);
                    }

                    GoToSchoolInRabbitHoleHelper.PostAfterSchoolLoop(this, succeeded, activity, afterSchoolLoop);

                    return(succeeded);
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.Exception(Actor, Target, e);
                    return(false);
                }
            }
Exemplo n.º 3
0
        public static void PostAfterSchoolLoop(GoToSchoolInRabbitHole ths, bool succeeded, AfterschoolActivity activity, InteractionInstance.InsideLoopFunction afterSchoolLoop)
        {
            try
            {
                if (afterSchoolLoop != null)
                {
                    ths.Target.ClearAmbientSounds(ths.Target);
                    ths.Target.AddAmbientSound("rhole_school_oneshot");

                    foreach (SkillNames names in activity.ActivitySkillNameList)
                    {
                        ths.Actor.SkillManager.StopSkillGain(names);
                    }

                    if (!sCareerPerformAfterschoolPostLoop.Invoke <bool>(new object[] { ths, activity }))
                    {
                        if (activity.CurrentActivityType == AfterschoolActivityType.ArtClub)
                        {
                            activity.CheckForNewPainting(ths.Actor);
                        }
                    }

                    ISchoolRabbitHole target = GetTarget(ths);

                    target.HasAfterschoolActivityToday = false;
                }

                ths.Actor.School.FinishWorking();

                ths.EndCommodityUpdates(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
            }
        }
Exemplo n.º 4
0
        public static void PostDetentionLoop(GoToSchoolInRabbitHole ths, bool succeeded, bool detention, bool fieldTrip, AfterschoolActivity activity, bool hasAfterschoolActivity, ref InteractionInstance.InsideLoopFunction afterSchoolLoop)
        {
            try
            {
                School school = ths.Actor.School;

                ISchoolRabbitHole target = GetTarget(ths);

                bool flag5 = false;
                bool flag6 = false;
                if (!fieldTrip && !detention)
                {
                    if (hasAfterschoolActivity)
                    {
                        flag5 = true;
                    }
                    else if (!ths.Actor.IsInActiveHousehold && target.HasAfterschoolActivityToday)
                    {
                        flag5 = RandomUtil.CoinFlip();
                        flag6 = true;
                    }
                }

                if (!flag5)
                {
                    school.FinishWorking();

                    ths.EndCommodityUpdates(succeeded);
                    return;
                }

                CommodityChange fun = new CommodityChange(CommodityKind.Fun, 50, false, 25, OutputUpdateType.ContinuousFlow, false, false, UpdateAboveAndBelowZeroType.Either);

                ths.BeginCommodityUpdate(fun, 1);

                ths.mParticipatedInAfterschoolActivity = true;
                string str  = flag6 ? AfterschoolActivityType.ArtClub.ToString() : activity.CurrentActivityType.ToString();
                float  num3 = (school.DayLength + Career.kNumHoursEarlyCanShowUpForWork) + AfterschoolActivity.kAfterschoolActivityLength;

                string name = null;
                if (Localization.HasLocalizationString("Gameplay/Careers/AfterschoolActivity:" + str))
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Careers/AfterschoolActivity:" + str);
                }
                else
                {
                    name = Common.LocalizeEAString(ths.Actor.IsFemale, "Gameplay/Abstracts/Careers/AfterschoolActivity:" + str);
                }

                TimeOfDayStage stage2 = new TimeOfDayStage(name, school.CurLevel.FinishTime() + AfterschoolActivity.kAfterschoolActivityLength, num3);
                ths.Stages      = new List <Stage>(new Stage[] { stage2 });
                ths.ActiveStage = stage2;
                ths.SetAvailableTones(null);
                ths.Actor.RemoveExitReason(ExitReason.StageComplete);

                if (!flag6)
                {
                    activity.StartSkillGainForActivity(ths.Actor);

                    activity.StartAmbientSounds(ths.Actor, ths.Target);

                    if (!sCareerPerformAfterschoolPreLoop.Invoke <bool>(new object[] { ths, activity }))
                    {
                        if (activity.CurrentActivityType == AfterschoolActivityType.StudyClub)
                        {
                            school.AddHomeworkToStudent(false);
                            ths.mHomework = school.OwnersHomework;
                            if (ths.mHomework != null)
                            {
                                school.DidHomeworkInStudyClubToday = true;
                                ths.mHomework.PercentComplete      = 0f;
                                ths.mHomeworkCompletionRate        = ths.mHomework.GetCompletionRate(ths.Actor, false, true);
                            }
                        }
                    }

                    ths.mLastLTRUpdateDateAndTime = SimClock.CurrentTime();

                    afterSchoolLoop = sCareerPerformAfterschoolLoop.Invoke <InteractionInstance.InsideLoopFunction>(new object[] { ths, activity });
                    if (afterSchoolLoop == null)
                    {
                        afterSchoolLoop = ths.AfterschoolActivityLoopDelegate;
                    }
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(ths.Actor, ths.Target, e);
            }
        }