Inheritance: Definition, Common.IAddInteraction
Ejemplo n.º 1
0
 public override bool Run()
 {
     if (!base.Actor.RouteToObjectRadialRange(base.Target, 0f, base.Target.MaxProximityBeforeSwiping()))
     {
         //Honestly just plain annoying to watch, especially since sims love this interaction so much
         //base.Actor.PlayRouteFailure();
         return false;
     }
     base.Actor.RouteTurnToFace(base.Target.Position);
     base.StandardEntry();
     base.BeginCommodityUpdates();
     List<ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
     RandomUtil.RandomizeListOfObjects<ObjectGuid>(objectsICanBuyInDisplay);
     for (int i = 0; base.Actor.HasNoExitReason() && (i < objectsICanBuyInDisplay.Count); i++)
     {
         ObjectGuid guid = objectsICanBuyInDisplay[i];
         GameObject target = GlobalFunctions.ConvertGuidToObject<GameObject>(guid);
         if (target != null)
         {
             base.Actor.RouteTurnToFace(target.Position);
             int priority = 100;
             base.Actor.LookAtManager.SetInteractionLookAt(target, priority, LookAtJointFilter.HeadBones | LookAtJointFilter.TorsoBones);
             bool flag = RandomUtil.RandomChance01(CraftersConsignment.kBrowseChanceOfDislikingObject);
             ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(target.GetThumbnailKey());
             if (flag)
             {
                 bd.LowAxis = ThoughtBalloonAxis.kDislike;
             }
             base.Actor.ThoughtBalloonManager.ShowBalloon(bd);
             string state = "1";
             if (flag)
             {
                 state = RandomUtil.GetRandomStringFromList(new string[] { "3", "5", "CantStandArtTraitReaction" });
             }
             else
             {
                 state = RandomUtil.GetRandomStringFromList(new string[] { "0", "1", "2" });
             }
             base.EnterStateMachine("viewobjectinteraction", "Enter", "x");
             base.AnimateSim(state);
             base.AnimateSim("Exit");
             base.Actor.LookAtManager.ClearInteractionLookAt();
         }
     }
     if (base.Autonomous && !base.Actor.IsSelectable)
     {
         float chance = CraftersConsignment.kBrowseBaseChanceOfBuyingObjectWithoutSale + base.Target.mSaleDiscount;
         if (RandomUtil.RandomChance01(chance))
         {
             List<ObjectGuid> randomList = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
             if (randomList.Count > 0)
             {
                 ObjectGuid randomObjectFromList = RandomUtil.GetRandomObjectFromList<ObjectGuid>(randomList);
                 if (randomObjectFromList != ObjectGuid.InvalidObjectGuid)
                 {
                     PurchaseItemEx.Definition continuationDefinition = null;
                     if (Actor.Motives.IsHungry())
                     {
                         PreparedFood food = GlobalFunctions.ConvertGuidToObject<PreparedFood>(randomObjectFromList);
                         if (food != null)
                         {
                             continuationDefinition = new PurchaseItemEx.BuyFoodDefinition(food);
                         }
                     }
                     if (continuationDefinition == null)
                     {
                         continuationDefinition = new PurchaseItemEx.Definition(randomObjectFromList, false);
                     }
                     base.TryPushAsContinuation(continuationDefinition);
                 }
             }
         }
     }
     if (!base.Autonomous)
     {
         List<ObjectGuid> list3 = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
         if (objectsICanBuyInDisplay.Count > 0)
         {
             StringBuilder builder = new StringBuilder();
             builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseItemsForPurchaseHeading", new object[0]));
             for (int j = 0; j < list3.Count; j++)
             {
                 GameObject obj3 = GlobalFunctions.ConvertGuidToObject<GameObject>(list3[j]);
                 if (obj3 != null)
                 {
                     ServingContainer container = obj3 as ServingContainer;
                     if (container != null)
                     {
                         builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { container.CookingProcess.RecipeNameFinal, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                     }
                     else
                     {
                         Common.Notify("BrowseEx for " + obj3.CatalogName);
                         builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { obj3.CatalogName, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                     }
                 }
             }
             base.Actor.ShowTNSIfSelectable(builder.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive);
         }
     }
     base.EndCommodityUpdates(true);
     base.StandardExit();
     return true;
 }
Ejemplo n.º 2
0
        public override bool Run()
        {
            if (!base.Actor.RouteToObjectRadialRange(base.Target, 0f, base.Target.MaxProximityBeforeSwiping()))
            {
                //Honestly just plain annoying to watch, especially since sims love this interaction so much
                //base.Actor.PlayRouteFailure();
                return(false);
            }
            base.Actor.RouteTurnToFace(base.Target.Position);
            base.StandardEntry();
            base.BeginCommodityUpdates();
            List <ObjectGuid> objectsICanBuyInDisplay = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);

            RandomUtil.RandomizeListOfObjects <ObjectGuid>(objectsICanBuyInDisplay);
            for (int i = 0; base.Actor.HasNoExitReason() && (i < objectsICanBuyInDisplay.Count); i++)
            {
                ObjectGuid guid   = objectsICanBuyInDisplay[i];
                GameObject target = GlobalFunctions.ConvertGuidToObject <GameObject>(guid);
                if (target != null)
                {
                    base.Actor.RouteTurnToFace(target.Position);
                    int priority = 100;
                    base.Actor.LookAtManager.SetInteractionLookAt(target, priority, LookAtJointFilter.HeadBones | LookAtJointFilter.TorsoBones);
                    bool flag = RandomUtil.RandomChance01(CraftersConsignment.kBrowseChanceOfDislikingObject);
                    ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(target.GetThumbnailKey());
                    if (flag)
                    {
                        bd.LowAxis = ThoughtBalloonAxis.kDislike;
                    }
                    base.Actor.ThoughtBalloonManager.ShowBalloon(bd);
                    string state = "1";
                    if (flag)
                    {
                        state = RandomUtil.GetRandomStringFromList(new string[] { "3", "5", "CantStandArtTraitReaction" });
                    }
                    else
                    {
                        state = RandomUtil.GetRandomStringFromList(new string[] { "0", "1", "2" });
                    }
                    base.EnterStateMachine("viewobjectinteraction", "Enter", "x");
                    base.AnimateSim(state);
                    base.AnimateSim("Exit");
                    base.Actor.LookAtManager.ClearInteractionLookAt();
                }
            }
            if (base.Autonomous && !base.Actor.IsSelectable)
            {
                float chance = CraftersConsignment.kBrowseBaseChanceOfBuyingObjectWithoutSale + base.Target.mSaleDiscount;
                if (RandomUtil.RandomChance01(chance))
                {
                    List <ObjectGuid> randomList = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
                    if (randomList.Count > 0)
                    {
                        ObjectGuid randomObjectFromList = RandomUtil.GetRandomObjectFromList <ObjectGuid>(randomList);
                        if (randomObjectFromList != ObjectGuid.InvalidObjectGuid)
                        {
                            PurchaseItemEx.Definition continuationDefinition = null;
                            if (Actor.Motives.IsHungry())
                            {
                                PreparedFood food = GlobalFunctions.ConvertGuidToObject <PreparedFood>(randomObjectFromList);
                                if (food != null)
                                {
                                    continuationDefinition = new PurchaseItemEx.BuyFoodDefinition(food);
                                }
                            }
                            if (continuationDefinition == null)
                            {
                                continuationDefinition = new PurchaseItemEx.Definition(randomObjectFromList, false);
                            }
                            base.TryPushAsContinuation(continuationDefinition);
                        }
                    }
                }
            }
            if (!base.Autonomous)
            {
                List <ObjectGuid> list3 = DisplayHelper.GetObjectsICanBuyInDisplay(base.Actor, base.Target);
                if (objectsICanBuyInDisplay.Count > 0)
                {
                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseItemsForPurchaseHeading", new object[0]));
                    for (int j = 0; j < list3.Count; j++)
                    {
                        GameObject obj3 = GlobalFunctions.ConvertGuidToObject <GameObject>(list3[j]);
                        if (obj3 != null)
                        {
                            ServingContainer container = obj3 as ServingContainer;
                            if (container != null)
                            {
                                builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { container.CookingProcess.RecipeNameFinal, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                            }
                            else
                            {
                                Common.Notify("BrowseEx for " + obj3.CatalogName);
                                builder.AppendLine(CraftersConsignment.LocalizeString(base.Actor.IsFemale, "BrowseLineItem", new object[] { obj3.CatalogName, DisplayHelper.ComputeFinalPriceOnObject(list3[j]) }));
                            }
                        }
                    }
                    base.Actor.ShowTNSIfSelectable(builder.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive);
                }
            }
            base.EndCommodityUpdates(true);
            base.StandardExit();
            return(true);
        }