Пример #1
0
        protected bool PlacePet(MinorPet pet)
        {
            foreach (MinorPetTerrarium terrarium in Sim.LotHome.GetObjects <MinorPetTerrarium>())
            {
                if (terrarium.Pet != null)
                {
                    continue;
                }

                if (!terrarium.AllowsPetType(pet.Data.MinorPetType))
                {
                    continue;
                }

                try
                {
                    Sim.CreatedSim.Inventory.RemoveByForce(pet);
                    pet.ParentToSlot(terrarium, terrarium.PetContainmentSlot);
                    pet.SetObjectToReset();
                    Simulator.Wake(pet.ObjectId, false);

                    IncStat("Pet Placed");
                    return(true);
                }
                catch (Exception e)
                {
                    Common.Exception(pet, e);
                }
            }

            return(false);
        }
Пример #2
0
        public static List <MinorPet> ReturnHomelessPets(Controller c)
        {
            List <MinorPet> homeless = ReturnMinorPets(c);

            foreach (ApartmentFamily af in c.Families)
            {
                if (af.MinorPets != null)
                {
                    foreach (MinorPet p in af.MinorPets)
                    {
                        MinorPet p2 = homeless.Find(delegate(MinorPet p3) { return(p3.ObjectId == p.ObjectId); });
                        if (p2 != null)
                        {
                            homeless.Remove(p2);
                        }
                    }
                }
            }

            return(homeless);
        }
Пример #3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            bool success = false;

            foreach (GameObject obj in GetInventory(Sim))
            {
                Gem gem = obj as Gem;
                if ((gem != null) && (string.IsNullOrEmpty(gem.mCutName)))
                {
                    if (CutGem(gem))
                    {
                        continue;
                    }
                }
                else
                {
                    Metal metal = obj as Metal;
                    if ((metal != null) && (!metal.mHasBeenSmelt))
                    {
                        if (SmeltMetal(metal))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        Rock rock = obj as Rock;
                        if ((rock != null) && (!rock.mAnalyzed))
                        {
                            if (rock.AnalyzeMe(Sim.CreatedSim))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            MinorPet pet = obj as MinorPet;
                            if (pet != null)
                            {
                                if (PlacePet(pet))
                                {
                                    continue;
                                }
                            }
                        }
                    }
                }

                SimDescription sim = Sim;
                if (!sim.IsHuman)
                {
                    sim = SimTypes.HeadOfFamily(Sim.Household);
                }

                int value = Money.Sell(sim, obj);

                mFunds += value;

                AddStat("Sold", value);
                success = true;
            }

            return(success);
        }
Пример #4
0
        public override bool Run()
        {
            try
            {
                if (!Actor.RouteToObjectRadialRangeAndCheckInUse(Target, Target.MinorPetTuning.CaptureRouteRange[0x0], Target.MinorPetTuning.CaptureRouteRange[0x1]))
                {
                    return(false);
                }
                bool escaped = Target.Escaped;
                StandardEntry();
                EnterStateMachine("MinorPetCapture", "Enter", "x");
                SetActor("pet", Target);
                SetParameter("petType", Target.Data.MinorPetType);
                BeginCommodityUpdates();
                bool succeeded = escaped || RandomUtil.RandomChance01(Target.Data.CatchChance);
                if (succeeded)
                {
                    Target.FadeOut();
                    Target.StopBehaviorSMC();
                    AnimateSim("Capture");

                    // Custom
                    if (Actor.Inventory.TryToAdd(Target, false))
                    {
                        string str;
                        if (escaped)
                        {
                            str = Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/MinorPets/Recapture:TNS", new object[] { Actor, Target.GetLocalizedName() });
                        }
                        else
                        {
                            Target.Captured = true;
                            string localizedPetType   = MinorPet.GetLocalizedPetType(Target.Data.MinorPetType);
                            string localizedPetRarity = MinorPet.GetLocalizedPetRarity(Target.Data.Rarity);
                            str = Localization.LocalizeGenderString("Gameplay/Objects/MinorPets:CaptureTNS", new object[] { Actor, Actor, Target.LocalizedSpeciesName, localizedPetType, localizedPetRarity });
                        }

                        Actor.ShowTNSIfSelectable(str, StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId);
                        EventTracker.SendEvent(new MinorPetEvent(EventTypeId.kCaughtMinorPet, Actor, Target, Target.Data.MinorPetType));
                        using (List <Sim> .Enumerator enumerator = Actor.Household.Sims.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Sim current = enumerator.Current;
                                EventTracker.SendEvent(new Event(EventTypeId.kArkBuilder, Actor, Target));
                            }
                        }
                        if (Target is IBird)
                        {
                            Tutorialette.TriggerLesson(Lessons.Birds, null);
                        }
                        else
                        {
                            Tutorialette.TriggerLesson(Lessons.MinorPets, null);
                        }
                    }
                    else
                    {
                        mDestroyPet = true;
                    }
                }
                else
                {
                    Target.FadeOut();
                    mDestroyPet = true;
                    bool flag3 = RandomUtil.CoinFlip();
                    AnimateSim(flag3 ? "CaptureFailBad" : "CaptureFail");
                    if (flag3)
                    {
                        Actor.BuffManager.AddElement(BuffNames.Bitten, Origin.FromUncapturedMinorPet);
                    }
                }
                AnimateSim("Exit");
                EndCommodityUpdates(succeeded);
                StandardExit();
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Пример #5
0
 public override string GetInteractionName(Sim actor, MinorPet target, InteractionObjectPair iop)
 {
     return(base.GetInteractionName(actor, target, new InteractionObjectPair(MinorPet.Capture.Singleton, target)));
 }
Пример #6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            foreach (MinorPetTerrarium terrarium in Lot.GetObjects <MinorPetTerrarium>())
            {
                if (terrarium.HasLivingPet)
                {
                    continue;
                }

                if (terrarium.Pet != null)
                {
                    terrarium.Pet.FadeOut(false, true);

                    IncStat("Dead Pet Removed");
                }

                if (terrarium.Cleanable != null)
                {
                    terrarium.Cleanable.ForceClean();

                    IncStat("Cleaned");
                }

                List <MinorPetSpecies> choices = new List <MinorPetSpecies>();

                foreach (KeyValuePair <MinorPetSpecies, MinorPetData> pair in MinorPet.sData)
                {
                    if (!pair.Value.Stockable)
                    {
                        continue;
                    }

                    if (Lot.Household.FamilyFunds < pair.Value.StockCost)
                    {
                        continue;
                    }

                    if (!terrarium.AllowsPetType(pair.Value.MinorPetType))
                    {
                        continue;
                    }

                    choices.Add(pair.Key);
                }

                AddStat("Choice", choices.Count);

                if (choices.Count > 0)
                {
                    MinorPet pet = MinorPet.Make(RandomUtil.GetRandomObjectFromList(choices), true, false) as MinorPet;
                    if (pet == null)
                    {
                        IncStat("Creation Fail");
                    }
                    else
                    {
                        pet.SetBehaviorSMCStateStopped();

                        if (pet.ParentToSlot(terrarium, terrarium.PetContainmentSlot))
                        {
                            pet.SetOpacity(0f, 0f);
                            pet.FadeIn();
                            pet.SetBehaviorSMCStateActive();
                            pet.StartBehaviorSMC(false);

                            Money.AdjustFunds(Lot.Household, "MinorPets", -pet.Data.StockCost);

                            IncStat("Pet Placed");
                        }
                        else
                        {
                            pet.FadeOut();

                            IncStat("Placement Fail");
                        }
                    }
                }
            }

            return(true);
        }
Пример #7
0
 public override string GetInteractionName(Sim actor, MinorPet target, InteractionObjectPair iop)
 {
     return base.GetInteractionName(actor, target, new InteractionObjectPair(MinorPet.Capture.Singleton, target));
 }
Пример #8
0
        protected override Scenario.GatherResult Gather(List <Scenario> list, ref int continueChance, ref int maximum, ref bool random)
        {
            if (mCollectables == null)
            {
                mCollectables = new List <GameObject>();
                foreach (GameObject obj in Sims3.Gameplay.Queries.GetObjects <GameObject>())
                {
                    if (obj.InInventory)
                    {
                        continue;
                    }

                    if (!obj.InWorld)
                    {
                        continue;
                    }

                    if (obj.LotCurrent == null)
                    {
                        continue;
                    }

                    RockGemMetalBase rock = obj as RockGemMetalBase;
                    if (rock != null)
                    {
                        if (rock.mCollected)
                        {
                            continue;
                        }

                        if (rock.IsOnSpawner)
                        {
                            continue;
                        }

                        mCollectables.Add(obj);
                    }
                    else if (obj is InsectJig)
                    {
                        mCollectables.Add(obj);
                    }
                    else if (obj is MinorPet)
                    {
                        MinorPet pet = obj as MinorPet;

                        if (pet.IsUnconscious)
                        {
                            continue;
                        }

                        if (pet.Captured)
                        {
                            if (!pet.Escaped)
                            {
                                continue;
                            }
                        }

                        mCollectables.Add(obj);
                    }
                    else
                    {
                        DigSite site = obj as DigSite;
                        if ((site != null) && (site.NumTreasuresRemaining > 0))
                        {
                            mCollectables.Add(obj);
                        }
                    }
                }

                if (mCollectables.Count == 0)
                {
                    return(GatherResult.Failure);
                }
            }

            return(base.Gather(list, ref continueChance, ref maximum, ref random));
        }