protected override void PrivatePerform(StateMachineClient smc, InteractionInstance.LoopData loopData) { if (SimClock.ElapsedTime(TimeUnit.Minutes, mInteraction.mLastLTRUpdateDateAndTime) >= GoToSchoolInRabbitHole.kSimMinutesBetweenLTRUpdates) { if (RandomUtil.RandomChance(kBugClubCollectChance)) { List <InsectJig> insects = new List <InsectJig>(Sims3.Gameplay.Queries.GetObjects <InsectJig>()); if (insects.Count > 0) { InsectJig insect = RandomUtil.GetRandomObjectFromList(insects); Terrarium terrarium = InsectTerrarium.Create(insect, mInteraction.Actor); if (terrarium != null) { string msg = Common.Localize("AfterschoolFoundObject:Notice", mInteraction.Actor.IsFemale, new object[] { mInteraction.Actor, terrarium.GetLocalizedName() }); mInteraction.Actor.ShowTNSIfSelectable(msg, StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, terrarium.ObjectId); } } } } mInteraction.AfterschoolActivityLoopDelegate(smc, loopData); }
public override bool Run() { try { InsectData data; Route r = Actor.RoutingComponent.CreateRoute(); r.PlanToPointRadialRange(Target.Position, 0f, InsectJig.sMaxCatchRange, RouteDistancePreference.PreferNearestToRouteDestination, RouteOrientationPreference.TowardsObject, Target.LotCurrent.LotId, null); try { if (!Actor.RoutingComponent.DoRoute(r) || Target.InUse) { return(false); } } catch (ResetException) { throw; } catch (Exception e) { Common.DebugException(Actor, Target, e); return(false); } mDummyIkJig = GlobalFunctions.CreateObjectOutOfWorld("SocialJigOnePerson") as SocialJigOnePerson; mDummyIkJig.SetForward(Actor.ForwardVector); mDummyIkJig.SetPosition(Actor.Position); mDummyIkJig.SetHiddenFlags(~HiddenFlags.Nothing); mDummyIkJig.AddToWorld(); StandardEntry(); BeginCommodityUpdates(); bool succeeded = false; try { if (InsectData.sData.TryGetValue(Target.InsectType, out data)) { mTempInsect = Sims3.Gameplay.Objects.Insect.Insect.Create(Target.InsectType); string jazzInsectParameterName = data.GetJazzInsectParameterName(); string jazzEnterStateName = data.GetJazzEnterStateName(); float catchChance = data.CatchChance; InsectRarity rarity = data.Rarity; data = null; mCurrentStateMachine = InsectData.AcquireInitAndEnterStateMachine(Actor, mTempInsect, mDummyIkJig, jazzInsectParameterName, jazzEnterStateName); if (mCurrentStateMachine != null) { Collecting collecting = Actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting; if (collecting.IsBeetleCollector()) { succeeded = true; } else { succeeded = RandomUtil.RandomChance01(catchChance); } AnimateSim(succeeded ? "ExitSuccess" : "ExitFailure"); if (succeeded) { InsectTerrarium.Create(Target, Actor); } else { ReactionTypes reactionType = RandomUtil.CoinFlip() ? ReactionTypes.Annoyed : (RandomUtil.CoinFlip() ? ReactionTypes.Shrug : ReactionTypes.Angry); Actor.PlayReaction(reactionType, ReactionSpeed.NowOrLater); } } } } finally { EndCommodityUpdates(succeeded); } StandardExit(); DestroyObject(Target); return(succeeded); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }