public override bool Run() { try { if (!RouteToWatch()) { return(false); } LowerPriority(); StandardEntry(false); BeginCommodityUpdates(); EnterStateMachine("GenericWatch", "Enter", "x"); AnimateSim("NeutralWatchLoop"); mFriendGainAlarm = Target.AddAlarmRepeating(MinutesForLikingGain, TimeUnit.Minutes, new AlarmTimerCallback(GainFriendly), MinutesForLikingGain, TimeUnit.Minutes, "Friendship Gain for Watch Perform for Tips", AlarmType.AlwaysPersisted); bool succeeded = false; if (Target.PlayingForTips) { mTipChancePerCheck = Target.GetChanceForATip(Target.DJOwnerSim); foreach (TraitNames names in TraitsLessLikelyToTip) { if (Actor.TraitManager.HasElement(names)) { mTipChancePerCheck *= LessLikelyToTipMultiplier; } } foreach (TraitNames names2 in TraitsMoreLikelyToTip) { if (Actor.TraitManager.HasElement(names2)) { mTipChancePerCheck *= MoreLikelyToTipMultiplier; } } } mShouldReactNow = false; mGoalTimeToTestTip = TimePerTipTest; succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), WatchLoopEx, mCurrentStateMachine); if (mTippingStatus == Tipping.WillTip) { AttemptToGiveATipEx(); } AnimateSim("Exit"); EndCommodityUpdates(succeeded); StandardExit(false); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public override bool Run() { try { mPlayer = Target.ActorsUsingMe[0x0]; bool flag = (mPlayer.Occupation is Music) && (mPlayer.Occupation.Level >= Music.GuitarBonusLevel); DanceFloor danceFloor = null; if (!MusicalInstrument.DoRouteForWatchOrDance(Actor, Target, out danceFloor)) { return(false); } mDanceFloor = danceFloor; if (mDanceFloor != null) { mDanceFloor.AddToUseList(Actor); } mPlayInstance = mPlayer.CurrentInteraction as MusicalInstrument.PlayInstrument <TTarget>; if (mPlayInstance != null) { if (!mPlayInstance.Performing) { return(false); } AddEventListeners(); } if (flag) { BeginCommodityUpdate(CommodityKind.Fun, Music.GuitarBonusFunMultiplier); } BeginCommodityUpdates(); bool success = false; try { AcquireStateMachine(Target.StateMachineName, AnimationPriority.kAPNormal); SetActorAndEnter("x", Actor, "Enter"); AddJamControllerWatchListener(); AnimateSim("Watch"); mbIsWatchingRightNow = true; Target.AddWatcher(); mFriendGainAlarm = Target.AddAlarmRepeating(Tuning.MinutesForLikingGain, TimeUnit.Minutes, new AlarmTimerCallback(GainFriendly), Tuning.MinutesForLikingGain, TimeUnit.Minutes, "Friendship Gain for Watch Music Playing", AlarmType.AlwaysPersisted); MusicSkill element = mPlayer.SkillManager.GetElement(Target.SkillName) as MusicSkill; if (element != null) { element.BeingWatched(); } if (Target.mPlayingForTips && (Actor.IsOutside || Actor.LotCurrent.IsCommunityLot)) { mTipChancePerCheck = Tuning.ChanceOfTipPerLevel[element.SkillLevel]; foreach (TraitNames names in Tuning.TraitsLessLikelyToTip) { if (Actor.TraitManager.HasElement(names)) { mTipChancePerCheck *= Tuning.LessLikelyToTipMultiplier; } } foreach (TraitNames names2 in Tuning.TraitsMoreLikelyToTip) { if (Actor.TraitManager.HasElement(names2)) { mTipChancePerCheck *= Tuning.MoreLikelyToTipMultiplier; } } mGoalTimeToTestTip = Tuning.TimePerTipTest; timeTillTip = RandomUtil.RandomFloatGaussianDistribution(Target.Tuning.ShortestSongLengthForTip, Target.Tuning.LongestSongLengthForTip); success = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new Interaction <Sim, TTarget> .InsideLoopFunction(TippingLoop), mCurrentStateMachine); } else { success = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new Interaction <Sim, TTarget> .InsideLoopFunction(WatchLoopBase), mCurrentStateMachine); } Target.RemoveAlarm(mFriendGainAlarm); Target.RemoveWatcher(); SongFinished(true, mTryToTip); RemoveJamControllerWatchListener(); if (mPlayInstance != null) { RemoveEventListeners(); mPlayInstance = null; } } finally { EndCommodityUpdates(success); } return(success); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public override bool Run() { try { PerformanceCareer occupationAsPerformanceCareer = Target.OccupationAsPerformanceCareer; if (occupationAsPerformanceCareer != null) { if (!RouteToWatch()) { return(false); } if (!occupationAsPerformanceCareer.PlayingForTips) { return(false); } PerformanceCareer.PerformerPerformForTips currentInteraction = Target.CurrentInteraction as PerformanceCareer.PerformerPerformForTips; if (currentInteraction == null) { return(false); } LowerPriority(); if (currentInteraction.IsPerforming()) { AddEventListeners(); StandardEntry(false); BeginCommodityUpdates(); EnterStateMachine("GenericWatch", "Enter", "x"); AnimateSim("NeutralWatchLoop"); mFriendGainAlarm = Target.AddAlarmRepeating(occupationAsPerformanceCareer.Tuning.MinutesForLikingGain, TimeUnit.Minutes, new AlarmTimerCallback(GainFriendly), occupationAsPerformanceCareer.Tuning.MinutesForLikingGain, TimeUnit.Minutes, "Friendship Gain for Watch Perform for Tips", AlarmType.AlwaysPersisted); bool succeeded = false; mTipChancePerCheck = occupationAsPerformanceCareer.Tuning.ChanceOfTipPerCareerLevel[occupationAsPerformanceCareer.CareerLevel]; foreach (TraitNames names in occupationAsPerformanceCareer.Tuning.TraitsLessLikelyToTip) { if (Actor.TraitManager.HasElement(names)) { mTipChancePerCheck *= occupationAsPerformanceCareer.Tuning.LessLikelyToTipMultiplier; } } foreach (TraitNames names2 in occupationAsPerformanceCareer.Tuning.TraitsMoreLikelyToTip) { if (Actor.TraitManager.HasElement(names2)) { mTipChancePerCheck *= occupationAsPerformanceCareer.Tuning.MoreLikelyToTipMultiplier; } } mShouldReactNow = false; mItsAGoodTimeToTip = false; mGoalTimeToTestTip = occupationAsPerformanceCareer.Tuning.TimePerTipTest; succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), WatchLoopEx, mCurrentStateMachine); if (mTippingStatus == Tipping.WillTip) { // Custom AttemptToGiveATipEx(); } AnimateSim("Exit"); EndCommodityUpdates(succeeded); StandardExit(false); return(succeeded); } } return(false); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }