static void World_OnWorldLoadFinishedEventHandler(object sender, EventArgs e) { List <HotBeverageMachine> coffeeMachines = new List <HotBeverageMachine>(Sims3.Gameplay.Queries.GetObjects <HotBeverageMachine>()); foreach (HotBeverageMachine machine in coffeeMachines) { AddInteractionsForCoffeeMaker(machine); } EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(AddCoffeeMenu.OnNewObject)); EventTracker.AddListener(EventTypeId.kBoughtObjectAtRabbithole, new ProcessEventDelegate(AddCoffeeMenu.OnNewObject)); //Add the interaction to all trays if it's not there already List <BarTray> coffeeTrays = new List <BarTray>(Sims3.Gameplay.Queries.GetObjects <BarTray>()); foreach (BarTray bt in coffeeTrays) { foreach (Slot slot in bt.GetContainmentSlots()) { Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup cup = bt.GetContainedObject(slot) as Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup; if (cup != null && !cup.FoodName.Equals("Juice") && !cup.FoodName.Equals("Nectar")) { //Add cup interactions cup.RemoveAllInteractions(); cup.AddInteraction(DrinkCoffee.Drink.Singleton); AddInteractionForTray(bt); } } } }
public override bool Run() { Route r = base.Actor.CreateRoute(); r.SetOption(Route.RouteOption.DoLineOfSightCheckUserOverride, true); r.PlanToPointRadialRange(base.Target.Position, 0.5f, 3f, Vector3.UnitZ, 360f, RouteDistancePreference.PreferNearestToRouteOrigin, RouteOrientationPreference.TowardsObject); if (!base.Actor.DoRoute(r)) { base.Actor.AddExitReason(ExitReason.RouteFailed); return(false); } if (!base.Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), BarTray.kTimeToWaitInLine)) { return(false); } List <Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup> randomList = new List <Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup>(); foreach (Slot slot in base.Target.GetContainmentSlots()) { Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup containedObject = base.Target.GetContainedObject(slot) as Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup; if ((containedObject != null) && !containedObject.InUse) { randomList.Add(containedObject); } } if (randomList.Count == 0) { return(false); } Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup randomObjectFromList = RandomUtil.GetRandomObjectFromList <Sims3.Gameplay.Objects.Appliances.HotBeverageMachine.Cup>(randomList); if ((randomObjectFromList != null) && CarrySystem.PickUp(base.Actor, randomObjectFromList)) { //Pay for the coffee CommonMethods.PayForCoffee(base.Actor, base.Target.LotCurrent); InteractionInstance instance = EatHeldFood.Singleton.CreateInstance(randomObjectFromList, base.Actor, base.Actor.InheritedPriority(), false, true); return(Actor.InteractionQueue.PushAsContinuation(instance, false)); } return(false); }