示例#1
0
        public void RemoveGameObj(IGameObject renderObj)
        {
            if (renderObj == null)
            {
                return;
            }

            List <IGameObject> objList    = null;
            string             strObjName = renderObj.GetResName();

            if (m_lstCacheRenderObj.Contains(strObjName))
            {
                if (renderObj.GetGameObject() == null)
                {
                    renderObj.Destroy();
                    Utility.Log.Error("RemoveGameObj error {0}", renderObj.GetResName());
                    return;
                }
                if (!m_mapRenderObjIdle.TryGetValue(renderObj.GetResName(), out objList)) // 缓存池里面有数据
                {
                    objList = new List <IGameObject>();
                    m_mapRenderObjIdle.Add(renderObj.GetResName(), objList);
                }
                renderObj.IdleStartTime = Time.realtimeSinceStartup;
                objList.Add(renderObj);
                renderObj.SetParent(m_ObjPool);
            }
            else
            {
                renderObj.Destroy();
                renderObj = null;
            }
        }
示例#2
0
            protected override bool PerformResults(CastConvertEx ths, string epicJazzName, IMagicalDefinition definition, MagicControl control, bool spellCastingSucceeded, bool spellCastingEpiclyFailed)
            {
                bool        flag2          = false;
                IGameObject conjuredObject = ths.PreCreateObject();

                if (((conjuredObject is Fish) && !(ths.Target.Parent is ISurface)) || (conjuredObject is FailureObject))
                {
                    conjuredObject.Destroy();
                    conjuredObject = null;
                    flag2          = true;
                }

                if (conjuredObject != null)
                {
                    int num        = kMaxConversionValue[0x1];
                    int skillLevel = control.GetSkillLevel(ths.Actor.SimDescription);
                    if ((skillLevel >= definition.SpellSettings.mMinSkillLevel) && (skillLevel <= 0xa))
                    {
                        num = kMaxConversionValue[skillLevel];
                    }
                    if (conjuredObject.Value > num)
                    {
                        flag2 = true;
                    }
                }

                bool succeeded = false;

                if (!flag2 && spellCastingSucceeded)
                {
                    succeeded = true;
                    ths.AnimateSim("SuccessIdle");
                    ths.AnimateSim("Success");
                    ths.OnSpellSuccess(conjuredObject);
                }
                else
                {
                    succeeded = base.PerformResults(ths, epicJazzName, definition, control, false, spellCastingEpiclyFailed);
                }

                if (!succeeded && (conjuredObject != null))
                {
                    conjuredObject.Destroy();
                    conjuredObject = null;
                }

                return(succeeded);
            }
示例#3
0
        public bool MoveDown()
        {
            this.Map[this.RowPosition, this.ColumnPosition] = environmentFactory.CreateRoad(this.RowPosition, this.ColumnPosition, this.Map);

            if (this.collision.DetectCollision(this.Map, this.RowPosition + 1, this.ColumnPosition))
            {
                IGameObject gameObject = this.Map[this.RowPosition + 1, this.ColumnPosition];

                if (gameObject is IIndestructable)
                {
                    this.Destroy();
                    return(false);
                }

                this.Map[this.RowPosition + 1, this.ColumnPosition] = environmentFactory.CreateRoad(this.RowPosition + 1, this.ColumnPosition, this.Map);
                this.Destroy();
                gameObject.Destroy();
                this.RowPosition++;

                return(false);
            }
            else
            {
                this.Map[this.RowPosition + 1, this.ColumnPosition] = this;
                this.RowPosition++;

                return(true);
            }
        }
示例#4
0
        public static bool AddHuntableToInventory(DogHuntingSkill ths, IGameObject huntable)
        {
            if (huntable == null)
            {
                return(false);
            }

            bool flag = false;

            if (SimTypes.IsSelectable(ths.SkillOwner))
            {
                flag = Inventories.TryToMove(huntable, ths.SkillOwner.CreatedSim);
            }
            else
            {
                // Add the item to head of family
                SimDescription head = SimTypes.HeadOfFamily(ths.SkillOwner.Household);
                if (head != null)
                {
                    flag = Inventories.TryToMove(huntable, head.CreatedSim);
                }
            }

            if (!flag)
            {
                huntable.RemoveFromWorld();
                huntable.Destroy();
            }
            else
            {
                StoryProgression.Main.Skills.Notify("SniffOut", ths.SkillOwner.CreatedSim, Common.Localize("SniffOut:Success", ths.SkillOwner.IsFemale, new object[] { ths.SkillOwner, huntable.GetLocalizedName() }));
            }

            return(flag);
        }
示例#5
0
        protected static void CleanupSlots(Sim sim)
        {
            foreach (Slot slot in sim.GetContainmentSlots())
            {
                IGameObject obj = sim.GetContainedObject(slot);
                if (obj == null)
                {
                    continue;
                }

                try
                {
                    obj.UnParent();
                    obj.RemoveFromUseList(sim);

                    if (!(obj is Sim))
                    {
                        if ((sim.Inventory == null) || (!sim.Inventory.TryToAdd(obj, false)))
                        {
                            obj.Destroy();
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(sim, obj, e);
                }
            }
        }
示例#6
0
            protected override void PrivatePerform(StateMachineClient smc, InteractionInstance.LoopData loopData)
            {
                if (SimClock.ElapsedTime(TimeUnit.Minutes, mInteraction.mLastLTRUpdateDateAndTime) >= GoToSchoolInRabbitHole.kSimMinutesBetweenLTRUpdates)
                {
                    if (RandomUtil.RandomChance(kExplorerClubCollectChance))
                    {
                        IGameObject huntable = GetHuntable();
                        if (huntable != null)
                        {
                            if (Inventories.TryToMove(huntable, mInteraction.Actor))
                            {
                                RockGemMetalBase rock = huntable as RockGemMetalBase;
                                if (rock != null)
                                {
                                    rock.RegisterCollected(mInteraction.Actor, false);
                                }

                                string msg = Common.Localize("AfterschoolFoundObject:Notice", mInteraction.Actor.IsFemale, new object[] { mInteraction.Actor, huntable.GetLocalizedName() });

                                mInteraction.Actor.ShowTNSIfSelectable(msg, StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, huntable.ObjectId);
                            }
                            else
                            {
                                huntable.Destroy();
                            }
                        }
                    }
                }

                mInteraction.AfterschoolActivityLoopDelegate(smc, loopData);
            }
示例#7
0
        public override bool Run()
        {
            bool  result       = false;
            IPond nearestWater = GetNearestWater(Actor.Position, float.MaxValue);

            if (nearestWater == null)
            {
                return(false);
            }
            ulong notUsed = 10u;             // Not used by the method. I don't know what it was supposed to be.

            if (!DrinkFromPondHelper.RouteToDrinkLocation(nearestWater.RepresentativePondPosition(), Actor,
                                                          GameObjectHitType.WaterPond, notUsed))
            {
                return(false);
            }
            mossBall = GlobalFunctions.CreateObjectOutOfWorld("petToyBallFoil", ProductVersion.EP5);
            //bool isChaining = Actor.CurrentInteraction is ITendGarden;
            mossBall.SetColorTint(74, 93, 35, 0);              // RGB value for Dark Moss Green
            mossBall.AddToWorld();
            mossBall.SetPosition(Actor.Position);
            CarryUtils.Acquire(Actor, mossBall);
            EnterCarry(Actor, mossBall);
            CarryUtils.Request(Actor, "PickUp");
            CarryUtils.Request(Actor, "Carry");
            //if (!PetCarrySystem.PickUpWithoutRouting(Actor, mossBall as IPetCarryable))
            //         {
            //	return false;
            //         }
            EnterStateMachine("DrinkFromPond", "Enter", "x");
            AnimateSim("Loop");
            AnimateSim("Loop");
            AnimateSim("Exit");

            if (Target.RouteSimToMeAndCheckInUse(Actor) && WaterTestDisregardGardeningSkill(Target, Actor))
            {
                ConfigureInteraction();
                //TryConfigureTendGardenInteraction(Actor.CurrentInteraction);
                result = DoWater();
            }
            CarryUtils.Request(Actor, "PutDown");
            CarryUtils.ExitCarry(Actor);
            mossBall.Destroy();
            //if (IsChainingPermitted(flag))
            //{
            //	IgnorePlants.Add(Target);
            //	if (flag2)
            //	{
            //		PushNextInteractionInChain(Singleton, WaterTest, Target.LotCurrent);
            //	}
            //	else
            //	{
            //		PushNextInteractionInChain(Singleton, WaterTestDisregardGardeningSkill, Target.LotCurrent);
            //	}
            //}
            return(result);
        }
示例#8
0
        public static bool OnFlush(IGameObject obj)
        {
            if (obj is PlumbBob) return false;

            obj.Dispose();
            obj.Destroy();

            return true;
        }
示例#9
0
 public override void Cleanup()
 {
     if (mossBall != null)
     {
         mossBall.Destroy();
         mossBall = null;
     }
     StopWateringSound(null, null);
     base.Cleanup();
 }
示例#10
0
        public static bool OnFlush(IGameObject obj)
        {
            if (obj is PlumbBob)
            {
                return(false);
            }

            obj.Dispose();
            obj.Destroy();

            return(true);
        }
示例#11
0
        public override bool InRabbitHole()
        {
            try
            {
                SimDescription oldSim = Actor.SimDescription;
                SimDescription newSim = Genetics.MakeDescendant(oldSim, oldSim, CASAgeGenderFlags.Child, oldSim.Gender, 100f, new Random(), false, true, true);
                newSim.WasCasCreated = false;

                /*
                 * if (!Household.ActiveHousehold.CanAddSpeciesToHousehold(Actor.SimDescription.Species))
                 * {
                 *  newSim.Dispose();
                 *  return false;
                 * }
                 */

                oldSim.Household.Add(newSim);
                newSim.FirstName = StringInputDialog.Show(Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneTitle", new object[0x0]), Localization.LocalizeString("Gameplay/Objects/RabbitHoles/ScienceLab:NameCloneDesc", new object[0x0]), string.Empty, 256, StringInputDialog.Validation.SimNameText);
                Target.SetupNewClone(oldSim, newSim, "ep4CloneTransitionChild");

                // Custom
                foreach (OccultTypes type in OccultTypeHelper.CreateList(oldSim))
                {
                    OccultTypeHelper.Add(newSim, type, false, false);
                }

                IGameObject voucher = Actor.Inventory.Find <IVoucherCloneMe>();
                if (voucher != null)
                {
                    Actor.Inventory.RemoveByForce(voucher);
                    voucher.Destroy();
                    voucher = null;
                }

                EventTracker.SendEvent(EventTypeId.kNewOffspring, Actor, newSim.CreatedSim);
                EventTracker.SendEvent(EventTypeId.kParentAdded, newSim.CreatedSim, Actor);
                EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, newSim.CreatedSim);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#12
0
        public virtual MagicWand InitialPrep(Sim actor, IMagicalDefinition definition, out bool wandCreated)
        {
            IGameObject toAdd = GlobalFunctions.CreateObject("magicHandsLHR", ProductVersion.EP7, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null);

            MagicWand wand = toAdd as MagicWand;

            if (wand == null)
            {
                toAdd.Destroy();
                wandCreated = false;
            }
            else
            {
                wandCreated = true;
            }

            return(wand);
        }
示例#13
0
        protected override OptionResult Run(GameHitParameters <GameObject> parameters)
        {
            DisplayHelper.DisplayTypes type;
            Dictionary <int, Slot>     slots = DisplayHelper.GetEmptyOrFoodSlots(mTarget as CraftersConsignmentDisplay, out type);

            foreach (KeyValuePair <int, Slot> slot in slots)
            {
                IGameObject obj = mTarget.GetContainedObject(slot.Value);
                if (obj != null)
                {
                    obj.UnParent();
                    obj.Destroy();
                }
            }

            Common.Notify(Common.Localize("General:Success"));

            return(OptionResult.SuccessClose);
        }
示例#14
0
        public static bool CreateScrap(Sim sim, int amount)
        {
            ScrapInitParameters initData = new ScrapInitParameters(amount);
            IGameObject         obj2     = GlobalFunctions.CreateObjectOutOfWorld("scrapPile", ProductVersion.EP2, null, initData);

            Scrap scrap = obj2 as Scrap;

            if (scrap != null)
            {
                scrap.HasBeenCounted = true;
                if (Inventories.TryToMove(scrap, sim))
                {
                    return(true);
                }
                scrap.Destroy();
            }
            else if (obj2 != null)
            {
                obj2.Destroy();
            }
            return(false);
        }
示例#15
0
		public static void UnreservePlantablePlantingFailed(IGameObject currentTarget, Sim sim,
			PlantInteractionType interactionType)
		{
			currentTarget.RemoveFromUseList(sim);
			if (interactionType == PlantInteractionType.FromInventory
				|| interactionType == PlantInteractionType.FromInventoryPlantMany)
			{
				if (!sim.Inventory.SetNotInUse(currentTarget))
				{
					currentTarget.Destroy();
				}
				return;
			}
			currentTarget.SetOpacity(1f, 0f);
			Ingredient ingredient = currentTarget as Ingredient;
			if (ingredient != null)
			{
				ingredient.EnableFootprint();
			}
			else
			{
				(currentTarget as PlantableNonIngredient)?.EnableFootprint();
			}
		}
示例#16
0
        public override bool Run()
        {
            try
            {
                IGameObject target = Target.Clone();

                Inventory inventory = Inventory.ParentInventory(Target);
                if (inventory != null)
                {
                    inventory.TryToAdd(target, false);
                    return(true);
                }
                else
                {
                    target.Destroy();
                    return(false);
                }
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
示例#17
0
        public override bool Run()
        {
            try
            {
                if (!Actor.Inventory.Contains(Target))
                {
                    if (!Actor.RouteToObjectRadiusAndCheckInUse(Target, 0.7f))
                    {
                        return(false);
                    }

                    StandardEntry();
                    BeginCommodityUpdates();
                    Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                    if (!Actor.Inventory.TryToAdd(Target))
                    {
                        EndCommodityUpdates(false);
                        StandardExit();
                        return(false);
                    }
                }
                else
                {
                    StandardEntry();
                    BeginCommodityUpdates();
                }

                SocialJigTwoPerson person = GlobalFunctions.CreateObjectOutOfWorld(SocialJig.SocialJigMedatorNames.SocialJigTwoPerson.ToString()) as SocialJigTwoPerson;
                person.RegisterParticipants(Actor, null);
                Sim createdSim = null;
                try
                {
                    World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position);
                    fglParams.BooleanConstraints |= FindGoodLocationBooleans.Routable;
                    if (GlobalFunctions.PlaceAtGoodLocation(person, fglParams, true))
                    {
                        Route r = Actor.CreateRoute();
                        r.PlanToSlot(person, person.GetSlotForActor(Actor, true));
                        r.DoRouteFail = true;
                        if (Actor.DoRoute(r))
                        {
                            bool paramValue = false;
                            mSummonGenieBroadcast = new ReactionBroadcaster(Actor, kSummonGenieBroadcastParams, SummonGenieBroadcastCallback);
                            Sims3.Gameplay.Gameflow.SetGameSpeed(Sims3.Gameplay.Gameflow.GameSpeed.Normal, Sims3.Gameplay.Gameflow.SetGameSpeedContext.Gameplay);
                            if (Target.mGenieDescription == null)
                            {
                                Target.mGenieDescription = OccultGenie.CreateGenie(Actor, Target);
                                createdSim = Target.mGenieDescription.CreatedSim;
                                EventTracker.SendEvent(EventTypeId.kCleanLamp, Actor, Target);
                                paramValue = true;
                            }
                            else
                            {
                                createdSim = Target.mGenieDescription.Instantiate(Vector3.OutOfWorld, false);
                                OccultGenie occultType          = null;
                                DateAndTime previousDateAndTime = SimClock.CurrentTime();
                                do
                                {
                                    SpeedTrap.Sleep(0xa);
                                    occultType = createdSim.OccultManager.GetOccultType(OccultTypes.None | OccultTypes.Genie) as OccultGenie;
                                }while ((occultType == null) && (SimClock.ElapsedTime(TimeUnit.Minutes, previousDateAndTime) < 120f));

                                if (occultType != null)
                                {
                                    occultType.SetGenieLampRelations(Actor, createdSim, Target);
                                }
                                else
                                {
                                    createdSim.Destroy();
                                    createdSim = null;
                                }
                            }

                            if (createdSim != null)
                            {
                                createdSim.FadeOut(false, false, 0f);
                                createdSim.GreetSimOnLot(Actor.LotCurrent);
                                createdSim.AddToWorld();
                                Slot slotForActor = person.GetSlotForActor(createdSim, false);
                                createdSim.SetPosition(person.GetSlotPosition(slotForActor));
                                createdSim.SetForward(person.GetForwardOfSlot(slotForActor));
                                IGameObject actor = GlobalFunctions.CreateObject("GenieLamp", ProductVersion.EP6, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, null);
                                if (!actor.IsActorUsingMe(Actor))
                                {
                                    actor.AddToUseList(Actor);
                                }
                                EnterStateMachine("GenieLampSummon", "Enter", "x");
                                SetActor("lamp", actor);
                                SetParameter("isFirstTime", paramValue);
                                AnimateSim("Exit");
                                actor.Destroy();
                                createdSim.FadeIn();
                                VisualEffect effect = VisualEffect.Create("ep6GenieAppearSmoke_main");
                                effect.SetPosAndOrient(createdSim.Position, Vector3.UnitX, Vector3.UnitZ);
                                effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);
                                OpportunityManager opportunityManager = Actor.OpportunityManager;
                                if ((opportunityManager != null) && opportunityManager.HasOpportunity(OpportunityNames.EP6_ReleaseGenie_SummonGenie))
                                {
                                    OccultGenie genie2 = createdSim.OccultManager.GetOccultType(OccultTypes.Genie) as OccultGenie;
                                    if (genie2 == null)
                                    {
                                        createdSim.Destroy();
                                        createdSim = null;
                                    }
                                    else
                                    {
                                        OccultGenieEx.OnFreedFromLamp(genie2, Actor, createdSim, true);
                                        if (opportunityManager.GetLastOpportunity(OpportunityCategory.Special) == OpportunityNames.EP6_ReleaseGenie_SummonGenie)
                                        {
                                            opportunityManager.ClearLastOpportunity(OpportunityCategory.Special);
                                        }

                                        EventTracker.SendEvent(EventTypeId.kGrantedWishToFreeGenie, Actor, Target);
                                        if (Target.InInventory)
                                        {
                                            Actor.Inventory.RemoveByForce(Target);
                                            if (Target.IsOnHandTool)
                                            {
                                                Target.RemoveFromWorld();
                                            }
                                        }
                                        else
                                        {
                                            Target.RemoveFromWorld();
                                        }
                                        EnterStateMachine("FreeTheGenie", "Enter", "x");
                                        SetActor("x", createdSim);
                                        AnimateSim("Exit");
                                    }
                                }
                                else
                                {
                                    Target.mGenieSocializingEvent        = EventTracker.AddListener(EventTypeId.kSocialInteraction, OnSocialization);
                                    Target.CheckGenieReturnToLamp        = createdSim.AddAlarmRepeating(1f, TimeUnit.Minutes, Target.CheckGenieReturnToLampCallback, "Genie Check to return to lamp", AlarmType.AlwaysPersisted);
                                    Target.mTimeSinceLastSocialWithGenie = SimClock.CurrentTime();
                                }
                            }
                        }
                    }
                }
                finally
                {
                    person.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit(createdSim == null, createdSim == null);
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#18
0
        public static Vehicle Sim_GetVehicle(Sim ths, Lot lot, bool allowUFO)
        {
            if (ths.IsPet)
            {
                return(null);
            }

            var vehicleForCurrentInteraction = ths.GetVehicleForCurrentInteraction();

            if (vehicleForCurrentInteraction != null && !(vehicleForCurrentInteraction is Boat))
            {
                return(vehicleForCurrentInteraction);
            }

            bool child    = ths.Posture == null || !ths.Posture.Satisfies(CommodityKind.CarryingChild, null);
            bool canDrive = ths.CanDriveOrCallTaxi();

            if (canDrive &&
                !Vehicle.WorldHasSpecialCarRules(GameUtils.GetCurrentWorld())

                && (!(ths.SimRoutingComponent != null && ths.SimRoutingComponent.AllowBikes)

                    || (ths.Autonomy != null &&
                        ths.Autonomy.SituationComponent != null &&
                        ths.Autonomy.SituationComponent.InSituationOfType(typeof(GoHereWithSituation)))

                    || ths.CurrentInteraction is TravelUtil.SitInCarToTriggerTravel ||
                    ths.CurrentInteraction is TravelUtil.SitInCarToReturnHomeWithinHomeWorld))
            {
                child = false;
            }

            Vehicle vehicle = null;

            vehicle = ths.GetOwnedAndUsableVehicle(lot, true, child && !ths.IsHoldingAnything(), !GameUtils.IsInstalled(ProductVersion.EP4), allowUFO);

            if (vehicle == null || vehicle.HasBeenDestroyed)
            {
                if (canDrive)
                {
                    if (ths.SimDescription == null)
                    {
                        return(null);
                    }

                    if (child)
                    {
                        vehicle = Vehicle_CreateTaxiBicycle(ths.SimDescription.Child);
                    }
                    else if (ths.SimDescription.CanDrive && ths.IsHoldingAnything())
                    {
                        IGameObject gameObject = (!GameUtils.IsInstalled(ProductVersion.EP11) ||
                                                  GameUtils.GetCurrentWorld() != WorldName.FutureWorld) ?
                                                 GlobalFunctions.CreateObjectOutOfWorld(RandomUtil.CoinFlip() ?
                                                                                        "CarUsed2" : "CarSedan", ProductVersion.BaseGame, null, null)
                            : GlobalFunctions.CreateObjectOutOfWorld(RandomUtil.CoinFlip() ? "HoverCarUsed"
                            : "HoverCarExpensive", ProductVersion.EP11, null, null);

                        CarOwnable carOwnable = gameObject as CarOwnable;
                        if (carOwnable != null)
                        {
                            Lot       lotHome   = ths.LotHome;
                            Household household = ths.Household;

                            if (lotHome != null && household != null && !household.IsServiceNpcHousehold)
                            {
                                int cost = carOwnable.Cost;
                                if (ths.FamilyFunds >= cost)
                                {
                                    ths.ModifyFunds(-cost);
                                }
                                else
                                {
                                    household.UnpaidBills += cost;
                                }
                            }

                            carOwnable.GeneratedOwnableForNpc = (lotHome == null);
                            carOwnable.DestroyOnRelease       = (lotHome == null);
                            carOwnable.LotHome = lotHome;

                            vehicle = carOwnable;
                        }
                        else if (gameObject != null)
                        {
                            gameObject.Destroy();
                            vehicle = null;
                        }
                    }
                    else
                    {
                        try
                        {
                            if (CarNpcManager.Singleton == null)
                            {
                                throw new NullReferenceException("CarNpcManager.Singleton == null");
                            }
                            vehicle = CarNpcManager.Singleton.CreateNpcCar(CarNpcManager.NpcCars.Taxi);
                        }
                        catch (ResetException)
                        {
                            throw;
                        }
                        catch (Exception) { }
                    }
                }
                else
                {
                    if (ths.IsHoldingAnything())
                    {
                        return(null);
                    }
                    vehicle = Vehicle_CreateTaxiBicycle(ths.SimDescription.Child);
                }
            }

            if (vehicle == null || vehicle.HasBeenDestroyed)
            {
                if (child && !ths.IsHoldingAnything() && ths.SimDescription != null)
                {
                    vehicle = Vehicle_CreateTaxiBicycle(ths.SimDescription.Child);
                }
                else if (CarNpcManager.Singleton != null)
                {
                    vehicle = CarNpcManager.Singleton.CreateNpcCar(CarNpcManager.NpcCars.Taxi);
                }
            }
            return(vehicle);
        }
示例#19
0
 public void Destroy(IGameObject gameObject)
 {
     gameObject.Destroy(this);
     _gameObjects.Remove(gameObject);
 }
示例#20
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("RepairImaginaryFriends");

            Trait trait;
            if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait))
            {
                trait.mNonPersistableData.mCanBeLearnedRandomly = false;
            }

            foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>())
            {
                if (doll.mLiveStateSimDescId == 0) continue;

                if (doll.GetLiveFormSimDescription() != null) continue;

                doll.CreateLiveStateForm();

                Overwatch.Log("Missing Imaginary Doll Repaired");
            }

            foreach (SimDescription sim in Households.All(Household.NpcHousehold))
            {
                if (sim.OccultManager == null) continue;

                OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend;
                if (occult == null) continue;

                Overwatch.Log(sim.FullName);

                if (occult.IsReal) continue;

                SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId);
                if (owner == null) continue;

                if (owner.LotHome == null) continue;

                IScriptProxy proxy = Simulator.GetProxy(occult.mDollId);
                if (proxy == null)
                {
                    IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4);
                    if (obj != null)
                    {
                        ImaginaryDoll doll = obj as ImaginaryDoll;
                        if (doll == null)
                        {
                            obj.Destroy();
                        }
                        else
                        {
                            occult.UpdateDollGuid(obj.ObjectId);

                            doll.SetOwner(owner);

                            doll.mLiveStateSimDescId = sim.SimDescriptionId;
                            doll.mIsFemale = sim.IsFemale;
                            doll.mGenderSet = true;
                            doll.EstablishState(ImaginaryDoll.OwnershipState.Live);

                            Sim ownerSim = owner.CreatedSim;
                            if (ownerSim != null)
                            {
                                if (Inventories.TryToMove(obj, ownerSim))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                            else
                            {
                                if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory))
                                {
                                    Overwatch.Log("Imaginary Friend Doll Added To Family Inventory");
                                }
                                else
                                {
                                    obj.Destroy();
                                }
                            }
                        }
                    }
                }
            }
        }
示例#21
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteSimToMeAndCheckInUse(Actor) || !HarvestPlant.HarvestTest(Target, Actor))
                {
                    return(false);
                }

                Target.RemoveHarvestStateTimeoutAlarm();
                StandardEntry();
                BeginCommodityUpdates();
                Soil dummyIk = null;
                StateMachineClient client = null;

                bool allowChild = false;

                if (Actor.SimDescription.YoungAdultOrAbove)
                {
                    allowChild = true;
                }
                else if ((Actor.SimDescription.Teen) && (Woohooer.Settings.mUnlockTeenActions))
                {
                    allowChild = true;
                }

                if ((!Autonomous) && (allowChild) && RandomUtil.RandomChance01(kChanceToHavePlantSimBaby))
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    Sim newBorn = GetNewBorn();
                    Relationship.Get(Actor, newBorn, true).LTR.ForceChangeState(LongTermRelationshipTypes.Friend);
                    if (newBorn.BridgeOrigin != null)
                    {
                        newBorn.BridgeOrigin.MakeRequest();
                        newBorn.BridgeOrigin = null;
                    }

                    if (client != null)
                    {
                        IGameObject actor = GlobalFunctions.CreateObjectOutOfWorld("plantSimHarvestable", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                        client.SetActor("harvestable", actor);
                        client.SetActor("y", newBorn);
                        client.EnterState("x", "Enter Standing");
                        Target.SetGrowthState(PlantGrowthState.Planted);
                        client.RequestState("x", "HaveAPlantSimBaby");
                        Pregnancy.MakeBabyVisible(newBorn);
                        client.RequestState("x", "Exit Standing");
                        actor.RemoveFromWorld();
                        actor.Destroy();
                    }

                    if (Actor.IsSelectable)
                    {
                        OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim>(new Sim[] { newBorn }));
                    }

                    ChildUtils.CarryChild(Actor, newBorn, true);
                    EventTracker.SendEvent(EventTypeId.kBornFromTheSoil, newBorn);
                }
                else
                {
                    client   = Target.CreateStateMachine(Actor, out dummyIk);
                    mDummyIk = dummyIk;
                    bool hasHarvested = true;
                    if (Actor.IsInActiveHousehold)
                    {
                        hasHarvested = false;
                        foreach (SimDescription description in Actor.Household.SimDescriptions)
                        {
                            Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if ((skill != null) && skill.HasHarvested())
                            {
                                hasHarvested = true;
                                break;
                            }
                        }
                    }

                    IGameObject obj3 = GlobalFunctions.CreateObjectOutOfWorld("plantForbiddenFruit", ProductVersion.EP9, "Sims3.Gameplay.Core.Null", null);
                    if (client != null)
                    {
                        client.SetActor("harvestable", obj3);
                        client.EnterState("x", "Enter Standing");
                        client.RequestState("x", "HaveAFruit");
                    }
                    Target.DoHarvest(Actor, hasHarvested, null);
                    Target.SetGrowthState(PlantGrowthState.Planted);
                    if (client != null)
                    {
                        client.RequestState("x", "Exit Standing");
                    }
                    obj3.RemoveFromWorld();
                    obj3.Destroy();
                }

                EndCommodityUpdates(true);
                StandardExit();
                Target.RemoveFromWorld();
                Target.Destroy();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#22
0
        public static void OnTrickOrTreatAccept(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i)
        {
            IGameObject trickOrTreatItem = null;

            if (actor.OccultManager != null)
            {
                if ((actor.OccultManager.HasAnyOccultType() || actor.SimDescription.IsAlien) && RandomUtil.RandomChance(Tempest.Settings.mChanceOccultItemTrickOrTreat))
                {
                    List <OccultTypes> types = OccultTypeHelper.CreateList(actor.SimDescription);
                    OccultTypes        pick  = OccultTypes.None;
                    bool useAlien            = true;
                    if (types.Count > 0)
                    {
                        pick     = RandomUtil.GetRandomObjectFromList <OccultTypes>(types);
                        useAlien = actor.SimDescription.IsAlien && RandomUtil.CoinFlip();
                    }
                    trickOrTreatItem = FetchRandomOccultTreat(pick, useAlien);

                    if (trickOrTreatItem is FailureObject)
                    {
                        trickOrTreatItem = null;
                    }
                    else
                    {
                        if (RandomUtil.CoinFlip())
                        {
                            if (actor.OccultManager.HasOccultType(OccultTypes.PlantSim) && GameUtils.IsInstalled(ProductVersion.EP10) && Sim.MosquitoBeBitten.kChanceToKillMosquito != 100 && !target.BuffManager.HasAnyElement(new BuffNames[] { BuffNames.MosquitoBiteLow, BuffNames.MosquitoBiteMid, BuffNames.MosquitoBiteHigh }))
                            {
                                target.BuffManager.AddElement(BuffNames.MosquitoBiteLow, Origin.FromFallHoliday);
                            }
                            else if (actor.OccultManager.HasOccultType(OccultTypes.Werewolf) && GameUtils.IsInstalled(ProductVersion.EP5) && BuffGotFleasHuman.kPetToHumanSpreadFleasChance != 0 && !target.BuffManager.HasElement(BuffNames.GotFleasHuman))
                            {
                                target.BuffManager.AddElement(BuffNames.GotFleasHuman, Origin.FromFallHoliday);
                            }
                        }
                    }
                }
            }

            if (trickOrTreatItem == null)
            {
                trickOrTreatItem = TrickOrTreatSituation.GetTrickOrTreatItem();
            }

            if (trickOrTreatItem != null)
            {
                if (!target.Inventory.TryToAdd(trickOrTreatItem))
                {
                    trickOrTreatItem.Destroy();
                }
                else if (!(trickOrTreatItem is Candy))
                {
                    target.ShowTNSIfSelectable(Localization.LocalizeString(target.IsFemale, "Gameplay/Situation/TrickorTreat:SpecialObjectTNS", new object[] { trickOrTreatItem }), StyledNotification.NotificationStyle.kSimTalking, target.ObjectId, trickOrTreatItem.ObjectId);
                    if (trickOrTreatItem is IMagicGnomeFall)
                    {
                        EventTracker.SendEvent(EventTypeId.kReceivedSeasonalGnome);
                    }
                }
            }
            EventTracker.SendEvent(EventTypeId.kWentTrickOrTreating, target);
        }
示例#23
0
        public T Get <T>(Common.IStatGenerator stats, string name, TestDelegate <T> test, out int price)
            where T : class
        {
            List <BuildBuyProduct> choices = new List <BuildBuyProduct>(mProducts);

            RandomUtil.RandomizeListOfObjects(choices);

            stats.AddStat(name + " Total", choices.Count);

            foreach (BuildBuyProduct choice in choices)
            {
                ResourceKey key = choice.ProductResourceKey;

                Hashtable overrides = new Hashtable(0x1);

                IGameObject obj = null;

                try
                {
                    obj = GlobalFunctions.CreateObjectInternal(key, overrides, null);
                }
                catch (Exception e)
                {
                    Common.DebugException(key.ToString(), e);
                    continue;
                }

                T result = obj as T;
                if (result == null)
                {
                    stats.IncStat(name + " Mismatch " + choice.ObjectInstanceName, Common.DebugLevel.High);
                    stats.IncStat(name + " Wrong Type " + obj.GetType().Name, Common.DebugLevel.High);
                }
                else if ((test != null) && (!test(result)))
                {
                    stats.IncStat(name + " Test Fail");
                }
                else
                {
                    BuildBuyModel model = Sims3.Gameplay.UI.Responder.Instance.BuildBuyModel;

                    List <ResourceKey> presets = new List <ResourceKey>();

                    uint[] objectPresetIdList = model.GetObjectPresetIdList(obj.ObjectId);
                    for (uint i = 0; i < objectPresetIdList.Length; i++)
                    {
                        ThumbnailKey thumbnail = model.GetObjectProductThumbnailKey(obj.ObjectId, ThumbnailSize.Large);
                        if (thumbnail.mDescKey != ResourceKey.kInvalidResourceKey)
                        {
                            uint id = objectPresetIdList[i];
                            thumbnail.mDescKey.GroupId = (thumbnail.mDescKey.GroupId & 0xff000000) | (id & 0xffffff);
                            ResourceKeyContentCategory customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentTypeFromKeyAndPresetIndex(model.GetObjectProductKey(obj.ObjectId), i);
                            if (customContentTypeFromKeyAndPresetIndex == ResourceKeyContentCategory.kInstalled)
                            {
                                customContentTypeFromKeyAndPresetIndex = UIUtils.GetCustomContentType(model.GetObjectProductKey(obj.ObjectId));
                            }
                            string presetString = model.GetPresetString(thumbnail.mDescKey);
                            if (presetString != string.Empty)
                            {
                                KeyValuePair <string, Dictionary <string, Complate> > presetEntryFromPresetString = (KeyValuePair <string, Dictionary <string, Complate> >)SimBuilder.GetPresetEntryFromPresetString(presetString);
                                if ((presetEntryFromPresetString.Value != null) && (presetEntryFromPresetString.Value.Count > 0))
                                {
                                    presets.Add(thumbnail.mDescKey);
                                }
                            }
                        }
                    }

                    if (presets.Count > 0)
                    {
                        ResourceKey preset = RandomUtil.GetRandomObjectFromList(presets);

                        string presetString = model.GetPresetString(preset);
                        if (!string.IsNullOrEmpty(presetString))
                        {
                            object presetEntryFromPresetString = SimBuilder.GetPresetEntryFromPresetString(presetString);
                            if (presetEntryFromPresetString is KeyValuePair <string, Dictionary <string, Complate> > )
                            {
                                FinalizePresetTask.Perform(obj.ObjectId, (KeyValuePair <string, Dictionary <string, Complate> >)presetEntryFromPresetString);
                            }
                        }
                    }

                    stats.IncStat(name + " Found");

                    price = (int)choice.Price;

                    return(result);
                }

                obj.Destroy();
            }

            price = 0;
            return(null);
        }
示例#24
0
        public static bool AddHuntableToInventory(DogHuntingSkill ths, IGameObject huntable)
        {
            if (huntable == null)
            {
                return false;
            }

            bool flag = false;

            if (SimTypes.IsSelectable(ths.SkillOwner))
            {
                flag = Inventories.TryToMove(huntable, ths.SkillOwner.CreatedSim);
            }
            else
            {
                // Add the item to head of family
                SimDescription head = SimTypes.HeadOfFamily(ths.SkillOwner.Household);
                if (head != null)
                {
                    flag = Inventories.TryToMove(huntable, head.CreatedSim);
                }
            }

            if (!flag)
            {
                huntable.RemoveFromWorld();
                huntable.Destroy();
            }
            else
            {
                StoryProgression.Main.Skills.Notify("SniffOut", ths.SkillOwner.CreatedSim, Common.Localize("SniffOut:Success", ths.SkillOwner.IsFemale, new object[] { ths.SkillOwner, huntable.GetLocalizedName() }));
            }

            return flag;
        }
示例#25
0
        public static void RestockDisplay(CraftersConsignmentDisplay display, out Common.StringBuilder debug)
        {
            debug = new Common.StringBuilder("Display: " + display.CatalogName + Common.NewLine + "ObjectID:" + display.ObjectId);
            if (qualites.Count == 0)
            {
                InitLists();
            }

            List <int> slotsToSkipForWeddingCakeSetupOnChiller = new List <int> {
                23, 25
            };
            List <int> slotsToSkipForWeddingCakeSetupOnRack = new List <int> {
                0, 2, 4
            };
            List <int> slotsForWeddingCakesChiller = new List <int> {
                21, 22, 24
            };
            List <int> slotsForWeddingCakesOnRack = new List <int> {
                1, 3
            };
            // wedding cake slots are included in these so they get stocked... if the cakes are disabled, they will be skipped properly
            List <int> slotsForElegantStockingOnRack = new List <int> {
                1, 3, 5, 8, 9, 11, 13, 14, 17, 18, 20, 22, 23, 26
            };
            List <int> slotsForElegantStockingOnChiller = new List <int> {
                0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 22, 24
            };
            Recipe randomRestockRecipe = null;

            if (display.LotCurrent != null)
            {
                debug += Common.NewLine + "LotCurrent: " + display.LotCurrent.Name;
            }

            if (!display.InWorld)
            {
                debug += Common.NewLine + "Display not in world";
                return;
            }

            if (Cupcake.Settings.IsDisplayExempt(display.ObjectId))
            {
                debug += Common.NewLine + "Display has auto restock disabled";
                return;
            }

            bool random = false;

            if (!Cupcake.Settings.HasSettings(display.ObjectId))
            {
                debug += Common.NewLine + "Display has no user defined settings.";
                random = true;
            }

            if (!Cupcake.Settings.mAffectActive && random)
            {
                if (display.LotCurrent == null)
                {
                    debug += Common.NewLine + "LotCurrent null";
                    return;
                }

                if (display.LotCurrent.LotId == Household.ActiveHousehold.LotId)
                {
                    debug += Common.NewLine + "On active household lot";
                    return;
                }

                List <PropertyData> list = RealEstateManager.AllPropertiesFromAllHouseholds();
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != null && display.LotCurrent.LotId == list[i].LotId && list[i].Owner != null && list[i].Owner.OwningHousehold == Household.ActiveHousehold)
                    {
                        debug += Common.NewLine + "On owned lot";
                        return;
                    }
                }
            }

            DisplayHelper.DisplayTypes displayType;
            Dictionary <int, Slot>     slots = DisplayHelper.GetEmptyOrFoodSlots(display, out displayType);

            foreach (KeyValuePair <int, Slot> slot in slots)
            {
                debug += Common.NewLine + "Slot: " + slot.Key;
                if (displayType == DisplayHelper.DisplayTypes.Chiller)
                {
                    if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        if (slot.Key > 20 && !Cupcake.Settings.mStockWeddingCakes)
                        {
                            debug += Common.NewLine + "Wedding cakes disabled, skipping top shelf";
                            continue;
                        }

                        if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnChiller.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slots for presentable wedding cake setup";
                            continue;
                        }

                        if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnChiller.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slot for elegant restocking";
                            continue;
                        }
                    }
                }

                if (displayType == DisplayHelper.DisplayTypes.Rack)
                {
                    if (!Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        if (Cupcake.Settings.mStockWeddingCakes && slotsToSkipForWeddingCakeSetupOnRack.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slots for presentable wedding cake setup";
                            continue;
                        }

                        if (Cupcake.Settings.mElegantRestock && !slotsForElegantStockingOnRack.Contains(slot.Key))
                        {
                            debug += Common.NewLine + "Skipping slot for elegant restocking";
                            continue;
                        }
                    }
                }

                GameObject containedObject = display.GetContainedObject(slot.Value) as GameObject;
                if (containedObject == null)
                {
                    Dictionary <string, List <Quality> > settings = Cupcake.Settings.GetDisplaySettingsForSlot(display.ObjectId, slot.Key);

                    Recipe         recipe    = null;
                    IFoodContainer container = null;
                    Quality        quality   = Quality.Perfect;
                    if (random && !Cupcake.Settings.mDisableRandomAutoRestock && (!Cupcake.Settings.mOneRecipePerDisplayOnRandom || (Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe == null)))
                    {
                        debug += Common.NewLine + "Random";
                        if (Cupcake.Settings.mRandomRestockSettings.Count > 0)
                        {
                            if (Cupcake.Settings.Debugging)
                            {
                                debug += Common.NewLine + "Choices:";
                                foreach (KeyValuePair <string, List <Quality> > val in Cupcake.Settings.mRandomRestockSettings)
                                {
                                    debug += Common.NewLine + val.Key;
                                    foreach (Quality val2 in val.Value)
                                    {
                                        debug += Common.NewLine + val2.ToString();
                                    }
                                }
                            }

                            if (Recipe.NameToRecipeHash.Count > 0)
                            {
                                string pick = RandomUtil.GetRandomObjectFromList <string>(new List <string>(Cupcake.Settings.mRandomRestockSettings.Keys));
                                if (Recipe.NameToRecipeHash.ContainsKey(pick))
                                {
                                    recipe = Recipe.NameToRecipeHash[pick];

                                    debug += Common.NewLine + "Fetching random recipe...";
                                    debug += Common.NewLine + "Pick: " + recipe.Key;

                                    quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mRandomRestockSettings[pick]);
                                    debug  += Common.NewLine + "Fetching random quality...";
                                    debug  += Common.NewLine + "Pick: " + quality.ToString();
                                }
                                else
                                {
                                    debug += Common.NewLine + "Failed to find defined recipe";
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            if (goodies.Count > 0)
                            {
                                recipe = RandomUtil.GetRandomObjectFromList <Recipe>(goodies);
                                debug += Common.NewLine + "Fetching random bakery recipe...";
                                debug += Common.NewLine + "Pick: " + recipe.SpecificNameKey;
                                debug += Common.NewLine + "Quality: Always Perfect";
                            }
                        }

                        randomRestockRecipe = recipe;
                    }

                    if (random && Cupcake.Settings.mOneRecipePerDisplayOnRandom && randomRestockRecipe != null)
                    {
                        debug += Common.NewLine + "OneRecipePerDisplayOnRandom = true" + Common.NewLine + "Last Recipe: " + randomRestockRecipe.GenericName;
                        recipe = randomRestockRecipe;
                    }

                    if (settings != null)
                    {
                        debug += Common.NewLine + "Reading user settings...";

                        if (Cupcake.Settings.Debugging)
                        {
                            debug += Common.NewLine + "Choices:";
                            foreach (KeyValuePair <string, List <Quality> > val in settings)
                            {
                                debug += Common.NewLine + val.Key;
                                foreach (Quality val2 in val.Value)
                                {
                                    debug += Common.NewLine + val2.ToString();
                                }
                            }
                        }

                        string pick = "";
                        if (settings.Count > 0)
                        {
                            List <string> tempList = new List <string>();
                            tempList.AddRange(settings.Keys);

                            pick = RandomUtil.GetRandomObjectFromList <string>(tempList);

                            if (Recipe.NameToRecipeHash.ContainsKey(pick))
                            {
                                recipe = Recipe.NameToRecipeHash[pick];
                                debug += Common.NewLine + "Fetching random recipe...";
                                debug += Common.NewLine + "Pick: " + recipe.Key;
                            }
                            else
                            {
                                debug += Common.NewLine + "Failed to find defined recipe: " + pick;
                                continue;
                            }
                        }
                        else
                        {
                            debug += Common.NewLine + "Settings for slot was 0 count.";
                            continue;
                        }

                        quality = RandomUtil.GetRandomObjectFromList <Quality>(Cupcake.Settings.mDisplayRestockSettings[display.ObjectId][slot.Key][pick]);
                        debug  += Common.NewLine + "Fetching random quality...";
                        debug  += Common.NewLine + "Pick: " + quality.ToString();
                    }

                    bool tryCake = false;
                    if (random && Cupcake.Settings.mStockWeddingCakes && !Cupcake.Settings.SlotHasSettings(display.ObjectId, slot.Key))
                    {
                        List <string> cakes = new List <string> {
                            "BSBakeWeddingCake", "WeddingCakeSliceDOT07"
                        };
                        tryCake = true;

                        if (GameUtils.IsInstalled(ProductVersion.EP4))
                        {
                            cakes.Add("Wedding Cake Slice");
                        }

                        if ((displayType == DisplayHelper.DisplayTypes.Chiller && slotsForWeddingCakesChiller.Contains(slot.Key)) || (displayType == DisplayHelper.DisplayTypes.Rack && slotsForWeddingCakesOnRack.Contains(slot.Key)))
                        {
                            debug += Common.NewLine + "Wedding cake slot";
                            recipe = null;
                            while (recipe == null)
                            {
                                string pick = RandomUtil.GetRandomObjectFromList <string>(cakes);
                                if (!Recipe.NameToRecipeHash.TryGetValue(pick, out recipe))
                                {
                                    // for folks with out of date mods
                                    if (pick == "BSBakeWeddingCake")
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (recipe != null)
                    {
                        if (quality == Quality.Any)
                        {
                            // EA standard apparently doesn't handle this correctly...
                            quality = RandomUtil.GetRandomObjectFromList <Quality>(qualites);
                        }

                        // Catalog recipes
                        IGameObject cake = null;
                        if (recipe.Key == "WeddingCakeSliceDOT07")
                        {
                            debug += Common.NewLine + "Attempt at Monte Vista cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingDOT07", ProductVersion.BaseGame);
                            }
                        }
                        else if (recipe.Key == "Wedding Cake Slice")
                        {
                            debug += Common.NewLine + "Attempt at Generations cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.EP4);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingTraditional", ProductVersion.BaseGame);
                            }
                        }
                        else if (((tryCake && cake is FailureObject) || recipe.Key == "BSBakeWeddingCake"))
                        {
                            debug += Common.NewLine + "Attempt at Store Wedding cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("foodServeCakeWeddingBakery", ProductVersion.BaseGame);
                            }
                        }
                        else if (recipe.Key == "BSBakeBirthdayCake")
                        {
                            debug += Common.NewLine + "Attempt at Store Birthday cake";
                            cake   = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ~ProductVersion.Undefined);
                            if (cake is FailureObject)
                            {
                                cake = GlobalFunctions.CreateObjectOutOfWorld("FoodBirthdayCakeBakery", ProductVersion.BaseGame);
                            }
                        }
                        else
                        {
                            container = recipe.CreateFinishedFood(recipe.CanMakeGroupServing ? Recipe.MealQuantity.Group : Recipe.MealQuantity.Single, quality);
                        }

                        if (cake != null)
                        {
                            if (cake is FailureObject)
                            {
                                debug += Common.NewLine + "Cake was FailureObject";
                                try
                                {
                                    cake.Destroy();
                                }
                                catch { }
                                continue;
                            }

                            debug += Common.NewLine + "Cake success";
                            DisplayHelper.ParentToSlot(cake as GameObject, slot.Value, display);
                            cake.AddToWorld();
                            InitInteractions(cake as GameObject);
                        }

                        if (container != null)
                        {
                            if (container is FailureObject)
                            {
                                debug += Common.NewLine + "Container was FailureObject";
                                try
                                {
                                    container.Destroy();
                                }
                                catch { }
                                continue;
                            }

                            DisplayHelper.ParentToSlot(container as GameObject, slot.Value, display);
                            container.SetGeometryState(recipe.SingleServingContainer); // this is how EA sets it, don't ask
                            container.AddToWorld();

                            ServingContainer container2 = container as ServingContainer;
                            if (container2 != null)
                            {
                                int[] numArray = new int[] { 0, 0, 0, 0, 0, 0, 15, 30, 0x2d, 60, 0x4b, 100, 0x65 };
                                container2.CookingProcess.FoodPoints = numArray[(int)quality];
                                container2.CookingProcess.FoodState  = FoodCookState.Cooked;
                                container2.FoodCookStateChanged(container2.CookingProcess.FoodState);
                            }

                            InitInteractions(container as GameObject);

                            debug += Common.NewLine + "Success: " + recipe.GenericName + Common.NewLine + quality.ToString();
                        }
                    }
                }
                else
                {
                    debug += Common.NewLine + "Slot contained object: " + containedObject.CatalogName;
                }
            }
            display.AddInteractionsToChildObjects();
        }
示例#26
0
        protected static void Cleanup1 <TConsigned>(Logger log, string prefix, int maximumAge, ref Dictionary <ulong, List <TConsigned> > list)
            where TConsigned : ICancelSellableUIItem, ISellableUIItem, IShopItem
        {
            if (list == null)
            {
                list = new Dictionary <ulong, List <TConsigned> >();

                if (log != null)
                {
                    log(" " + prefix + ".sConsignedObjects Restarted");
                }
            }

            List <ulong> remove = new List <ulong>();

            foreach (KeyValuePair <ulong, List <TConsigned> > objects in list)
            {
                if ((objects.Value == null) || (objects.Value.Count == 0))
                {
                    remove.Add(objects.Key);
                }
                else
                {
                    SimDescription owner = null;

                    for (int i = objects.Value.Count - 1; i >= 0; i--)
                    {
                        TConsigned obj = objects.Value[i];

                        IGameObject consignedObj = null;
                        int         age          = 0;

                        if (obj is ConsignmentRegister.ConsignedObject)
                        {
                            ConsignmentRegister.ConsignedObject castObj = obj as ConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is PotionShopConsignmentRegister.ConsignedObject)
                        {
                            PotionShopConsignmentRegister.ConsignedObject castObj = obj as PotionShopConsignmentRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is BotShopRegister.ConsignedObject)
                        {
                            BotShopRegister.ConsignedObject castObj = obj as BotShopRegister.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        else if (obj is FruitVeggieStand.ConsignedObject)
                        {
                            FruitVeggieStand.ConsignedObject castObj = obj as FruitVeggieStand.ConsignedObject;

                            consignedObj = castObj.Object;
                            age          = castObj.Age;
                        }
                        try
                        {
                            if ((age < 0) || (age >= maximumAge))
                            {
                                if (owner == null)
                                {
                                    owner = SimDescription.Find(objects.Key);
                                }

                                bool success = false;
                                if (owner != null)
                                {
                                    if (owner.CreatedSim != null)
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.CreatedSim);
                                    }

                                    if ((!success) && (owner.Household != null) && (owner.Household.SharedFamilyInventory != null))
                                    {
                                        success = Inventories.TryToMove(consignedObj, owner.Household.SharedFamilyInventory.Inventory);
                                    }
                                }

                                if (!success)
                                {
                                    consignedObj.Destroy();

                                    if (log != null)
                                    {
                                        log(" Over Age Object deleted");
                                    }
                                }
                                else
                                {
                                    if (log != null)
                                    {
                                        log(" Over Age Object returned");
                                    }
                                }

                                objects.Value.RemoveAt(i);
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(consignedObj, e);
                        }
                    }
                }
            }

            foreach (ulong id in remove)
            {
                list.Remove(id);

                if (log != null)
                {
                    log(" Removed: " + id);
                }
            }
        }
示例#27
0
        public bool ImportContent(ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader)
        {
            Inventory ths = mInventory;

            uint[] numArray;
            ths.DestroyItems();
            ths.Owner.InventoryComp.InventoryUIModel.ClearInvalidItemStacks();
            if (!reader.ReadUint32(0x804459ab, out numArray))
            {
                return(false);
            }

            foreach (uint num in numArray)
            {
                IGameObject obj2 = GameObject.GetObject <IGameObject>(objIdTable[(int)num]);
                if (obj2 != null)
                {
                    IPropertyStreamReader child = reader.GetChild(num);
                    if (child != null)
                    {
                        bool flag = true;
                        try
                        {
                            Urnstone urnstone = obj2 as Urnstone;
                            if (urnstone != null)
                            {
                                flag = urnstone.ImportContent(resKeyTable, objIdTable, child, ths.Owner);
                            }
                            else if (obj2 is IPhoneCell)
                            {
                                if (ths.AmountIn <IPhoneCell>() == 0x1)
                                {
                                    flag = false;
                                }
                            }
                            else
                            {
                                flag = obj2.ImportContent(resKeyTable, objIdTable, child);
                            }
                        }
                        catch (Exception)
                        {
                            flag = false;
                        }
                        if (!flag)
                        {
                            obj2.Destroy();
                            continue;
                        }
                    }

                    // Custom
                    if (!Inventories.TryToMove(obj2, ths, false))
                    {
                        obj2.Destroy();
                    }
                }
            }
            reader.ReadInt32(0x86c4285, out ths.mMaxInventoryCapacity, 0x0);
            return(true);
        }
示例#28
0
        public override void OnCollisionStart(IGameObject otherCollider)
        {
            if (otherCollider is FuelCan)
            {
                AddFuel((otherCollider as FuelCan).Amount);
                otherCollider.Destroy();
            }
            else if (otherCollider is HealthPickup)
            {
                Health = 10;
                otherCollider.Destroy();
            }
            else if (otherCollider is Ammo)
            {
                AddAmmo(otherCollider as Ammo);
                otherCollider.Destroy();
            }
            else if (otherCollider is Door && IsCarryingItem("Key"))
            {
                (otherCollider as Door).Open();
                RemoveItemWithTag("Key");
            }
            else if (otherCollider is DoorKey)
            {
                DoorKey key = (otherCollider as DoorKey);
                CarriedItems.Add(key);
                key.Visible = false;
                key.Active  = false;
            }
            else if (otherCollider is AbstractEnemy)
            {
                collidingWith.Add((otherCollider as AbstractEnemy));
                if (!(otherCollider as AbstractEnemy).Tutorial && !IsKicking)
                {
                    if (Timer.IsSet("Invincible"))
                    {
                        return;
                    }
                    Timer.SetTimer("Invincible", 1000);
                    Vector2 repel = new Vector2(-2, -1);
                    if (otherCollider.Transform.Position.X < Transform.Position.X)
                    {
                        repel = new Vector2(2, -1);
                    }
                    Velocity += repel;
                    Health--;
                    AudioEngine.Play("HeroHurt", true);
                }
            }
            else if (otherCollider is Spikes)
            {
                if (Timer.IsSet("Invincible"))
                {
                    return;
                }
                Timer.SetTimer("Invincible", 1000);
                Vector2 repel = new Vector2(-2, -1);
                if (otherCollider.Transform.Position.X < Transform.Position.X)
                {
                    repel = new Vector2(2, -1);
                }
                if ((otherCollider as Spikes).Direction == Direction.SOUTH)
                {
                    repel.Y *= -1;
                }
                Velocity += repel;
                Health--;
                AudioEngine.Play("HeroHurt", true);
            }
            else if (otherCollider is Saw)
            {
                if (Timer.IsSet("Invincible"))
                {
                    return;
                }
                Timer.SetTimer("Invincible", 1000);
                Vector2 repel = new Vector2(-2, -1);
                if (otherCollider.Transform.Position.X < Transform.Position.X)
                {
                    repel = new Vector2(2, -1);
                }
                Velocity += repel;
                Health--;
                AudioEngine.Play("HeroHurt", true);
            }
            else if (otherCollider is MountedGunBullet)
            {
                otherCollider.Destroy();
                Health--;
                AudioEngine.Play("HeroHurt", true);
            }


            base.OnCollisionStart(otherCollider);
        }
示例#29
0
        public static Pattern DiscoverPattern(Sim actor)
        {
            //int skillLevel = actor.SkillManager.GetSkillLevel(SewingSkill.kSewingSkillGUID);
            ResourceKey getPattern       = GetUnregisteredpattern(actor, false);
            ResourceKey emptyRes         = new ResourceKey(0uL, 0u, 0u);
            PatternInfo mPatternInfoInit = new PatternInfo();
            SewingSkill sewingSkill      = actor.SkillManager.AddElement(SewingSkill.kSewingSkillGUID) as SewingSkill;

            try
            {
                ObjectLoader.sewableSetting sSetting = ObjectLoader.dictSettings[getPattern];

                mPatternInfoInit.resKeyPattern          = getPattern;
                mPatternInfoInit.fabricsNeeded          = sSetting.typeFabric;
                mPatternInfoInit.IsMagic                = sSetting.isMagicProject;
                mPatternInfoInit.amountOfFabricToRemove = sSetting.amountRemoveFabric;
                mPatternInfoInit.isClothing             = sSetting.isClothing;
                mPatternInfoInit.mClothingName          = sSetting.clothingName;
                mPatternInfoInit.mWasPatternGifted      = false;

                //mPatternInfoInit.mSkilllevel              = 0;

                if (mPatternInfoInit.isClothing)
                {
                    mPatternInfoInit.mSimOutfit = new CASPart(mPatternInfoInit.resKeyPattern);
                }

                // Pattern OBJD key.
                ResourceKey reskey1 = new ResourceKey(0x19D4F5930F26B2D8, 0x319E4F1D, 0x00000000);
                Pattern.PatternObjectInitParams initData = new Pattern.PatternObjectInitParams(mPatternInfoInit.fabricsNeeded, mPatternInfoInit.IsMagic, mPatternInfoInit.amountOfFabricToRemove, mPatternInfoInit.mSkilllevel, mPatternInfoInit.resKeyPattern, mPatternInfoInit.isClothing, mPatternInfoInit.mSimOutfit, mPatternInfoInit.mClothingName, mPatternInfoInit.mWasPatternGifted);
                Pattern pattern = (Pattern)GlobalFunctions.CreateObjectOutOfWorld(reskey1, null, initData);

                if (pattern.GetType() == typeof(FailureObject))
                {
                    return(null);
                }

                if (pattern != null)
                {
                    IGameObject getname = (GameObject)GlobalFunctions.CreateObjectOutOfWorld(mPatternInfoInit.resKeyPattern, null, initData);
                    if (getname != null)
                    {
                        // Currently uses the pattern object's name. We need to concatinate the sewable's name here as well. Since EA never made a function to get the name direction from the resource key, we need to do this.
                        mPatternInfoInit.Name = pattern.GetLocalizedName() + ": " + getname.GetLocalizedName();
                        pattern.NameComponent.SetName(pattern.GetLocalizedName() + ": " + getname.GetLocalizedName());

                        // Now we finally got the name and can destroy the object.
                        getname.Destroy();
                    }
                    SimDescription desc = actor.SimDescription;
                    pattern.mPatternInfo = mPatternInfoInit;
                    SewingSkill.AddItemsToDiscoveredList(desc.mSimDescriptionId, mPatternInfoInit.resKeyPattern);

                    actor.Inventory.TryToAdd(pattern);
                    sewingSkill.AddPatternCount(1);
                    return(pattern);
                }
                else if (pattern != null && mPatternInfoInit.isClothing)
                {
                    mPatternInfoInit.Name = mPatternInfoInit.mClothingName;
                    pattern.NameComponent.SetName(mPatternInfoInit.mClothingName);

                    pattern.mPatternInfo = mPatternInfoInit;
                    actor.Inventory.TryToAdd(pattern);
                    sewingSkill.AddPatternCount(1);

                    return(pattern);
                }
                else
                {
                    GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n The pattern doesn't exist! Did you delete things from the sewing table .package? Else, contact Lyralei.");
                    return(null);
                }
            }
            catch (Exception ex2)
            {
                GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n REPORT THIS TO LYRALEI: " + ex2.ToString());
                return(null);
            }
        }
示例#30
0
 public void Smash()
 {
     gameManager.Score += scoreValue;
     gameObject.Destroy();
 }
示例#31
0
        public static void DiscoverAllPatterns(Sim actor)
        {
            List <ResourceKey> allPatternsList = new List <ResourceKey>();

            allPatternsList.AddRange(ObjectLoader.EasySewablesList);
            allPatternsList.AddRange(ObjectLoader.MediumSewablesList);
            allPatternsList.AddRange(ObjectLoader.HardSewablesList);
            allPatternsList.AddRange(ObjectLoader.HarderSewablesList);
            allPatternsList.AddRange(ObjectLoader.MagicHarderSewablesList);

            Pattern.PatternInfo mPatternInfoInit = new Pattern.PatternInfo();
            int skillLevel = actor.SkillManager.GetSkillLevel(SewingSkill.kSewingSkillGUID);

            for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++)
            {
                //					if(ObjectLoader.sewableSettings[i].key == getPattern)
                //                  {
                try
                {
                    mPatternInfoInit.resKeyPattern          = ObjectLoader.sewableSettings[i].key;
                    mPatternInfoInit.fabricsNeeded          = ObjectLoader.sewableSettings[i].typeFabric;
                    mPatternInfoInit.IsMagic                = ObjectLoader.sewableSettings[i].isMagicProject;
                    mPatternInfoInit.amountOfFabricToRemove = ObjectLoader.sewableSettings[i].amountRemoveFabric;
                    mPatternInfoInit.mSkilllevel            = 0;
                    mPatternInfoInit.isClothing             = ObjectLoader.sewableSettings[i].isClothing;
                    mPatternInfoInit.mClothingName          = ObjectLoader.sewableSettings[i].clothingName;
                    mPatternInfoInit.mWasPatternGifted      = false;

                    if (mPatternInfoInit.isClothing)
                    {
                        mPatternInfoInit.mSimOutfit = new CASPart(mPatternInfoInit.resKeyPattern);
                    }

                    // Move on if the reskey is invalid.
                    if (mPatternInfoInit.resKeyPattern == ResourceKey.kInvalidResourceKey)
                    {
                        continue;
                    }

                    // Pattern OBJD key.
                    ResourceKey reskey1 = new ResourceKey(0x19D4F5930F26B2D8, 0x319E4F1D, 0x00000000);
                    Pattern.PatternObjectInitParams initData = new Pattern.PatternObjectInitParams(mPatternInfoInit.fabricsNeeded, mPatternInfoInit.IsMagic, mPatternInfoInit.amountOfFabricToRemove, mPatternInfoInit.mSkilllevel, mPatternInfoInit.resKeyPattern, mPatternInfoInit.isClothing, mPatternInfoInit.mSimOutfit, mPatternInfoInit.mClothingName, mPatternInfoInit.mWasPatternGifted);
                    Pattern pattern = (Pattern)GlobalFunctions.CreateObjectOutOfWorld(reskey1, null, initData);

                    //Move on if the pattern resulted into a failure Object
                    if (pattern.GetType() == typeof(FailureObject))
                    {
                        continue;
                    }

                    if (pattern != null && !mPatternInfoInit.isClothing)
                    {
                        IGameObject getname = (GameObject)GlobalFunctions.CreateObjectOutOfWorld(mPatternInfoInit.resKeyPattern, null, initData);
                        if (getname != null)
                        {
                            // Currently uses the pattern object's name. We need to concatinate the sewable's name here as well. Since EA never made a function to get the name direction from the resource key, we need to do this.
                            mPatternInfoInit.Name = pattern.GetLocalizedName() + ":" + getname.GetLocalizedName();
                            pattern.NameComponent.SetName(pattern.GetLocalizedName() + ": " + getname.GetLocalizedName());
                            // Now we finally got the name and can destroy the object.
                            getname.Destroy();
                        }
                        pattern.mPatternInfo = mPatternInfoInit;
                        actor.Inventory.TryToAdd(pattern);
                    }
                    else if (pattern != null && mPatternInfoInit.isClothing)
                    {
                        mPatternInfoInit.Name = mPatternInfoInit.mClothingName;
                        pattern.NameComponent.SetName(mPatternInfoInit.mClothingName);

                        pattern.mPatternInfo = mPatternInfoInit;
                        actor.Inventory.TryToAdd(pattern);
                    }
                    else
                    {
                        GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n The pattern doesn't exist! Did you delete things from the sewing table .package? Else, contact Lyralei.");
                    }
                    SewingSkill.AddItemsToDiscoveredList(actor.mSimDescription.mSimDescriptionId, mPatternInfoInit.resKeyPattern);
                }
                catch (Exception ex2)
                {
                    GlobalOptionsSewingTable.print("Lyralei's Sewing table: \n \n REPORT THIS TO LYRALEI: " + ex2.ToString());
                }
                //}
            }
        }