Beispiel #1
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            Common.StringBuilder msg = new Common.StringBuilder("Run");

            try
            {
                Terrain terrain = parameters.mTarget as Terrain;
                if (terrain != null)
                {
                    foreach (Sim sim in LotManager.Actors)
                    {
                        Common.TestSpan span = Common.TestSpan.CreateSimple();

                        Route r = null;

                        uint simFlags = sim.SimDescription.SimFlags;

                        try
                        {
                            r = Route.Create(sim.Proxy, simFlags);
                        }
                        finally
                        {
                            msg += Common.NewLine + sim.FullName;
                            msg += Common.NewLine + " " + sim.SimDescription.mSimFlags;
                            msg += Common.NewLine + " " + span.Duration;
                        }

                        SimDescription simDescription  = sim.SimDescription;
                        Posture        previousPosture = sim.Posture;

                        SimRoutingComponent routingComponent = sim.RoutingComponent as SimRoutingComponent;

                        bool flag = false;

                        span = Common.TestSpan.CreateSimple();
                        try
                        {
                            //routingComponent.SetRouteOptions(route, simFlags);

                            if (!(sim.CurrentInteraction is IHasCustomRouteOptions))
                            {
                                r.SetOption(Route.RouteOption.BeginAsCar, (sim.Parent is Vehicle) && !(sim.Parent is IBoat));
                                r.SetOption(Route.RouteOption.EnablePlanningAsCar, simDescription.ChildOrAbove);
                                r.SetOption(Route.RouteOption.DisablePlanningAsPedestrian, false);
                                r.SetOption(Route.RouteOption.PushSimsAtDestination, true);
                                r.SetOption(Route.RouteOption.UseAutoSlotFootprintLocking, true);
                                r.SetOption(Route.RouteOption.ReplanToFindObstacleWhenPathPlanFails, true);
                                r.SetOption(Route.RouteOption.IgnoreParent, false);
                                r.SetOption(Route.RouteOption.IgnoreChildren, false);
                                r.SetOption(Route.RouteOption.CreateSubPaths, true);
                                r.SetOption(Route.RouteOption.CheckForFootprintsNearGoals, true);
                                r.SetOption(Route.RouteOption.PenalizeGoalsOnDifferentLevels, true);
                                if (GameUtils.IsInstalled(ProductVersion.EP10))
                                {
                                    IBoat parent = sim.Parent as IBoat;
                                    if (parent != null)
                                    {
                                        flag       = true;
                                        r.Follower = parent.Proxy;
                                        r.FollowerAgeGenderSpecies = (uint)parent.GetBoatSpecies();
                                        r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, true);
                                        r.SetOption2(Route.RouteOption2.BeginAsBoat, true);
                                        r.SetOption2(Route.RouteOption2.UseFollowerStartOrientation, true);
                                        r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                                        r.AddObjectToIgnoreForRoute(sim.ObjectId);
                                    }
                                    bool flag2 = OccultMermaid.IsEveryOneGroupedWithMeATeenOrAboveMermaid(sim);
                                    bool flag3 = false;
                                    if (!flag2)
                                    {
                                        flag3 = ((previousPosture is CarryingChildPosture) || (previousPosture is CarryingPetPosture)) || sim.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation));
                                    }
                                    bool flag4 = simDescription.ChildOrAbove & !(previousPosture is ScubaDiving);
                                    flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.GiveCPR);
                                    flag4 &= !(sim.InteractionQueue.GetHeadInteraction() is Lifeguard.FakeInjury);
                                    flag4 &= !(simDescription.CreatedByService is GrimReaper);
                                    flag4 &= !flag2 || flag3;
                                    flag4 &= !(previousPosture is BeingRiddenPosture) && !(previousPosture is RidingPosture);
                                    bool flag5 = simDescription.ChildOrAbove && simDescription.IsHuman;
                                    flag5 &= !(previousPosture is CarryingChildPosture) && !(previousPosture is CarryingPetPosture);
                                    r.SetOption(Route.RouteOption.EnableWaterPlanning, flag5);
                                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, !flag5);
                                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, (parent != null) || flag4);
                                    if (flag2 && flag5)
                                    {
                                        r.SetOption2(Route.RouteOption2.RouteAsMermaid, true);
                                    }
                                    else
                                    {
                                        r.SetOption2(Route.RouteOption2.RouteAsLifeguard, Lifeguard.ShouldUseRescueSwimWade(sim));
                                    }
                                }

                                // Cut

                                if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP3))
                                {
                                    r.SetOption(Route.RouteOption.EnableSubwayPlanning, true);
                                }
                                if (GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP5) && ((sim.IsWildAnimal || sim.IsStray) || (sim.IsUnicorn || WildHorses.IsWildHorse(sim))))
                                {
                                    r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false);
                                    r.SetOption2(Route.RouteOption2.DestinationMustBeOnLand, true);
                                }
                                if (routingComponent.SimSatisfiesSpecialConditions())
                                {
                                    r.SetOption(Route.RouteOption.PassThroughObjects, true);
                                    r.SetOption(Route.RouteOption.PassThroughWalls, true);
                                }
                                if (sim.HasGhostBuff && !flag)
                                {
                                    r.SetOption(Route.RouteOption.RouteAsGhost, true);
                                }
                                if ((GameUtils.IsInstalled(ProductVersion.Undefined | ProductVersion.EP4) && (sim.CarryingChildPosture != null)) && (Stroller.GetStroller(sim, sim.LotCurrent) != null))
                                {
                                    r.SetOption(Route.RouteOption.PlanUsingStroller, true);
                                }
                                if (sim.IsHuman)
                                {
                                    SwimmingInPool pool = previousPosture as SwimmingInPool;
                                    if (pool != null)
                                    {
                                        if (pool.ContainerIsOcean)
                                        {
                                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                                        }
                                    }
                                    else
                                    {
                                        Ocean.PondAndOceanRoutingPosture posture2 = previousPosture as Ocean.PondAndOceanRoutingPosture;
                                        if ((posture2 != null) && (posture2.WalkStyleToUse == Sim.WalkStyle.Wade))
                                        {
                                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                                        }
                                    }
                                }

                                // Cut

                                if (GameUtils.IsInstalled(ProductVersion.EP8))
                                {
                                    if (SimEx.GetOwnedAndUsableVehicle(sim, sim.LotHome, false, false, false, true) is CarUFO)
                                    {
                                        r.SetOption(Route.RouteOption.EnableUFOPlanning, true);
                                    }

                                    if ((sim.IsHuman && sim.SimDescription.ChildOrAbove) && PondManager.ArePondsFrozen())
                                    {
                                        bool flag6 = true;
                                        while (previousPosture != null)
                                        {
                                            if (previousPosture.Satisfaction(CommodityKind.Standing, null) <= 0f)
                                            {
                                                flag6 = false;
                                                break;
                                            }
                                            previousPosture = previousPosture.PreviousPosture;
                                        }
                                        if (flag6)
                                        {
                                            r.SetOption(Route.RouteOption.EnablePondPlanning, true);
                                        }
                                    }
                                }
                            }
                        }
                        finally
                        {
                            msg += Common.NewLine + " B " + span.Duration;
                        }

                        span = Common.TestSpan.CreateSimple();
                        try
                        {
                            if (!(sim.CurrentInteraction is IHasCustomRouteOptions))
                            {
                                r.ExitReasonsInterrupt = unchecked ((int)0xffa9bfff);
                                if ((0x0 != (simFlags & 0x3)) && !sim.LotCurrent.IsWorldLot)
                                {
                                    r.SetValidRooms(sim.LotCurrent.LotId, null);
                                }
                                if ((sim.IsHorse && sim.SimDescription.AdultOrAbove) && !sim.SimDescription.IsGhost)
                                {
                                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                                }
                                if (((sim.IsHorse || sim.IsDeer) || (sim.IsFullSizeDog && sim.SimDescription.AdultOrAbove)) && !sim.SimDescription.IsGhost)
                                {
                                    r.SetOption(Route.RouteOption.OffsetDestinationForLongAnimals, true);
                                }
                                if (sim.IsHorse && sim.IsInBeingRiddenPosture)
                                {
                                    r.SetOption(Route.RouteOption.RouteWhileMounted, true);
                                }
                                if (previousPosture is LeadingHorsePosture)
                                {
                                    r.SetOption(Route.RouteOption.EnablePlanningAsCar, false);
                                    r.SetOption(Route.RouteOption.RouteAsLargeAnimal, true);
                                    r.SetOption(Route.RouteOption.RouteAsSimLeadingHorse, true);
                                }
                                if (sim.IsPet && !sim.IsInBeingRiddenPosture)
                                {
                                    r.SetOption(Route.RouteOption.IgnoreSidewalkAndLotRestrictions, true);
                                }
                            }

                            //route = sim.CreateRoute();
                        }
                        finally
                        {
                            msg += Common.NewLine + " C " + span.Duration;
                        }
                    }
                }

                AcademicTextBook book = parameters.mTarget as AcademicTextBook;
                if (book != null)
                {
                    Sim a = parameters.mActor as Sim;

                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if ((a.OccupationAsAcademicCareer != null) || !book.mRequireAcademics)
                    {
                        if (book.TestRockAndRead(a, false, ref greyedOutTooltipCallback))
                        {
                            msg += Common.NewLine + "A";
                        }
                        if (a.Inventory.Contains(parameters.mTarget) && !(a.Posture is Sim.StandingPosture))
                        {
                            if (book.TestReadBook(a, false, ref greyedOutTooltipCallback))
                            {
                                msg += Common.NewLine + "B";
                            }
                        }
                        if (a.GetObjectInRightHand() == parameters.mTarget)
                        {
                            if (book.TestReadBook(a, false, ref greyedOutTooltipCallback))
                            {
                                msg += Common.NewLine + "C";
                            }
                        }

                        msg += Common.NewLine + "D";
                    }

                    msg += Common.NewLine + "E";
                }

                CommonDoor door = parameters.mTarget as CommonDoor;
                if (door != null)
                {
                    if (door.mObjComponents != null)
                    {
                        msg += Common.NewLine + "Count: " + door.mObjComponents.Count;

                        for (int i = 0x0; i < door.mObjComponents.Count; i++)
                        {
                            msg += Common.NewLine + door.mObjComponents[i].BaseType;

                            if (door.mObjComponents[i].BaseType == typeof(PortalComponent))
                            {
                                msg += Common.NewLine + " Found";

                                door.mObjComponents[i].Dispose();
                                door.mObjComponents.RemoveAt(i);
                                break;
                            }
                        }
                        if (door.mObjComponents.Count == 0x0)
                        {
                            door.mObjComponents = null;
                        }
                    }
                }

                HarvestPlant plant = parameters.mTarget as HarvestPlant;
                if (plant != null)
                {
                    msg += Common.NewLine + "mBarren: " + plant.mBarren;
                    msg += Common.NewLine + "mGrowthState: " + plant.mGrowthState;
                    msg += Common.NewLine + "mDormant: " + plant.mDormant;
                    msg += Common.NewLine + "mLeaflessState: " + plant.mLeaflessState;
                    msg += Common.NewLine + "mLifetimeHarvestablesYielded: " + plant.mLifetimeHarvestablesYielded;
                    msg += Common.NewLine + "NumLifetimeHarvestables: " + plant.PlantDef.NumLifetimeHarvestables;
                    msg += Common.NewLine + "Yield: " + plant.GetYield();
                }
            }
            catch (Exception e)
            {
                GameHitParameters <GameObject> .Exception(parameters, msg, e);
            }
            finally
            {
                Common.DebugWriteLog(msg);
            }

            return(OptionResult.SuccessClose);
        }
Beispiel #2
0
        public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register)
        {
            GameObject o           = null;
            bool       keepLooping = true;

            switch (rItem.info.Type)
            {
            case ItemType.Herb:
            case ItemType.Ingredient:
                foreach (KeyValuePair <string, List <StoreItem> > kvp in Grocery.mItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;
                            IngredientData data = (IngredientData)item.CustomData;
                            if (rItem.info.Type == ItemType.Ingredient)
                            {
                                o = Ingredient.Create(data);
                            }
                            else
                            {
                                o = Herb.Create(data);
                                //PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData;
                                //o = (GameObject)PlantableNonIngredient.Create(data);
                            }
                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }

                break;

            case ItemType.Fish:
                o = Fish.CreateFishOfRandomWeight(rItem.info.FType);
                break;

            case ItemType.Craftable:
                break;

            case ItemType.Gem:
            case ItemType.Metal:

                o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false);
                break;

            case ItemType.Nectar:

                NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle");
                NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price);

                if (nectarBottleObjectInitParams != null)
                {
                    bottle.mBottleInfo.FruitHash   = nectarBottleObjectInitParams.FruitHash;
                    bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients;
                    bottle.mBottleInfo.Name        = rItem.info.Name;             //nectarBottleObjectInitParams.Name;
                    bottle.mDateString             = nectarBottleObjectInitParams.DateString;
                    bottle.mBottleInfo.DateNum     = nectarBottleObjectInitParams.DateNum;
                    bottle.mBaseValue                   = rItem.info.Price;  // nectarBottleObjectInitParams.BaseValue;
                    bottle.ValueModifier                = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price);
                    bottle.mBottleInfo.mCreator         = nectarBottleObjectInitParams.Creator;
                    bottle.mBottleInfo.NectarQuality    = Sims3.Gameplay.Objects.Quality.Neutral;                 //NectarBottle.GetQuality((float)rItem.info.Price);
                    bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim;
                    bottle.UpdateVisualState();
                }

                o = bottle;

                break;

            case ItemType.AlchemyPotion:

                foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes())
                {
                    if (rItem.info.Name.Equals(recipe.Name))
                    {
                        string[] array = new string[] { recipe.Key };

                        AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe();
                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData();

                        potionShopConsignmentRegisterData.mParameters             = array;
                        potionShopConsignmentRegisterData.mObjectName             = randomAwardPotionRecipe.MedatorName;
                        potionShopConsignmentRegisterData.mGuid                   = potionShopConsignmentRegisterData.mObjectName.GetHashCode();
                        potionShopConsignmentRegisterData.mSellerAge              = CASAgeGenderFlags.None;
                        potionShopConsignmentRegisterData.mWeight                 = 100f;
                        potionShopConsignmentRegisterData.mSellPriceMinimum       = 0.75f;
                        potionShopConsignmentRegisterData.mSellPriceMaximum       = 1.25f;
                        potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0;
                        potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5;
                        potionShopConsignmentRegisterData.mLifespan               = 3f;
                        string text = string.Empty;
                        if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName))
                        {
                            text = randomAwardPotionRecipe.CustomClassName;
                        }
                        else
                        {
                            text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion";
                        }
                        potionShopConsignmentRegisterData.mScriptClass = text;
                        potionShopConsignmentRegisterData.mIsRotatable = true;

                        PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData);
                        potionShopConsignmentRegisterObjectData2.ShowTooltip = true;

                        o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject;


                        break;
                    }
                }

                break;

            case ItemType.Bug:
                Terrarium t = Terrarium.Create(rItem.info.BugType);
                if (t != null)
                {
                    t.StartVfx();
                }
                o = t;
                break;

            case ItemType.Food:
                int servingPrice = 25;
                if (register != null)
                {
                    servingPrice = register.Info.ServingPrice;
                }

                IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality);

                if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group)
                {
                    ((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft);
                    ((ServingContainerGroup)container).RemoveSpoilageAlarm();
                }
                else
                {
                    ((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice);
                    ((ServingContainerSingle)container).RemoveSpoilageAlarm();
                }

                o = (GameObject)container;

                break;

            case ItemType.Flowers:
                o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase);
                break;

            case ItemType.BookAlchemyRecipe_:
            case ItemType.BookComic_:
            case ItemType.BookFish_:
            case ItemType.BookGeneral_:
            case ItemType.BookRecipe_:
            case ItemType.BookSkill_:
            case ItemType.BookToddler_:
            case ItemType.SheetMusic_:
            case ItemType.AcademicTextBook_:

                foreach (KeyValuePair <string, List <StoreItem> > kvp in Bookstore.sItemDictionary)
                {
                    foreach (StoreItem item in kvp.Value)
                    {
                        if (item.Name.Equals(rItem.info.Name))
                        {
                            keepLooping = false;

                            if (rItem.info.Type == ItemType.BookGeneral_)
                            {
                                o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData);
                            }
                            if (rItem.info.Type == ItemType.BookSkill_)
                            {
                                o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData);
                            }
                            if (rItem.info.Type == ItemType.BookRecipe_)
                            {
                                o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData);
                            }
                            if (rItem.info.Type == ItemType.SheetMusic_)
                            {
                                o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData);
                            }
                            if (rItem.info.Type == ItemType.BookToddler_)
                            {
                                o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData);
                            }
                            if (rItem.info.Type == ItemType.BookFish_)
                            {
                                o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData);
                            }
                            if (rItem.info.Type == ItemType.BookAlchemyRecipe_)
                            {
                                o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData);
                            }
                            if (rItem.info.Type == ItemType.AcademicTextBook_)
                            {
                                o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor);
                            }
                            if (rItem.info.Type == ItemType.BookComic_)
                            {
                                o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData);
                            }

                            break;
                        }
                    }
                    if (!keepLooping)
                    {
                        break;
                    }
                }


                break;

            case ItemType.JamJar:
                JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld("canningJarJam", ProductVersion.Store) as JamJar;

                if (jamJar != null)
                {
                    Type         tInfo = jamJar.GetType();
                    BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
                    FieldInfo    ingredientDataField = tInfo.GetField("mData", flags);
                    FieldInfo    ingredientKeyField  = tInfo.GetField("mIngredientKey", flags);
                    FieldInfo    qualityField        = tInfo.GetField("mQuality", flags);
                    FieldInfo    preservesField      = tInfo.GetField("mIsPreserves", flags);
                    MethodInfo   materialStateMethod = tInfo.GetMethod("SetMaterialState", flags);

                    ingredientDataField.SetValue(jamJar, rItem.info.IngData);
                    ingredientKeyField.SetValue(jamJar, rItem.info.IngredientKey);
                    qualityField.SetValue(jamJar, rItem.info.JamQuality);
                    preservesField.SetValue(jamJar, rItem.info.JamIsPreserve);
                    materialStateMethod.Invoke(jamJar, null);
                }
                o = (GameObject)jamJar;
                break;

            default:
                break;
            }

            return(o);
        }