Esempio n. 1
0
            public override bool Test(Sim a, AthleticGameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (isAutonomous)
                {
                    if (TrainableSim.Service != null)
                    {
                        return(false);
                    }
                }

                if (SkillBasedCareerBooter.GetSkillBasedCareer(a, SkillNames.Athletic) == null)
                {
                    return(false);
                }

                if ((!target.CanObjectTrainSim() || (a.SkillManager.GetSkillLevel(SkillNames.Athletic) >= AthleticGameObject.TrainSim.AthleticSkillLevelGate)) || ((target.ActorsUsingMe.Count != 0x0) || isAutonomous))
                {
                    return(false);
                }

                if (target.Cardio)
                {
                    return(AthleticGameObject.WorkOut.CardioSingleton.CreateInstance(target, TrainableSim, a.InheritedPriority(), false, true).Test());
                }
                return(AthleticGameObject.WorkOut.StrengthSingleton.CreateInstance(target, TrainableSim, a.InheritedPriority(), false, true).Test());
            }
Esempio n. 2
0
        protected static ListenerAction StoppedWorkingOut(Event e)
        {
            Sim sim = e.Actor as Sim;

            if (sim != null)
            {
                //Treadmill tm = e.TargetObject as Treadmill;
                //WorkoutBench wb = e.TargetObject as WorkoutBench;
                //AthleticGameObject s = e.TargetObject as AthleticGameObject;

                //if (tm != null || wb != null || s != null)
                AthleticGameObject ao = e.TargetObject as AthleticGameObject;

                if (ao != null && sim.LotCurrent != null)
                {
                    //Only pay if you are at gym or pool lot type
                    if (sim.LotCurrent.CommercialLotSubType == CommercialLotSubType.kGym || sim.LotCurrent.CommercialLotSubType == CommercialLotSubType.kPool)
                    {
                        CommonMethods.PayForWorkOut(sim, sim.LotCurrent, CommonMethods.ReturnFee(CommonMethods.WorkOut.WorkOut));
                    }
                }
            }

            return(ListenerAction.Keep);
        }
Esempio n. 3
0
 public static void OnAccepted(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i)
 {
     try
     {
         AthleticGameObject[] objects = actor.LotCurrent.GetObjects <AthleticGameObject>();
         float maxValue          = float.MaxValue;
         AthleticGameObject obj2 = null;
         foreach (AthleticGameObject obj3 in objects)
         {
             if (!obj3.InUse && obj3.CanObjectTrainSim())
             {
                 float distanceToObject = obj3.GetDistanceToObject(actor);
                 if (distanceToObject < maxValue)
                 {
                     maxValue = distanceToObject;
                     obj2     = obj3;
                 }
             }
         }
         if (obj2 != null)
         {
             QueueUpTrainSim.Definition definition = new QueueUpTrainSim.Definition(target);
             actor.InteractionQueue.AddNext(definition.CreateInstance(obj2, actor, actor.InheritedPriority(), false, true));
         }
     }
     catch (ResetException)
     {
         throw;
     }
     catch (Exception e)
     {
         Common.Exception(actor, target, e);
     }
 }
Esempio n. 4
0
 public override void AddInteractions(InteractionObjectPair iop, Sim actor, AthleticGameObject target, List<InteractionObjectPair> results)
 {
     foreach (Sim sim in actor.LotCurrent.GetSims())
     {
         if ((actor != sim) && sim.SimDescription.TeenOrAbove)
         {
             results.Add(new InteractionObjectPair(new Definition(sim.SimDescription.FirstName, new string[] { AthleticGameObject.QueueUpTrainSim.LocalizeString(actor.IsFemale, "TrainSimMenuText", new object[0x0]) }, sim), iop.Target));
         }
     }
 }
Esempio n. 5
0
        protected bool OnSecondAction(Sim a, Sim b, GoToLotSituation.MeetUp meetUp, Sim actor, float x)
        {
            if (mPushed)
            {
                return(false);
            }
            mPushed = true;

            InteractionInstance interactionB = b.InteractionQueue.GetCurrentInteraction();

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

            AthleticGameObject choice = interactionB.Target as AthleticGameObject;

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

            if ((a.InteractionQueue.HasInteractionOfType(QueueTrainSimEx.Singleton)) ||
                (a.InteractionQueue.HasInteractionOfType(AthleticGameObject.TrainSim.Singleton)))
            {
                return(true);
            }

            a.InteractionQueue.CancelAllInteractions();

            QueueTrainSimEx train = meetUp.ForceSituationSpecificInteraction(choice, a, QueueTrainSimEx.Singleton, null, meetUp.OnSocialSucceeded, meetUp.OnSocialFailed, new InteractionPriority(InteractionPriorityLevel.UserDirected)) as QueueTrainSimEx;

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

            StoryProgression.Main.Skills.Post(new ReportScenario(a.SimDescription, b.SimDescription));

            train.Trainee = b;
            return(true);
        }
Esempio n. 6
0
        protected bool FirstAction(GoToLotSituation parent, GoToLotSituation.MeetUp meetUp)
        {
            try
            {
                List <AthleticGameObject> choices = new List <AthleticGameObject>(parent.mLot.GetObjects <AthleticGameObject>(TestObject));
                if (choices.Count == 0)
                {
                    return(false);
                }

                InteractionInstance interaction = parent.mSimB.InteractionQueue.GetCurrentInteraction();
                if ((interaction != null) && (interaction.Target is AthleticGameObject))
                {
                    OnSecondAction(parent.mSimA, parent.mSimB, meetUp, parent.mSimB, 0);
                }
                else
                {
                    AthleticGameObject choice = RandomUtil.GetRandomObjectFromList(choices);

                    GoToLotSituation.Action startUp = new GoToLotSituation.Action(meetUp, OnSecondAction);

                    parent.mSimB.InteractionQueue.CancelAllInteractions();

                    if (choice.Cardio)
                    {
                        meetUp.ForceSituationSpecificInteraction(choice, parent.mSimB, AthleticGameObject.WorkOut.CardioSingleton, startUp.OnPerform, meetUp.OnSocialSucceeded, meetUp.OnSocialFailed, new InteractionPriority(InteractionPriorityLevel.UserDirected));
                    }
                    else
                    {
                        meetUp.ForceSituationSpecificInteraction(choice, parent.mSimB, AthleticGameObject.WorkOut.StrengthSingleton, startUp.OnPerform, meetUp.OnSocialSucceeded, meetUp.OnSocialFailed, new InteractionPriority(InteractionPriorityLevel.UserDirected));
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                Common.Exception(parent.mSimA, parent.mSimB, e);
                return(false);
            }
        }
Esempio n. 7
0
            public override bool Test(Sim a, AthleticGameObject target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (isAutonomous)
                {
                    if (TrainableSim.Service != null) return false;
                }

                if (SkillBasedCareerBooter.GetSkillBasedCareer(a, SkillNames.Athletic) == null)
                {
                    return false;
                }

                if ((!target.CanObjectTrainSim() || (a.SkillManager.GetSkillLevel(SkillNames.Athletic) >= AthleticGameObject.TrainSim.AthleticSkillLevelGate)) || ((target.ActorsUsingMe.Count != 0x0) || isAutonomous))
                {
                    return false;
                }

                if (target.Cardio)
                {
                    return AthleticGameObject.WorkOut.CardioSingleton.CreateInstance(target, TrainableSim, a.InheritedPriority(), false, true).Test();
                }
                return AthleticGameObject.WorkOut.StrengthSingleton.CreateInstance(target, TrainableSim, a.InheritedPriority(), false, true).Test();
            }
Esempio n. 8
0
        public static bool TestObject(AthleticGameObject obj)
        {
            if (obj.InUse)
            {
                return(false);
            }

            if (!obj.CanObjectTrainSim())
            {
                return(false);
            }

            if (obj.LotCurrent == null)
            {
                return(false);
            }

            if (!obj.InWorld)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
        public static void OnLeveled(Event e)
        {
            HasGuidEvent <SkillNames> skillEvent = e as HasGuidEvent <SkillNames>;

            if (skillEvent == null)
            {
                return;
            }

            if (skillEvent.Guid != SkillNames.Athletic)
            {
                return;
            }

            Sim actor = e.Actor as Sim;

            if (actor == null)
            {
                return;
            }

            if (actor.InteractionQueue == null)
            {
                return;
            }

            InteractionInstance interaction = actor.InteractionQueue.GetCurrentInteraction();

            if (interaction == null)
            {
                return;
            }

            AthleticGameObject gameobj = interaction.Target as AthleticGameObject;

            if (gameobj == null)
            {
                return;
            }

            Sim trainer = gameobj.OtherActor(actor);

            if (trainer == null)
            {
                return;
            }

            if (trainer.Household == actor.Household)
            {
                return;
            }

            float cash = GetPay(trainer);

            if (cash == 0)
            {
                return;
            }

            cash *= 2;

            if (sAccrued.ContainsKey(actor.SimDescription.SimDescriptionId))
            {
                sAccrued[actor.SimDescription.SimDescriptionId] += cash;
            }
            else
            {
                sAccrued.Add(actor.SimDescription.SimDescriptionId, cash);
            }
        }
Esempio n. 10
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Occupation occupation = Occupation;

            if (occupation is PrivateEye)
            {
                return(ProgressPrivateEye(occupation));
            }
            else if (occupation is Stylist)
            {
                if (!Test(Sim.CreatedSim, DraftingTable.Research.SingletonStylist))
                {
                    return(false);
                }

                Add(frame, new DraftingPushScenario(Sim), ScenarioResult.Start);
                return(true);
            }
            else if (occupation is InteriorDesigner)
            {
                if (!Test(Sim.CreatedSim, DraftingTable.Research.SingletonStylist))
                {
                    return(false);
                }

                Add(frame, new DraftingPushScenario(Sim), ScenarioResult.Start);
                return(true);
            }
            else if (occupation is GhostHunter)
            {
                return(ProgressJobBased(occupation as ActiveCareer));
            }
            else if (occupation is ActiveFireFighter)
            {
                if (Sim.CreatedSim.GetSituationOfType <FirefighterSituation>() != null)
                {
                    IncStat("In Situation");
                    return(true);
                }

                if ((Household.ActiveHousehold == null) || (Household.ActiveHousehold.LotHome == null))
                {
                    IncStat("No Active Household");
                    return(true);
                }

                if (occupation.ActiveCareerLotID != Sim.CreatedSim.LotCurrent.LotId)
                {
                    return(Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.None, occupation.GetInteractionToTakeSimToWork()));
                }

                if (Sim.CreatedSim.InteractionQueue.HasInteractionOfType(AthleticGameObject.WorkOut.Singleton))
                {
                    IncStat("Relax");

                    Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
                    return(true);
                }

                bool activeFirefighter = false;

                if (!GetValue <AllowInactiveFireRepairOption, bool>())
                {
                    foreach (Sim sim in HouseholdsEx.AllSims(Household.ActiveHousehold))
                    {
                        if (sim.Occupation is ActiveFireFighter)
                        {
                            activeFirefighter = true;
                            break;
                        }
                    }
                }

                if ((!activeFirefighter) && (RandomUtil.CoinFlip()))
                {
                    List <GameObject> objs = new List <GameObject>();

                    foreach (GameObject obj in Sim.CreatedSim.LotCurrent.GetObjects <GameObject>())
                    {
                        if (obj.MaintenenceComponent == null)
                        {
                            continue;
                        }

                        objs.Add(obj);
                    }

                    if (objs.Count == 0)
                    {
                        IncStat("No Maintain Objects");
                        return(false);
                    }

                    IncStat("Maintain");

                    GameObject choice = RandomUtil.GetRandomObjectFromList(objs);

                    choice.MaintenenceComponent.MaintenanceLevel = 0;

                    return(Situations.PushInteraction <GameObject>(this, Sim, choice, MaintenanceComponent.MaintainObject.Singleton));
                }
                else
                {
                    List <AthleticGameObject> objs = new List <AthleticGameObject>();

                    foreach (AthleticGameObject obj in Sim.CreatedSim.LotCurrent.GetObjects <AthleticGameObject>())
                    {
                        objs.Add(obj);
                    }

                    if (objs.Count == 0)
                    {
                        IncStat("No Gym Objects");
                        return(false);
                    }

                    IncStat("Workout");

                    AthleticGameObject choice = RandomUtil.GetRandomObjectFromList(objs);

                    return(Situations.PushInteraction <AthleticGameObject>(this, Sim, choice, AthleticGameObject.WorkOut.Singleton));
                }
            }

            return(false);
        }
Esempio n. 11
0
 public override void AddInteractions(InteractionObjectPair iop, Sim actor, AthleticGameObject target, List <InteractionObjectPair> results)
 {
     foreach (Sim sim in actor.LotCurrent.GetSims())
     {
         if ((actor != sim) && sim.SimDescription.TeenOrAbove)
         {
             results.Add(new InteractionObjectPair(new Definition(sim.SimDescription.FirstName, new string[] { AthleticGameObject.QueueUpTrainSim.LocalizeString(actor.IsFemale, "TrainSimMenuText", new object[0x0]) }, sim), iop.Target));
         }
     }
 }