//Performe the random interaction private static void PerformeInteractionOnSelf(Sim sim, InteractionDefinition definition) { InteractionPriority priority = sim.CurrentInteraction.GetPriority(); InteractionInstance instance3 = definition.CreateInstance(sim, sim, priority, false, true); sim.InteractionQueue.Add(instance3); if (AddMenuItem.ReturnShowNotification()) { StyledNotification.Show(new StyledNotification.Format(sim.Name + "\r" + instance3.GetInteractionName(), StyledNotification.NotificationStyle.kGameMessagePositive)); } }
public static void DoInteractionToOthers(Sim sim) { try { Random r = new Random(); //Get Sims on lot List <Sim> sims = ReturnSimsOnLot(sim); if (sims.Count > 0) { int tries = 0; int maxTries = 20; bool success = false; while (!success) { //Get random sim int randomSim = r.Next(sims.Count); Sim targetSim = sims[randomSim]; //Increment tries tries++; if (sim != null && sim.SocialComponent != null && targetSim != null) { List <InteractionObjectPair> pairs = new List <InteractionObjectPair>(); foreach (var item in sim.SocialComponent.GetAllInteractionsForAutonomy(targetSim)) { if (item.CheckIfInteractionValid()) { pairs.Add(item); } } InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.UserDirected); if (sim.CurrentInteraction != null) { priority = sim.CurrentInteraction.GetPriority(); } //IF the sim is not in the active household, raise the priority if (sim.Household != null && !sim.Household.IsActive) { priority = new InteractionPriority(InteractionPriorityLevel.UserDirected); } InteractionInstance instance = pairs[r.Next(pairs.Count)].InteractionDefinition.CreateInstance(targetSim, sim, priority, false, true); if (instance != null) { try { success = sim.InteractionQueue.Add(instance); if (success && AddMenuItem.ReturnShowNotification()) { StyledNotification.Show(new StyledNotification.Format(sim.Name + "\r" + instance.GetInteractionName() + "\r" + targetSim.Name, StyledNotification.NotificationStyle.kGameMessagePositive)); } } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format(sim.Name + "\r" + ex.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive)); } } } //Break off if the interaction is not sticking if (tries == maxTries && !success) { success = true; DoInteractionToSelf(sim); } } } } catch (Exception ex) { sim.ShowTNSIfSelectable(ex.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, sim.ObjectId); } }
public static void DelInteraction(List <InteractionInstance> mInteractionList, Sims3.Gameplay.ActorSystems.InteractionQueue simIQ, Sim sim, int index, bool stopImmediately, bool succeeded) { if (index >= 0 && index < mInteractionList.Count) { InteractionInstance interactionInstance = mInteractionList._items[index]; if (interactionInstance == null) { niec_std.list_remove(mInteractionList, interactionInstance); goto r; } if (simIQ.mIsHeadInteractionLocked && index == 0) { throw new ArgumentException("Sim: " + interactionInstance.InstanceActor.SimDescription.FullName + " is removing head interaction: " + interactionInstance.GetInteractionName() + " while it is locked."); } interactionInstance.OnRemovedFromQueue(index == 0); niec_std.list_remove(mInteractionList, interactionInstance); if (!sim.HasExitReason(ExitReason.SuspensionRequested)) { CleanUpOrOnFailureInteraction(sim, interactionInstance, stopImmediately, succeeded); } if (succeeded || simIQ.mBabyOrToddlerTransitionTargetInteraction == interactionInstance || mInteractionList.Count == 0) { simIQ.mBabyOrToddlerTransitionTargetInteraction = null; } r : if (sim.IsSelectable) { simIQ.FireQueueChanged(); } } }