Beispiel #1
0
 public virtual float GetDelta(Sim sim)
 {
     return(RandomUtil.GetFloat(mMinimum, mMaximum));
 }
Beispiel #2
0
        protected override bool OnPerform()
        {
            string msg = "OnPerform" + Common.NewLine;

            try
            {
                if ((TrafficManager.Singleton == null) || (LotManager.sLots == null))
                {
                    return(true);
                }

                Simulator.DestroyObject(TrafficManager.Singleton.mUpdateTrafficTask);
                TrafficManager.Singleton.mUpdateTrafficTask = ObjectGuid.InvalidObjectGuid;

                while (!TrafficManager.Enabled)
                {
                    FoodTruckManagerEx.Update();
                    SpeedTrap.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours));
                }

                msg += "A";

                List <Lot> list = new List <Lot>();
                foreach (Lot lot in LotManager.AllLots)
                {
                    if (lot.StreetParking == null)
                    {
                        continue;
                    }

                    if (lot.IsWorldLot)
                    {
                        continue;
                    }

                    list.Add(lot);
                }

                if (TrafficManager.GeneratedTrafficTuning.sLotTuning == null)
                {
                    return(true);
                }

                msg += "B";

                PairedListDictionary <Type, int> dictionary = new PairedListDictionary <Type, int>();
                foreach (Type type in TrafficManager.GeneratedTrafficTuning.sLotTuning.Keys)
                {
                    if (!TrafficManager.Enabled)
                    {
                        break;
                    }

                    int[] carRange = TrafficManager.GeneratedTrafficTuning.GetCarRange(type);
                    if (carRange == null)
                    {
                        continue;
                    }

                    if (Math.Max(carRange[0x0], carRange[0x1]) > 0x0)
                    {
                        msg += "C";

                        int numTaxis = RandomUtil.GetInt(carRange[0x0], carRange[0x1]);
                        foreach (Lot lot in list)
                        {
                            if (!TrafficManager.Enabled)
                            {
                                break;
                            }

                            int num2 = (int)Sims3.SimIFace.Queries.CountObjects(type, lot.LotId);
                            if (num2 > 0x0)
                            {
                                msg += "D";

                                PairedListDictionary <Type, int> dictionary2;
                                Type type2;
                                int  num3 = 0x0;
                                if (TrafficManager.sGeneratedCarCount != null)
                                {
                                    TrafficManager.sGeneratedCarCount.TryGetValue(type.ToString(), out num3);
                                }

                                msg += "E";

                                if (!dictionary.ContainsKey(type))
                                {
                                    dictionary.Add(type, 0x0);
                                }

                                msg += "F";

                                (dictionary2 = dictionary)[type2 = type] = dictionary2[type2] + num2;
                                if (num3 < (numTaxis * dictionary[type]))
                                {
                                    msg += "G";

                                    CarNpcWithNoDriver car = GlobalFunctions.CreateObjectOutOfWorld("CarTaxiLightweight", ProductVersion.EP3) as CarNpcWithNoDriver;
                                    if (car != null)
                                    {
                                        Matrix44 mat = new Matrix44();
                                        if (lot.StreetParking.GetParkingSpotForCar(car, ref mat))
                                        {
                                            msg += "H";

                                            Vector3[]    vectorArray;
                                            Quaternion[] quaternionArray;
                                            if (World.FindPlaceOnRoadOffScreen(car.Proxy, mat.pos.V3, FindPlaceOnRoadOption.Road, 100f, out vectorArray, out quaternionArray))
                                            {
                                                msg += "I";

                                                car.GeneratingClassName = type.ToString();
                                                car.PlaceAt(vectorArray[0x0], mat.at.V3, null);
                                                car.DriveAroundFor(RandomUtil.GetFloat(TrafficManager.kCarDriveAroundTimeRange[0x0], TrafficManager.kCarDriveAroundTimeRange[0x1]), TimeUnit.Hours);
                                            }
                                            else
                                            {
                                                car.Destroy();
                                            }

                                            msg += "J";

                                            lot.StreetParking.FreeParkingSpotForCar(car);
                                            SpeedTrap.Sleep((uint)RandomUtil.GetInt(TrafficManager.kAfterSpawnWaitTime[0x0], TrafficManager.kAfterSpawnWaitTime[0x1]));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                msg += "K";

                // Custom
                FoodTruckManagerEx.Update();

                msg += "L";

                uint tickCount = (uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(TrafficManager.kTrafficCheckTime[0x0], TrafficManager.kTrafficCheckTime[0x1]), TimeUnit.Hours);
                SpeedTrap.Sleep(tickCount);
            }
            catch (Exception e)
            {
                Common.Exception(msg, e);
            }

            return(true);
        }
Beispiel #3
0
        public override bool Run()
        {
            try
            {
                string          str2;
                ProxyDefinition definition = InteractionDefinition as ProxyDefinition;

                bool flag2 = false;
                if (mIsMaster)
                {
                    WooHooee.InteractionQueue.AddNext(new RouteToObject.Definition(WooHooer).CreateInstance(Target, WooHooee, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true));

                    flag2 = Target.RouteToMachine(Actor, false, null);
                }
                else
                {
                    flag2 = Target.RouteToMachine(Actor, false, WooHooer);
                }

                if (!flag2)
                {
                    Actor.AddExitReason(ExitReason.Finished);
                    return(false);
                }

                if (mIsMaster && Target.ActorsUsingMe.Contains(WooHooee))
                {
                    return(false);
                }

                Actor.SimDescription.Contactable = false;
                StandardEntry();
                EnterStateMachine("TimeMachine", "Enter", "x");
                SetActor("timeMachine", Target);
                SetParameter("isFuture", definition.Definition.TimePeriod == TimeMachine.TravelTimePeriod.Future);
                Target.SetMaterial("InUse");
                AddOneShotScriptEventHandler(0x66, ToggleHiddenAnimationEvent);
                if (mIsMaster)
                {
                    AddOneShotScriptEventHandler(0x3ee, OnEnterAnimationEvent);
                }
                else
                {
                    Target.EnableRoutingFootprint(Actor);
                }

                AnimateSim("GetIn");
                if ((WooHooee == null) || WooHooee.HasBeenDestroyed)
                {
                    AnimateSim("WooHoo");
                    Target.PushSimsFromFootprint(TimeMachine.sFootprintPathingHash, Actor, null, true);
                    SpeedTrap.Sleep(0x64);

                    string str;
                    Target.PickExitStateAndSound(definition.Definition.TimePeriod, out str, out mExitSound);
                    if (mIsMaster)
                    {
                        AddOneShotScriptEventHandler(0x3e9, OnExitAnimationEvent);
                        AddOneShotScriptEventHandler(0x3ef, OnExitAnimationEvent);
                    }
                    AddOneShotScriptEventHandler(0x67, ToggleHiddenAnimationEvent);
                    AnimateSim(str);
                    Target.SetMaterial("default");
                    AnimateSim("Exit");
                    StandardExit();
                    return(true);
                }
                if (mIsMaster && !Actor.HasExitReason())
                {
                    TimeMachineWooHoo entry = definition.ProxyClone(WooHooer).CreateInstance(Target, WooHooee, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as TimeMachineWooHoo;
                    entry.LinkedInteractionInstance = this;
                    entry.WooHooer = WooHooer;
                    entry.WooHooee = WooHooee;
                    WooHooee.InteractionQueue.AddNext(entry);
                }
                isWooHooing = true;
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                AnimateSim("WooHoo");
                if (StartSync(mIsMaster))
                {
                    BeginCommodityUpdates();

                    try
                    {
                        DoTimedLoop(RandomUtil.GetFloat(TimeMachine.kWooHooMinutesMin, TimeMachine.kWooHooMinutesMax));
                    }
                    finally
                    {
                        EndCommodityUpdates(true);
                    }

                    if (mIsMaster)
                    {
                        CommonWoohoo.TestNakedOutfit(Woohooer.Settings.mNakedOutfitTimeMachine, WooHooer, WooHooee);

                        CommonWoohoo.RunPostWoohoo(Actor, WooHooee, Target, definition.GetStyle(this), definition.GetLocation(Target), true);

                        do
                        {
                            SpeedTrap.Sleep(0xa);
                        }while (Target.UseCount > 0x1);

                        if (CommonPregnancy.IsSuccess(WooHooee, WooHooer, Autonomous, definition.GetStyle(this)))
                        {
                            if (WooHooer.IsMale)
                            {
                                Target.AddTryForBabyAlarm(WooHooer.SimDescription.SimDescriptionId, WooHooee.SimDescription.SimDescriptionId, definition.Definition.TimePeriod);
                            }
                            else
                            {
                                Target.AddTryForBabyAlarm(WooHooee.SimDescription.SimDescriptionId, WooHooer.SimDescription.SimDescriptionId, definition.Definition.TimePeriod);
                            }
                        }
                    }
                }
                else if (mIsMaster)
                {
                    Target.PushSimsFromFootprint(TimeMachine.sFootprintPathingHash, Actor, null, true);
                    SpeedTrap.Sleep(0x64);
                    if (LinkedInteractionInstance != null)
                    {
                        LinkedInteractionInstance.InstanceActor.AddExitReason(ExitReason.CanceledByScript);
                    }
                    do
                    {
                        SpeedTrap.Sleep(0xa);
                    }while (Target.UseCount > 0x1);
                }
                Target.PickExitStateAndSound(definition.Definition.TimePeriod, out str2, out mExitSound);
                if (mIsMaster)
                {
                    AddOneShotScriptEventHandler(0x3e9, new SacsEventHandler(OnExitAnimationEvent));
                    AddOneShotScriptEventHandler(0x3ef, new SacsEventHandler(OnExitAnimationEvent));
                }
                AddOneShotScriptEventHandler(0x67, new SacsEventHandler(ToggleHiddenAnimationEvent));
                AnimateSim(str2);
                Target.SetMaterial("default");
                AnimateSim("Exit");
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);
                isWooHooing = false;
                StandardExit();
                if (!mIsMaster)
                {
                    Actor.RouteAway(1f, 3f, false, GetPriority(), Autonomous, false, true, RouteDistancePreference.PreferNearestToRouteOrigin);
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
        // replaces the method from RabbitHole class - identical except for new slot reassignment code
        public bool RouteNearEntranceAndEnterRabbitHole(Sim a, RabbitHole.IRabbitHoleFollowers inst, RabbitHole.BeforeEnteringRabbitHoleDelegate beforeEntering, bool canUseCar, Route.RouteMetaType routeMetaType, bool playRouteFailure)
        {
            if ((Target.RabbitHoleProxy.EnterSlots.Count == 0) || (Target.RabbitHoleProxy.ExitSlots.Count == 0))
            {
                return(false);
            }
            if (a.IsInRidingPosture && ((Target.RabbitHoleProxy.MountedEnterSlots.Count == 0) || (Target.RabbitHoleProxy.MountedExitSlots.Count == 0)))
            {
                return(false);
            }
            List <Sim>           list    = new List <Sim>();
            CarryingChildPosture posture = a.Posture as CarryingChildPosture;

            if (posture != null)
            {
                list.Add(posture.Child);
            }
            if (inst != null)
            {
                if (inst.SimFollowers != null)
                {
                    foreach (Sim sim in inst.SimFollowers)
                    {
                        posture = sim.Posture as CarryingChildPosture;
                        if (posture != null)
                        {
                            list.Add(posture.Child);
                        }
                    }
                    foreach (Sim sim2 in list)
                    {
                        inst.AddFollower(sim2);
                    }
                }
                else if (list.Count > 0)
                {
                    inst.AddFollower(list[0]);
                }
            }
            bool  flag   = false;
            Route item   = null;
            Sim   parent = null;

            if (a.IsInRidingPosture)
            {
                if (a.Parent is Sim)
                {
                    parent = a.Parent as Sim;
                }
                item = parent.CreateRoute();
                item.ExecutionFromNonSimTaskIsSafe = true;
            }
            else
            {
                item = a.CreateRoute();
            }
            bool flag2 = false;
            int  kRouteAttemptsToEnterRabbitHole = RabbitHole.kRouteAttemptsToEnterRabbitHole;
            Slot slotToUse = Slot.None;

            while ((kRouteAttemptsToEnterRabbitHole > 0) && !flag2)
            {
                kRouteAttemptsToEnterRabbitHole--;
                try
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Add(item);
                    if (playRouteFailure)
                    {
                        item.DoRouteFail = kRouteAttemptsToEnterRabbitHole == 0;
                    }
                    item.SetOption(Route.RouteOption.EnablePlanningAsCar, canUseCar);
                    if (Target.mGuid == RabbitHoleType.Subway)
                    {
                        item.SetOption(Route.RouteOption.EnableSubwayPlanning, false);
                    }
                    if (Target.mGuid == RabbitHoleType.HoverTrainStation)
                    {
                        item.SetOption2(Route.RouteOption2.EnableHoverTrainPlanning, false);
                    }
                    item.SetRouteMetaType(routeMetaType);
                    foreach (Slot slot2 in Target.RabbitHoleProxy.EnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot2].Footprint.ObjectId);
                    }
                    foreach (Slot slot3 in Target.RabbitHoleProxy.MountedEnterSlots)
                    {
                        item.AddObjectToIgnoreForRoute(Target.RabbitHoleProxy.SlotToSlotInfo[slot3].Footprint.ObjectId);
                    }
                    item.PlanToSlot(Target.RabbitHoleProxy, (a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots).ToArray());
                    if (!item.PlanResult.Succeeded())
                    {
                        item.DoRouteFail = playRouteFailure;
                        if (a.IsInRidingPosture)
                        {
                            return(parent.DoRoute(item));
                        }
                        return(a.DoRoute(item));
                    }
                    slotToUse = (Slot)item.PlanResult.mDestSlotNameHash;

                    // Slot Reassignment
                    if ((Target.RabbitHoleProxy.EnterSlots.Count > 1) && (Target.RabbitHoleProxy.EnterSlots.Count <= 5))
                    {
                        slotToUse = ReassignSlot(Target.RabbitHoleProxy.EnterSlots.Count);
                    }
                    List <Sim> followers = (inst == null) ? null : inst.SimFollowers;
                    if ((!flag && (followers != null)) && ((followers.Count > 1) || ((followers.Count == 1) && (followers[0].Posture.Container != a))))
                    {
                        //if (RouteOutside(a, followers, this.RabbitHoleProxy.EnterSlots[0x0], false, true, true, false))
                        if (Target.RouteOutside(a, followers, Target.RabbitHoleProxy.EnterSlots[0], false, true, true, false))
                        {
                            flag  = true;
                            flag2 = true;
                        }
                    }
                    else
                    {
                        //flag2 = RouteOutside(a, followers, none, false, true, false, false);
                        flag2 = Target.RouteOutside(a, followers, slotToUse, false, true, false, false);
                    }
                    if (!flag2 && (kRouteAttemptsToEnterRabbitHole > 0))
                    {
                        if (IntroTutorial.TutorialSim == a)
                        {
                            break;
                        }
                        a.RemoveExitReason(ExitReason.RouteFailed);
                        if (a.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                        {
                            break;
                        }
                        a.LoopIdle();
                        Simulator.Sleep((uint)SimClock.ConvertToTicks(RandomUtil.GetFloat(RabbitHole.kMinSimMinutesToSleepOnFailedRouteAttempt, RabbitHole.kMaxSimMinutesToSleepOnFailedRouteAttempt), TimeUnit.Minutes));
                    }
                    continue;
                }
                finally
                {
                    Target.RabbitHoleProxy.ActiveEntryRoutes.Remove(item);
                }
            }
            item = null;
            if (((a.ExitReason & ExitReason.HigherPriorityNext) == ExitReason.None) && ((a.ExitReason & ExitReason.UserCanceled) == ExitReason.None))
            {
                if (flag2)
                {
                    RabbitHole.NumSuccess++;
                }
                else
                {
                    RabbitHole.NumFail++;
                }
            }
            if (!flag2)
            {
                return(flag2);
            }
            if ((beforeEntering != null) && !beforeEntering())
            {
                List <Sim> simFollowers = null;
                if (inst != null)
                {
                    simFollowers = inst.SimFollowers;
                }
                //RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList<Slot>(a.IsInRidingPosture ? this.RabbitHoleProxy.MountedEnterSlots : this.RabbitHoleProxy.EnterSlots), false, false, true, true);
                Target.RouteOutside(a, simFollowers, RandomUtil.GetRandomObjectFromList <Slot>(a.IsInRidingPosture ? Target.RabbitHoleProxy.MountedEnterSlots : Target.RabbitHoleProxy.EnterSlots), false, false, true, true);
                return(false);
            }
            LeadingHorsePosture posture2 = a.Posture as LeadingHorsePosture;

            if (posture2 != null)
            {
                Sim container = posture2.Container as Sim;
                LeadingHorsePosture.ReleaseHorseFromLeadingPosture(a, container, false);
                Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType);
                Target.AnimateEnterRabbitHole(container, slotToUse, true, routeMetaType);
                return(flag2);
            }
            return(Target.AnimateEnterRabbitHole(a, slotToUse, true, routeMetaType));
        }
Beispiel #5
0
        public static SimDescription MakeAlien(CASAgeGenderFlags age, CASAgeGenderFlags gender, WorldName homeworld, float alienDNAPercentage, bool assignRandomTraits)
        {
            ResourceKey skinTone      = kSkinTones[RandomUtil.GetInt(0, kSkinTones.Length - 1)];
            float       skinToneIndex = GetSkinToneIndex(skinTone);
            SimBuilder  sb            = new SimBuilder();

            sb.Age            = age;
            sb.Gender         = gender;
            sb.Species        = CASAgeGenderFlags.Human;
            sb.SkinTone       = skinTone;
            sb.SkinToneIndex  = skinToneIndex;
            sb.TextureSize    = 1024u;
            sb.UseCompression = true;
            bool flag = (gender == CASAgeGenderFlags.Female);

            SetFacialBlends(sb);
            SimDescription alienDescription = Genetics.MakeSim(sb, age, gender, skinTone, skinToneIndex, kHairColors, homeworld, 4294967295u, true);

            if (alienDescription != null)
            {
                alienDescription.FirstName = SimUtils.GetRandomAlienGivenName(alienDescription.IsMale);
                alienDescription.LastName  = SimUtils.GetRandomAlienFamilyName();
                alienDescription.SetAlienDNAPercentage(alienDNAPercentage);
                alienDescription.VoicePitchModifier = RandomUtil.GetFloat(1.2f, 1.6f);
                alienDescription.VoiceVariation     = (VoiceVariationType)RandomUtil.GetInt(2);

                if (assignRandomTraits)
                {
                    Genetics.AssignRandomTraits(alienDescription);
                }

                if (alienDescription.TeenOrAbove)
                {
                    string s = "a";

                    if (age != CASAgeGenderFlags.Teen)
                    {
                        if (age == CASAgeGenderFlags.Elder)
                        {
                            s = "e";
                        }
                    }
                    else
                    {
                        s = "t";
                    }

                    string      s2     = alienDescription.IsFemale ? "f" : "m";
                    string      name   = s + s2 + "_alienOutfit";
                    ResourceKey key33  = ResourceKey.CreateOutfitKeyFromProductVersion(name, ProductVersion.EP8);
                    SimOutfit   outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Everyday, OutfitCategories.Everyday, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Everyday, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Formalwear, OutfitCategories.Formalwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Formalwear, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Outerwear, OutfitCategories.Outerwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Outerwear, true);
                    }
                }
            }

            return(alienDescription);
        }
Beispiel #6
0
            // Methods
            public override bool Run() // Run
            {
                Slot[] routingSlots = this.Target.GetRoutingSlots();
                bool   flag         = false;
                Route  route        = this.Actor.CreateRoute();

                if (route.PlanToSlot(this.Target, routingSlots).Succeeded())
                {
                    flag = this.Actor.DoRoute(route);
                }
                else if (this.Actor.RouteToObjectRadius(this.Target, 1f))
                {
                    flag = true;
                }
                base.StandardEntry();
                base.BeginCommodityUpdates();
                base.AcquireStateMachine("JellyBean");
                base.SetActor("x", this.Actor);
                base.SetActor("magicjellybeanbush", this.Target);
                base.EnterState("x", "JellyBeanEnter");
                if (RandomUtil.RandomChance01(100) && this.Actor.IsNPC)
                {
                    base.AnimateSim("Poisoned");
                    this.Actor.Kill(SimDescription.DeathType.Shark);
                    KillSimNiecX.MineKill(Actor, SimDescription.DeathType.Shark, true);
                }
                else
                {
                    float @float = RandomUtil.GetFloat(1f);
                    if (@float < JellyBeanBush.kChanceToCatchOnFire && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        if (this.Actor.SimDescription.TeenOrAbove)
                        {
                            this.Actor.BuffManager.AddElement(BuffNames.OnFire, Origin.FromMagicJellyBean);
                            this.Actor.PlayReaction(ReactionTypes.SmellSmoke, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Actor.BuffManager.AddElement(BuffNames.TooSpicy, Origin.FromMagicJellyBean);
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalPositive);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanPos_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalNegative);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanNeg_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend;

                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend) && !this.Actor.IsSimBot)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransPositive);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff + JellyBeanBush.kChanceToGetNegTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend2;
                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend2) && this.Actor.IsNPC)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransNegative);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else
                    {
                        base.AnimateSim("NormalExit");
                    }
                }
                base.EndCommodityUpdates(true);
                base.StandardExit();
                EventTracker.SendEvent(EventTypeId.kEatMagicJellyBean, this.Actor);
                return(true);
            }
Beispiel #7
0
        private static SimDescription MakeAlien(CASAgeGenderFlags age, CASAgeGenderFlags gender, WorldName homeworld, float alienDNAPercentage, bool assignRandomTraits)
        {
            ResourceKey skinTone      = new ResourceKey(0xb93c88cd44494517, 55867754u, 0u);
            float       skinToneIndex = RandomUtil.GetFloat(1f);

            SimBuilder sb = new SimBuilder();

            sb.Age            = age;
            sb.Gender         = gender;
            sb.Species        = CASAgeGenderFlags.Human;
            sb.SkinTone       = skinTone;
            sb.SkinToneIndex  = skinToneIndex;
            sb.TextureSize    = 1024u;
            sb.UseCompression = true;
            ApplyAlienFaceBlend(gender, ref sb);
            float hue        = (skinToneIndex + 0.5f) % 1f;
            float saturation = age == CASAgeGenderFlags.Elder ? 0.25f : 0.75f;

            Color[]        colors           = new Color[] { HSLToRGB(hue, saturation, 0.5f) };
            SimDescription alienDescription = Genetics.MakeSim(sb, age, gender, skinTone, skinToneIndex, colors, homeworld, 4294967295u, true);

            if (alienDescription != null)
            {
                alienDescription.FirstName = SimUtils.GetRandomAlienGivenName(alienDescription.IsMale);
                alienDescription.LastName  = SimUtils.GetRandomAlienFamilyName();
                alienDescription.SetAlienDNAPercentage(alienDNAPercentage);
                alienDescription.VoicePitchModifier = RandomUtil.GetFloat(1.2f, 1.6f);
                alienDescription.VoiceVariation     = (VoiceVariationType)RandomUtil.GetInt(2);

                if (assignRandomTraits)
                {
                    Genetics.AssignRandomTraits(alienDescription);
                }

                if (alienDescription.TeenOrAbove)
                {
                    string s = "a";

                    if (age != CASAgeGenderFlags.Teen)
                    {
                        if (age == CASAgeGenderFlags.Elder)
                        {
                            s = "e";
                        }
                    }
                    else
                    {
                        s = "t";
                    }

                    string      s2     = alienDescription.IsFemale ? "f" : "m";
                    string      name   = s + s2 + "_alienOutfit";
                    ResourceKey key33  = ResourceKey.CreateOutfitKeyFromProductVersion(name, ProductVersion.EP8);
                    SimOutfit   outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Everyday, OutfitCategories.Everyday, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Everyday, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Formalwear, OutfitCategories.Formalwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Formalwear, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Outerwear, OutfitCategories.Outerwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Outerwear, true);
                    }
                }
            }

            return(alienDescription);
        }
Beispiel #8
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            float age = Sim.YearsSinceLastAgeTransition - AgingManager.GetAgingStageLength(Sim.Species, Sim.Age);

            if (age >= 0)
            {
                bool kill = false;

                age = AgingManager.Singleton.AgingYearsToSimDays(age);
                if (age >= GetValue <MaximumAgeOption, int>(Sim))
                {
                    kill = true;

                    IncStat("Beyond Maximum");
                }
                else
                {
                    int cumulChance = GetValue <CumulativeAgeChanceOption, int>(Sim);
                    if (cumulChance > 0)
                    {
                        float chance = AgingManager.Singleton.GetChancePerDayElderWillDie(Sim.Species, false, Sim.IsFrankenstein);

                        chance += cumulChance * age;

                        if (RandomUtil.RandomChance(chance))
                        {
                            kill = true;

                            AddStat("Cumul Success", chance);
                        }
                    }
                    else
                    {
                        AddStat("Too Young", age);
                    }
                }

                if (kill)
                {
                    EventTracker.SendEvent(new MiniSimDescriptionEvent(EventTypeId.kSimGettingOld, Sim));
                    Sim.AgingState.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarm(RandomUtil.GetFloat(12f, 24f), TimeUnit.Hours, Sim.AgingState.AgeTransitionWithoutCakeCallback, "The Cake is a Lie and Then You Die", AlarmType.AlwaysPersisted, Sim);
                    AlarmManager.Global.AlarmWillYield(Sim.AgingState.AgeTransitionWithoutCakeAlarm);

                    IncStat("Aging Initiated");
                }
            }
            else
            {
                AddStat("Still Under Age", age);
            }

            return(false);
        }
Beispiel #9
0
        public static void Inherit(SimDescription child, SimDescription dad, SimDescription mom)
        {
            VoiceVariationType voice = VoiceVariationType.B;

            if (RandomUtil.CoinFlip())
            {
                if (dad != null)
                {
                    voice = dad.VoiceVariation;
                }
                else if (mom != null)
                {
                    voice = mom.VoiceVariation;
                }
                else
                {
                    voice = unchecked ((VoiceVariationType)RandomUtil.GetInt(0, 2));
                }
            }
            else
            {
                if (mom != null)
                {
                    voice = mom.VoiceVariation;
                }
                else if (dad != null)
                {
                    voice = dad.VoiceVariation;
                }
                else
                {
                    voice = unchecked ((VoiceVariationType)RandomUtil.GetInt(0, 2));
                }
            }

            child.VoiceVariation = voice;

            if (child.IsMale)
            {
                if (dad != null)
                {
                    child.VoicePitchModifier = dad.VoicePitchModifier;
                }
                else
                {
                    child.VoicePitchModifier = RandomUtil.GetFloat(0f, 0.6f);
                }
            }
            else
            {
                if (mom != null)
                {
                    child.VoicePitchModifier = mom.VoicePitchModifier;
                }
                else
                {
                    child.VoicePitchModifier = RandomUtil.GetFloat(0.4f, 1f);
                }
            }

            float fMutation = RandomUtil.GetFloat(-0.1f, 0.1f);

            child.VoicePitchModifier += fMutation;

            if (child.VoicePitchModifier < 0f)
            {
                fMutation = RandomUtil.GetFloat(0f, 0.2f);

                child.VoicePitchModifier = fMutation;
            }
            else if (child.VoicePitchModifier > 1f)
            {
                fMutation = RandomUtil.GetFloat(0f, 0.2f);

                child.VoicePitchModifier = 1f - fMutation;
            }
        }
Beispiel #10
0
        public static void CalculateAttractionScore(Relationship ths, bool displayNotice)
        {
            if (Common.AssemblyCheck.IsInstalled("NRaasChemistry"))
            {
                return;
            }

            if (ths == null)
            {
                return;
            }

            ths.AttractionScore = 0;

            //if (ths.AttractionScore == float.PositiveInfinity)
            {
                SimDescription simA = ths.SimDescriptionA;
                SimDescription simB = ths.SimDescriptionB;
                if ((simA != null) && (simB != null) && (simA.IsHuman) && (simB.IsHuman))
                {
                    string reason;
                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (CommonSocials.CanGetRomantic(simA, simB, true, false, true, ref greyedOutTooltipCallback, out reason))
                    {
                        float score = RandomUtil.GetFloat(Relationship.kBaseRandomAttraction[0x0], Relationship.kBaseRandomAttraction[0x1]);

                        score += Woohooer.Settings.mAttractionBaseChanceScoringV3[PersistedSettings.GetSpeciesIndex(simA)];

                        float origScore = score;
                        float highScore = 0f;
                        float newScore  = 0f;

                        switch (ths.LTR.CurrentLTR)
                        {
                        case LongTermRelationshipTypes.Spouse:
                        case LongTermRelationshipTypes.Fiancee:
                            if (score > 0)
                            {
                                score *= 2;
                            }
                            else
                            {
                                score = 0;
                            }
                            break;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        Relationship.AttractionType attractionType = Relationship.AttractionType.None;
                        foreach (Trait traitA in simA.TraitManager.List)
                        {
                            if (traitA.IsReward)
                            {
                                continue;
                            }

                            foreach (Trait traitB in simB.TraitManager.List)
                            {
                                if (traitB.IsReward)
                                {
                                    continue;
                                }

                                if (traitA.TraitGuid == traitB.TraitGuid)
                                {
                                    score += Relationship.kTraitModifier;
                                }
                                else if (TraitManager.DoTraitsConflict(traitA.Guid, traitB.Guid))
                                {
                                    score -= Relationship.kTraitModifier;
                                }
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Trait, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Trait;
                        }

                        Occupation occupation = simA.Occupation;
                        if (occupation != null)
                        {
                            score += occupation.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        Occupation occupation2 = simB.Occupation;
                        if (occupation2 != null)
                        {
                            score += occupation2.CareerLevel * Relationship.kCareerBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Career, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Career;
                        }

                        foreach (Skill skill in simA.SkillManager.List)
                        {
                            score += skill.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        foreach (Skill skill2 in simB.SkillManager.List)
                        {
                            score += skill2.SkillLevel * Relationship.kSkillBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Skill, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Skill;
                        }

                        List <OccultTypes> listA = OccultTypeHelper.CreateList(simA);
                        List <OccultTypes> listB = OccultTypeHelper.CreateList(simB);

                        foreach (OccultTypes typeA in listA)
                        {
                            if (listB.Contains(typeA))
                            {
                                score += Relationship.kBonusForMatchingOccult;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Occult, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Occult;
                        }

                        CelebrityManager celebrityManagerA = simA.CelebrityManager;
                        if (celebrityManagerA != null)
                        {
                            score += celebrityManagerA.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        CelebrityManager celebrityManagerB = simB.CelebrityManager;
                        if (celebrityManagerB != null)
                        {
                            score += celebrityManagerB.Level * Relationship.kCelebrityBonusPerLevel;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Celebrity, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Celebrity;
                        }

                        if (simA.Zodiac == simB.Zodiac)
                        {
                            score += Relationship.kMatchingSignsBonus;
                        }

                        if (simA.FavoriteColor == simB.FavoriteColor)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteFood == simB.FavoriteFood)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        if (simA.FavoriteMusic == simB.FavoriteMusic)
                        {
                            score += Relationship.kMatchingSignsBonus / 2;
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Astro, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Astro;
                        }

                        int familyFundsA = 0;

                        Household house = simA.Household;
                        if (house != null)
                        {
                            familyFundsA = house.FamilyFunds;
                        }

                        if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsA >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        int familyFundsB = 0;

                        house = simB.Household;
                        if (house != null)
                        {
                            familyFundsB = house.FamilyFunds;
                        }
                        if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x2])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x2];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x1])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x1];
                        }
                        else if (familyFundsB >= Relationship.kAttractedMoneyAmounts[0x0])
                        {
                            score += Relationship.kAttractedMoneyBonuses[0x0];
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Money, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Money;
                        }

                        foreach (TraitNames trait in sAttractionTraits)
                        {
                            if (simA.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }

                            if (simB.HasTrait(trait))
                            {
                                score += Relationship.kAttractionLifetimeRewardBonus;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Attractive, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Attractive;
                        }

                        BuffManager buffManagerA = null;
                        if (simA.CreatedSim != null)
                        {
                            buffManagerA = simA.CreatedSim.BuffManager;
                        }

                        BuffManager buffManagerB = null;
                        if (simB.CreatedSim != null)
                        {
                            buffManagerB = simB.CreatedSim.BuffManager;
                        }

                        foreach (BuffNames posBuff in Relationship.kPositiveBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(posBuff)))
                            {
                                score += Relationship.kPerBuffModifier;
                            }
                        }

                        foreach (BuffNames negBuff in Relationship.kNegativeBuffList)
                        {
                            if ((buffManagerA != null) && (buffManagerA.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                            if ((buffManagerB != null) && (buffManagerB.HasElement(negBuff)))
                            {
                                score -= Relationship.kPerBuffModifier;
                            }
                        }

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Buffs, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Buffs;
                        }

                        score += simA.Fitness * 25;
                        score += simB.Fitness * 25;

                        if (simA.Weight < 0)
                        {
                            score += 25 - simA.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simA.Weight * 25;
                        }

                        if (simB.Weight < 0)
                        {
                            score += 25 - simB.Weight * -25;
                        }
                        else
                        {
                            score += 25 - simB.Weight * 25;
                        }

                        int ageA = 0;
                        switch (simA.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageA = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageA = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageA = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageA = 4;
                            break;
                        }

                        int ageB = 0;
                        switch (simB.Age)
                        {
                        case CASAgeGenderFlags.Teen:
                            ageB = 1;
                            break;

                        case CASAgeGenderFlags.YoungAdult:
                            ageB = 2;
                            break;

                        case CASAgeGenderFlags.Adult:
                            ageB = 3;
                            break;

                        case CASAgeGenderFlags.Elder:
                            ageB = 4;
                            break;
                        }

                        score -= Math.Abs(ageA - ageB) * 25;

                        newScore  = score - origScore;
                        origScore = score;

                        if (ths.TestWasNewHighScore(Relationship.AttractionType.Physical, newScore, ref highScore))
                        {
                            attractionType = Relationship.AttractionType.Physical;
                        }

                        ths.AttractionScore = score;

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + "Attraction: " + score + Common.NewLine + attractionType);
                        }

                        if ((ths.AreAttracted) && ((SimTypes.IsSelectable(simA)) || (SimTypes.IsSelectable(simB))))
                        {
                            if (AttractionHelper.TestEnableAttractionNPCController(ths))
                            {
                                if (ths.AttractionNPCController == null)
                                {
                                    ths.AttractionNPCController = new AttractionNPCBehaviorController(ths);
                                }
                            }
                            else
                            {
                                if (ths.AttractionNPCController != null)
                                {
                                    ths.AttractionNPCController.Dispose();
                                }
                            }

                            switch (ths.LTR.CurrentLTR)
                            {
                            case LongTermRelationshipTypes.Spouse:
                            case LongTermRelationshipTypes.Fiancee:
                            case LongTermRelationshipTypes.Ex:
                            case LongTermRelationshipTypes.ExSpouse:
                            case LongTermRelationshipTypes.Partner:
                            case LongTermRelationshipTypes.RomanticInterest:
                                break;

                            default:
                                if (displayNotice)
                                {
                                    Sim createdSimA = simA.CreatedSim;
                                    Sim createdSimB = simB.CreatedSim;
                                    if ((createdSimA != null) && (createdSimB != null))
                                    {
                                        if ((createdSimA.LotCurrent == createdSimB.LotCurrent) && (createdSimA.RoomId == createdSimB.RoomId))
                                        {
                                            VisualEffect effect = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimB.ParentHeadlineFx(effect);
                                            effect.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            VisualEffect effect2 = VisualEffect.Create("ep8AttractionSystem");
                                            createdSimA.ParentHeadlineFx(effect2);
                                            effect2.SubmitOneShotEffect(VisualEffect.TransitionType.SoftTransition);

                                            ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.BalloonData(createdSimA.GetThumbnailKey());
                                            bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimB.ThoughtBalloonManager.ShowBalloon(bd);

                                            ThoughtBalloonManager.BalloonData data2 = new ThoughtBalloonManager.BalloonData(createdSimB.GetThumbnailKey());
                                            data2.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                            createdSimA.ThoughtBalloonManager.ShowBalloon(data2);

                                            TNSNames reasonTNS = ths.GetReasonTNS(attractionType);
                                            if (reasonTNS != TNSNames.None)
                                            {
                                                Sim target = createdSimB.IsSelectable ? createdSimB : createdSimA;
                                                Sim actor  = (createdSimB == target) ? createdSimA : createdSimB;
                                                target.ShowTNSIfSelectable(reasonTNS, actor, target, new object[] { actor, target });
                                            }

                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimB);
                                            EventTracker.SendEvent(EventTypeId.kMeetAttractiveSim, createdSimA);
                                            Audio.StartObjectSound(createdSimB.IsSelectable ? createdSimB.ObjectId : createdSimA.ObjectId, "sting_attraction", false);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        else if (ths.AttractionNPCController != null)
                        {
                            ths.AttractionNPCController.Dispose();
                        }
                    }
                    else
                    {
                        if (greyedOutTooltipCallback != null)
                        {
                            Common.DebugNotify(simA.FullName + Common.NewLine + simB.FullName + Common.NewLine + greyedOutTooltipCallback());
                        }
                    }
                }
            }

            if (ths.AttractionNPCController != null)
            {
                ths.AttractionNPCController.Dispose();
            }
        }
Beispiel #11
0
        public static SimDescription MakeAlien(CASAgeGenderFlags age, CASAgeGenderFlags gender, WorldName homeworld, float alienDNAPercentage, bool assignRandomTraits)
        {
            ResourceKey skinTone = AlienSkinTones[RandomUtil.GetInt(0, AlienSkinTones.Length - 1)];
            float       skinToneIndex;

            if (skinTone == AlienSkinTones[0])
            {
                skinToneIndex = 1f;
            }
            else if (skinTone == AlienSkinTones[1] || skinTone == AlienSkinTones[3] || skinTone == AlienSkinTones[4])
            {
                skinToneIndex = 0.25f + (0.5f * RandomUtil.GetFloat(1f));
            }
            else if (skinTone == AlienSkinTones[2])
            {
                skinToneIndex = 0.5f + (0.5f * RandomUtil.GetFloat(1f));
            }
            else
            {
                skinToneIndex = 0.25f + (0.75f * RandomUtil.GetFloat(1f));
            }

            SimBuilder sb = new SimBuilder();

            sb.Age            = age;
            sb.Gender         = gender;
            sb.Species        = CASAgeGenderFlags.Human;
            sb.SkinTone       = skinTone;
            sb.SkinToneIndex  = skinToneIndex;
            sb.TextureSize    = 1024u;
            sb.UseCompression = true;
            bool flag = (gender == CASAgeGenderFlags.Female);

            float num = flag ? Genetics.kAlienHeadWide[0] : Genetics.kAlienHeadWide[1];

            if (num != 0f)
            {
                ResourceKey key = new ResourceKey(ResourceUtils.HashString64("HeadWide"), 56144010u, 0u);
                sb.SetFacialBlend(key, num);
            }

            num = flag ? Genetics.kAlienJawChinSquare[0] : Genetics.kAlienJawChinSquare[1];

            if (num != 0f)
            {
                ResourceKey key2 = new ResourceKey(ResourceUtils.HashString64("JawChinSquare"), 56144010u, 0u);
                sb.SetFacialBlend(key2, num);
            }

            num = flag ? Genetics.kAlienNoseScaleDown[0] : Genetics.kAlienNoseScaleDown[1];

            if (num != 0f)
            {
                ResourceKey key3 = new ResourceKey(ResourceUtils.HashString64("NoseScaleDown"), 56144010u, 0u);
                sb.SetFacialBlend(key3, num);
            }

            num = flag ? Genetics.kAlienNoseDown[0] : Genetics.kAlienNoseDown[1];

            if (num != 0f)
            {
                ResourceKey key4 = new ResourceKey(ResourceUtils.HashString64("NoseDown"), 56144010u, 0u);
                sb.SetFacialBlend(key4, num);
            }

            num = flag ? Genetics.kAlienNoseThin[0] : Genetics.kAlienNoseThin[1];

            if (num != 0f)
            {
                ResourceKey key5 = new ResourceKey(ResourceUtils.HashString64("NoseThin"), 56144010u, 0u);
                sb.SetFacialBlend(key5, num);
            }

            num = flag ? Genetics.kAlienNoseBridgeRotate[0] : Genetics.kAlienNoseBridgeRotate[1];

            if (num != 0f)
            {
                ResourceKey key6 = new ResourceKey(ResourceUtils.HashString64("NoseBridgeRotate"), 56144010u, 0u);
                sb.SetFacialBlend(key6, num);
            }

            num = flag ? Genetics.kAlienNoseBridgeOut[0] : Genetics.kAlienNoseBridgeOut[1];

            if (num != 0f)
            {
                ResourceKey key7 = new ResourceKey(ResourceUtils.HashString64("NoseBridgeOut"), 56144010u, 0u);
                sb.SetFacialBlend(key7, num);
            }

            num = flag ? Genetics.kAlienNoseBridgeScaleUp[0] : Genetics.kAlienNoseBridgeScaleUp[1];

            if (num != 0f)
            {
                ResourceKey key8 = new ResourceKey(ResourceUtils.HashString64("NoseBridgeScaleUp"), 56144010u, 0u);
                sb.SetFacialBlend(key8, num);
            }

            num = flag ? Genetics.kAlienNoseNostrilsUp[0] : Genetics.kAlienNoseNostrilsUp[1];

            if (num != 0f)
            {
                ResourceKey key9 = new ResourceKey(ResourceUtils.HashString64("NoseNostrilsUp"), 56144010u, 0u);
                sb.SetFacialBlend(key9, num);
            }

            num = flag ? Genetics.kAlienNoseNostrilScale[0] : Genetics.kAlienNoseNostrilScale[1];

            if (num != 0f)
            {
                ResourceKey key10 = new ResourceKey(ResourceUtils.HashString64("NoseNostrilScale"), 56144010u, 0u);
                sb.SetFacialBlend(key10, num);
            }

            num = flag ? Genetics.kAlienNoseTipScaleDown[0] : Genetics.kAlienNoseTipScaleDown[1];

            if (num != 0f)
            {
                ResourceKey key11 = new ResourceKey(ResourceUtils.HashString64("NoseTipScaleDown"), 56144010u, 0u);
                sb.SetFacialBlend(key11, num);
            }

            num = flag ? Genetics.kAlienEyesBrowCurve[0] : Genetics.kAlienEyesBrowCurve[1];

            if (num != 0f)
            {
                ResourceKey key12 = new ResourceKey(ResourceUtils.HashString64("EyesBrowCurve"), 56144010u, 0u);
                sb.SetFacialBlend(key12, num);
            }

            num = flag ? Genetics.kAlienEyesBrowRotate[0] : Genetics.kAlienEyesBrowRotate[1];

            if (num != 0f)
            {
                ResourceKey key13 = new ResourceKey(ResourceUtils.HashString64("EyesBrowRotate"), 56144010u, 0u);
                sb.SetFacialBlend(key13, num);
            }

            num = flag ? Genetics.kAlienMouthLipUpperDefinition[0] : Genetics.kAlienMouthLipUpperDefinition[1];

            if (num != 0f)
            {
                ResourceKey key14 = new ResourceKey(ResourceUtils.HashString64("MouthLipUpperDefinition"), 56144010u, 0u);
                sb.SetFacialBlend(key14, num);
            }

            num = flag ? Genetics.kAlienMouthCurveDown[0] : Genetics.kAlienMouthCurveDown[1];

            if (num != 0f)
            {
                ResourceKey key15 = new ResourceKey(ResourceUtils.HashString64("MouthCurveDown"), 56144010u, 0u);
                sb.SetFacialBlend(key15, num);
            }

            num = flag ? Genetics.kAlienMouthIn[0] : Genetics.kAlienMouthIn[1];

            if (num != 0f)
            {
                ResourceKey key16 = new ResourceKey(ResourceUtils.HashString64("MouthIn"), 56144010u, 0u);
                sb.SetFacialBlend(key16, num);
            }

            num = flag ? Genetics.kAlienTranslateMouthDown[0] : Genetics.kAlienTranslateMouthDown[1];

            if (num != 0f)
            {
                ResourceKey key17 = new ResourceKey(ResourceUtils.HashString64("TranslateMouthDown"), 56144010u, 0u);
                sb.SetFacialBlend(key17, num);
            }

            num = flag ? Genetics.kAlienMouthThin[0] : Genetics.kAlienMouthThin[1];

            if (num != 0f)
            {
                ResourceKey key18 = new ResourceKey(ResourceUtils.HashString64("MouthThin"), 56144010u, 0u);
                sb.SetFacialBlend(key18, num);
            }

            num = flag ? Genetics.kAlienEyeAlienCorrector[0] : Genetics.kAlienEyeAlienCorrector[1];

            if (num != 0f)
            {
                ResourceKey key19 = new ResourceKey(ResourceUtils.HashString64("EyeAlienCorrector"), 56144010u, 0u);
                sb.SetFacialBlend(key19, num);
            }

            num = flag ? Genetics.kAlienEyeAlien[0] : Genetics.kAlienEyeAlien[1];

            if (num != 0f)
            {
                ResourceKey key20 = new ResourceKey(ResourceUtils.HashString64("EyeAlien"), 56144010u, 0u);
                sb.SetFacialBlend(key20, num);
            }

            num = flag ? Genetics.kAlienJawChinDown[0] : Genetics.kAlienJawChinDown[1];

            if (num != 0f)
            {
                ResourceKey key21 = new ResourceKey(ResourceUtils.HashString64("JawChinDown"), 56144010u, 0u);
                sb.SetFacialBlend(key21, num);
            }

            num = flag ? Genetics.kAlienJawChinScaleDown[0] : Genetics.kAlienJawChinScaleDown[1];

            if (num != 0f)
            {
                ResourceKey key22 = new ResourceKey(ResourceUtils.HashString64("JawChinScaleDown"), 56144010u, 0u);
                sb.SetFacialBlend(key22, num);
            }

            num = flag ? Genetics.kAlienJawThin[0] : Genetics.kAlienJawThin[1];

            if (num != 0f)
            {
                ResourceKey key23 = new ResourceKey(ResourceUtils.HashString64("JawThin"), 56144010u, 0u);
                sb.SetFacialBlend(key23, num);
            }

            num = flag ? Genetics.kAlienJawCheeksIn[0] : Genetics.kAlienJawCheeksIn[1];

            if (num != 0f)
            {
                ResourceKey key24 = new ResourceKey(ResourceUtils.HashString64("JawCheeksIn"), 56144010u, 0u);
                sb.SetFacialBlend(key24, num);
            }

            num = flag ? Genetics.kAlienJawCheekSharpness[0] : Genetics.kAlienJawCheekSharpness[1];

            if (num != 0f)
            {
                ResourceKey key25 = new ResourceKey(ResourceUtils.HashString64("JawCheekSharpness"), 56144010u, 0u);
                sb.SetFacialBlend(key25, num);
            }

            num = flag ? Genetics.kAlienEarsRotateY[0] : Genetics.kAlienEarsRotateY[1];

            if (num != 0f)
            {
                ResourceKey key26 = new ResourceKey(ResourceUtils.HashString64("EarsRotateY"), 56144010u, 0u);
                sb.SetFacialBlend(key26, num);
            }

            num = flag ? Genetics.kAlienEarPoint[0] : Genetics.kAlienEarPoint[1];

            if (num != 0f)
            {
                ResourceKey key27 = new ResourceKey(ResourceUtils.HashString64("EarPoint"), 56144010u, 0u);
                sb.SetFacialBlend(key27, num);
            }

            num = flag ? Genetics.kAlienHeadProfileOut[0] : Genetics.kAlienHeadProfileOut[1];

            if (num != 0f)
            {
                ResourceKey key28 = new ResourceKey(ResourceUtils.HashString64("HeadProfileOut"), 56144010u, 0u);
                sb.SetFacialBlend(key28, num);
            }

            num = flag ? Genetics.kAlienEyesLashesThin[0] : Genetics.kAlienEyesLashesThin[1];

            if (num != 0f)
            {
                ResourceKey key29 = new ResourceKey(ResourceUtils.HashString64("EyesLashesThin"), 56144010u, 0u);
                sb.SetFacialBlend(key29, num);
            }

            num = flag ? Genetics.kAlienJawCheeksBoneDown[0] : Genetics.kAlienJawCheeksBoneDown[1];

            if (num != 0f)
            {
                ResourceKey key30 = new ResourceKey(ResourceUtils.HashString64("JawCheeksBoneDown"), 56144010u, 0u);
                sb.SetFacialBlend(key30, num);
            }

            num = flag ? Genetics.kAlienJawChinRound[0] : Genetics.kAlienJawChinRound[1];

            if (num != 0f)
            {
                ResourceKey key31 = new ResourceKey(ResourceUtils.HashString64("JawChinRound"), 56144010u, 0u);
                sb.SetFacialBlend(key31, num);
            }

            num = flag ? Genetics.kAlienNoseTipDepthIn[0] : Genetics.kAlienNoseTipDepthIn[1];

            if (num != 0f)
            {
                ResourceKey key32 = new ResourceKey(ResourceUtils.HashString64("NoseTipDepthIn"), 56144010u, 0u);
                sb.SetFacialBlend(key32, num);
            }

            SimDescription alienDescription = Genetics.MakeSim(sb, age, gender, skinTone, skinToneIndex, AlienHairColors, homeworld, 4294967295u, true);

            if (alienDescription != null)
            {
                alienDescription.FirstName = SimUtils.GetRandomAlienGivenName(alienDescription.IsMale);
                alienDescription.LastName  = SimUtils.GetRandomAlienFamilyName();
                alienDescription.SetAlienDNAPercentage(alienDNAPercentage);
                alienDescription.VoicePitchModifier = RandomUtil.GetFloat(1.2f, 1.6f);
                alienDescription.VoiceVariation     = (VoiceVariationType)RandomUtil.GetInt(2);

                if (assignRandomTraits)
                {
                    Genetics.AssignRandomTraits(alienDescription);
                }

                if (alienDescription.TeenOrAbove)
                {
                    string s = "a";

                    if (age != CASAgeGenderFlags.Teen)
                    {
                        if (age == CASAgeGenderFlags.Elder)
                        {
                            s = "e";
                        }
                    }
                    else
                    {
                        s = "t";
                    }

                    string      s2     = alienDescription.IsFemale ? "f" : "m";
                    string      name   = s + s2 + "_alienOutfit";
                    ResourceKey key33  = ResourceKey.CreateOutfitKeyFromProductVersion(name, ProductVersion.EP8);
                    SimOutfit   outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Everyday, OutfitCategories.Everyday, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Everyday, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Formalwear, OutfitCategories.Formalwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Formalwear, true);
                    }

                    outfit = OutfitUtils.CreateOutfitForSim(alienDescription, key33, OutfitCategories.Outerwear, OutfitCategories.Outerwear, false);

                    if (outfit != null)
                    {
                        alienDescription.AddOutfit(outfit, OutfitCategories.Outerwear, true);
                    }
                }
            }

            return(alienDescription);
        }
Beispiel #12
0
        protected bool PrivatePerform(Common.IStatGenerator stats, SimDescription mom, SimDescription dad, bool forcePitch)
        {
            VoiceVariationType voice = VoiceVariationType.A;

            if (Sim.Child)
            {
                if (RandomUtil.CoinFlip())
                {
                    voice = VoiceVariationType.B;
                }

                stats.IncStat("Voice Child Random");
            }
            else if (Sim.TeenOrAbove)
            {
                if (RandomUtil.CoinFlip())
                {
                    if (dad != null)
                    {
                        voice = dad.VoiceVariation;

                        stats.IncStat("Voice From Dad");
                    }
                    else if (mom != null)
                    {
                        voice = mom.VoiceVariation;

                        stats.IncStat("Voice From Mom");
                    }
                    else
                    {
                        voice = unchecked ((VoiceVariationType)RandomUtil.GetInt(0, 2));

                        stats.IncStat("Voice Teen Random");
                    }
                }
                else
                {
                    if (mom != null)
                    {
                        voice = mom.VoiceVariation;

                        stats.IncStat("Voice From Mom");
                    }
                    else if (dad != null)
                    {
                        voice = dad.VoiceVariation;

                        stats.IncStat("Voice From Dad");
                    }
                    else
                    {
                        voice = unchecked ((VoiceVariationType)RandomUtil.GetInt(0, 2));

                        stats.IncStat("Voice Teen Random");
                    }
                }
            }

            Sim.VoiceVariation = voice;

            if ((forcePitch) || (Sim.Baby))
            {
                if (Sim.IsMale)
                {
                    if (dad != null)
                    {
                        Sim.VoicePitchModifier = dad.VoicePitchModifier;

                        stats.IncStat("Pitch From Dad");
                    }
                    else
                    {
                        Sim.VoicePitchModifier = RandomUtil.GetFloat(0f, 0.6f);

                        stats.IncStat("Pitch Random");
                    }
                }
                else
                {
                    if (mom != null)
                    {
                        Sim.VoicePitchModifier = mom.VoicePitchModifier;

                        stats.IncStat("Pitch From Mom");
                    }
                    else
                    {
                        Sim.VoicePitchModifier = RandomUtil.GetFloat(0.4f, 1f);

                        stats.IncStat("Pitch Random");
                    }
                }

                float fMutation = RandomUtil.GetFloat(-0.1f, 0.1f);

                Sim.VoicePitchModifier += fMutation;

                if (Sim.VoicePitchModifier < 0f)
                {
                    fMutation = RandomUtil.GetFloat(0f, 0.2f);

                    Sim.VoicePitchModifier = fMutation;
                }
                else if (Sim.VoicePitchModifier > 1f)
                {
                    fMutation = RandomUtil.GetFloat(0f, 0.2f);

                    Sim.VoicePitchModifier = 1f - fMutation;
                }

                stats.AddStat("Baby Pitch", Sim.VoicePitchModifier);
            }

            return(true);
        }
Beispiel #13
0
        public override bool Run()
        {
            try
            {
                Definition interactionDefinition = InteractionDefinition as Definition;

                mIsJoin = interactionDefinition.IsJoin;
                if (!Actor.RoutingComponent.RouteToObjectRadialRange(Target, WeatherStone.kSummonWeatherRouteDistance[0], WeatherStone.kSummonWeatherRouteDistance[1], AlwaysRoute ? new Route.RouteOption[] { Route.RouteOption.DoNotEmitDegenerateRoutesForRadialRangeGoals } : null))
                {
                    return(false);
                }

                if ((interactionDefinition.mType == WeatherStone.SummonWeatherType.HuntersStorm) && !Actor.BuffManager.HasElement(BuffNames.Werewolf))
                {
                    InteractionInstance instance = OccultWerewolf.TransformationToWerewolf.Singleton.CreateInstance(Actor, Actor, GetPriority(), Autonomous, CancellableByPlayer);
                    if (instance != null)
                    {
                        if (instance.RunInteraction())
                        {
                            Actor.ClearExitReasons();
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                if (!Target.TryStartSummoningWeather(Actor, interactionDefinition.mType, mIsJoin))
                {
                    if (mIsJoin || !Target.TryStartSummoningWeather(Actor, interactionDefinition.mType, true))
                    {
                        Sim createdSim = null;
                        if (Target.mSummoningSimDescriptionId != 0L)
                        {
                            createdSim = SimDescription.GetCreatedSim(Target.mSummoningSimDescriptionId);
                        }
                        Actor.PlayRouteFailure(createdSim);
                        return(false);
                    }
                    mIsJoin = true;
                }

                StandardEntry();
                EnterStateMachine("SummonWeather", "Enter", "x");
                if (Target.mSummonWeatherType == WeatherStone.SummonWeatherType.BewitchingRain)
                {
                    StartLightningEffects();
                }

                AnimateSim(interactionDefinition.mType.ToString());
                BeginCommodityUpdates();
                if (mIsJoin)
                {
                    mSummonWeatherTimeRemaining = WeatherStone.kSummonWeatherDetermineOutcomeTime[1] + 10f;
                }
                else
                {
                    mSummonWeatherTimeRemaining = RandomUtil.GetFloat(WeatherStone.kSummonWeatherDetermineOutcomeTime[0], WeatherStone.kSummonWeatherDetermineOutcomeTime[1]);
                }

                bool succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), SummonLoop, mCurrentStateMachine);
                EndCommodityUpdates(succeeded);
                StandardExit();
                switch (Target.CurrentWeatherStoneState)
                {
                case WeatherStone.WeatherStoneState.AfterSuccessfulSummon:
                    AnimateSim("Success");
                    BuffNames buffNameFromSummonWeatherType = WeatherStone.GetBuffNameFromSummonWeatherType(Target.mSummonWeatherType);
                    if (buffNameFromSummonWeatherType != BuffNames.Undefined)
                    {
                        Actor.BuffManager.AddElement(buffNameFromSummonWeatherType, Origin.FromWeatherStone);
                    }
                    if (!mIsJoin)
                    {
                        Target.StopElectrifiedEffect();
                    }
                    break;

                case WeatherStone.WeatherStoneState.AfterFailureSummon:
                    if (!Target.mUseExtremeFailure)
                    {
                        AnimateSim("FailureNormal");
                    }
                    else
                    {
                        BuffSinged.SingeViaInteraction(this, Origin.FromLightning);
                        AnimateSim("FailureExtreme");
                    }

                    if (!HasOtherSimsSummoning(Actor))
                    {
                        Target.AnimateChangeWeatherStoneState(false, WeatherStone.WeatherStoneState.Resting);
                    }
                    break;

                default:
                    if (!mIsJoin)
                    {
                        Target.OnSummoningStoppedEarly();
                    }
                    AnimateSim("FailureNormal");
                    break;
                }

                AnimateSim("Exit");
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Beispiel #14
0
        public override bool Run()
        {
            EWCatFishingSkill skill = Actor.SkillManager.GetSkill <EWCatFishingSkill>(EWCatFishingSkill.SkillNameID);

            if (skill == null)
            {
                skill = (Actor.SkillManager.AddElement(EWCatFishingSkill.SkillNameID) as EWCatFishingSkill);
                if (skill == null)
                {
                    return(false);
                }
            }
            if (!DrinkFromPondHelper.RouteToDrinkLocation(Hit.mPoint, Actor, Hit.mType, Hit.mId))
            {
                return(false);
            }
            if (skill.OppFishercatCompleted)
            {
                skill.StartSkillGain(EWCatFishingSkill.kEWFishingSkillGainRateFishercat);
            }
            else
            {
                skill.StartSkillGain(EWCatFishingSkill.kEWFishingSkillGainRateNormal);
            }
            StandardEntry();
            EnterStateMachine("CatHuntInPond", "Enter", "x");
            AddOneShotScriptEventHandler(101u, (SacsEventHandler)(object)new SacsEventHandler(SnapOnExit));
            BeginCommodityUpdates();
            AnimateSim("PrePounceLoop");
            // TODO: If we don't have an opportunity for catching fish faster, we should
            bool flag = DoTimedLoop(RandomUtil.GetFloat(kMinMaxPrePounceTime[0], kMinMaxPrePounceTime[1]));

            if (flag)
            {
                EventTracker.SendEvent(EventTypeId.kGoFishingCat, Actor);
                AnimateSim("FishLoop");
                float successBonus = 0;
                if ((TerrainIsWaterPond && skill.OppPondProvisionerCompleted) ||
                    (!TerrainIsWaterPond && skill.OppSaltaholicCompleted))
                {
                    successBonus = EWCatFishingSkill.kFishCatchingBonus;
                }
                flag = RandomUtil.InterpolatedChance(0f, skill.MaxSkillLevel, kMinMaxSuccesChance[0] + successBonus,
                                                     kMinMaxSuccesChance[1] + successBonus, skill.SkillLevel);
                if (flag)
                {
                    FishType caughtFishType = GetCaughtFishType(Actor, Hit);
                    Fish     fish           = Fish.CreateFishOfRandomWeight(caughtFishType, Actor.SimDescription);

                    // Register will return a message if the fish is new or interesting
                    string message = skill.RegisterCaughtFish(fish, TerrainIsWaterPond);
                    if (fish.CatHuntingComponent != null)
                    {
                        fish.CatHuntingComponent.SetCatcher(Actor);
                    }
                    fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.Carried);
                    SetActor("fish", fish);
                    if (Actor.Motives.GetValue(CommodityKind.Hunger) <= kEatFishHungerThreshold)
                    {
                        message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:EatFishTns",
                                                               Actor, fish.GetLocalizedName(), fish.Weight);
                        Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive);
                        AnimateSim("ExitEat");
                        fish.Destroy();
                        Actor.Motives.ChangeValue(CommodityKind.Hunger, kHungerGainFromEating);
                    }
                    else
                    {
                        message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:PutFishInInventoryTns",
                                                               Actor, fish.GetLocalizedName(), fish.Weight);
                        Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive);
                        AnimateSim("ExitInventory");
                        fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.InInventory);
                        if (!Actor.Inventory.TryToAdd(fish))
                        {
                            fish.Destroy();
                        }
                    }
                }
                else
                {
                    Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:FishFail",
                                                                          Actor.Name), NotificationStyle.kGameMessageNegative);
                    AnimateSim("ExitFailure");
                }
            }
            else
            {
                AnimateSim("ExitPrePounce");
            }
            EndCommodityUpdates(flag);
            StandardExit();
            skill.StopSkillGain();
            return(true);
        }
Beispiel #15
0
        public override bool Run()
        {
            try
            {
                string str;
                mTimeTravelDef = InteractionDefinition as Definition;
                if (!Target.RouteToMachine(Actor, false, null))
                {
                    return(false);
                }

                if (!TimePortalTravelEx.PreTimeTravel1(this))
                {
                    return(false);
                }

                if (!TimePortalTravelEx.PreTimeTravel2(this))
                {
                    return(false);
                }

                Actor.SimDescription.Contactable = false;
                EnterStateMachine("TimeMachine", "Enter", "x");
                SetActor("timeMachine", Target);
                SetParameter("isFuture", mTimeTravelDef.TimePeriod == TimeMachine.TravelTimePeriod.Future);
                AddOneShotScriptEventHandler(0x3ee, OnEnterAnimationEvent);
                AddOneShotScriptEventHandler(0x66, ToggleHiddenAnimationEvent);
                AnimateSim("GetIn");
                Target.EnableRoutingFootprint(Actor);

                mTimeTravelAlarm = AlarmManager.Global.AddAlarmRepeating(RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, new AlarmTimerCallback(TimeTravelCallback), RandomUtil.GetFloat(TimeMachine.kMinutesBetweenAdventureTNSMin, TimeMachine.kMinutesBetweenAdventureTNSMax), TimeUnit.Minutes, "Time Travel Alarm For:" + Actor.SimDescription.FullName, AlarmType.AlwaysPersisted, Actor);
                Target.SetMaterial("InUse");

                bool succeeded = true;
                if (!GameUtils.IsFutureWorld())
                {
                    // Custom
                    succeeded = TimePortalEx.TravelToFuture(null, Actor, new List <Sim>(), new List <ulong>());
                }

                succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                EndCommodityUpdates(succeeded);
                Target.PickExitStateAndSound(mTimeTravelDef.TimePeriod, out str, out mExitSound);
                AddOneShotScriptEventHandler(0x3e9, OnExitAnimationEvent);
                AddOneShotScriptEventHandler(0x3ef, OnExitAnimationEvent);
                AddOneShotScriptEventHandler(0x67, ToggleHiddenAnimationEvent);
                AnimateSim(str);

                if (!TimePortalTravelEx.PostTimeTravel1(this, succeeded))
                {
                    return(false);
                }

                Target.SetMaterial("default");
                AnimateSim("Exit");
                if (!string.IsNullOrEmpty(mTravelSummary))
                {
                    Actor.ShowTNSIfSelectable(mTravelSummary, StyledNotification.NotificationStyle.kGameMessagePositive, Target.ObjectId, Actor.ObjectId);
                }

                StandardExit();
                Target.Repairable.UpdateBreakage(Actor);
                InventingSkill skill = Actor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                if (succeeded && (skill != null))
                {
                    skill.RegisterTimeTravelDone();
                }

                if (GameUtils.IsFutureWorld())
                {
                    EventTracker.SendEvent(EventTypeId.kTravelToPresent, Actor);

                    // Custom
                    GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld();
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
            finally
            {
                TravelUtil.PlayerMadeTravelRequest = false;
            }
        }
Beispiel #16
0
        public override bool Run()
        {
            if (!SafeToSync())
            {
                return(false);
            }

            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                             as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }

            skillTarget = Target.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillTarget == null)
            {
                skillTarget = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                              as EWPetFightingSkill;
                if (skillTarget == null)
                {
                    return(false);
                }
            }

            skillActor.StartSkillGain(skillActor.getSkillGainRate(Actor));
            skillTarget.StartSkillGain(skillTarget.getSkillGainRate(Target));

            BeginCommodityUpdates();
            Actor.RequestWalkStyle(WalkStyle.PetRun);

            if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, GetInteractionName(),
                                                                          allowCarryChild: false), pairedSocial: true, doCallOver: false))
            {
                if (Actor.IsCat)
                {
                    Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                    PouncePosture pouncePosture2 = Actor.Posture as PouncePosture;
                    if (pouncePosture2 != null)
                    {
                        pouncePosture2.ExitPounce();
                        Actor.PopPosture();
                    }
                }
                else
                {
                    Actor.UnrequestWalkStyle(WalkStyle.PetRun);
                }
                EndCommodityUpdates(false);
                return(false);
            }

            Actor.UnrequestWalkStyle(WalkStyle.PetRun);

            if (Actor.IsCat)
            {
                PouncePosture pouncePosture = PouncePosture.Create(Actor);
                pouncePosture.EnterPounce();
                Actor.Posture = pouncePosture;
            }

            StandardEntry(addToUseList: false);
            StartSocial("Fight Pet");
            ((SocialInteraction)LinkedInteractionInstance).Rejected = Rejected;
            mPetFightNoiseBroadcast = new ReactionBroadcaster(Actor, kPetFightLoudBroadcastParams,
                                                              FightBroadcastCallback);
            PetStartleBehavior.CheckForStartle(Actor, StartleType.Fight);
            EnterStateMachine("PetFight", "Enter", "x");
            SetActor("y", Target);
            AnimateSim("Loop Fight");
            // TODO: A fight should reduce fatigue
            InteractionTuning tuning = InteractionObjectPair.Tuning;

            if (tuning != null && tuning.mTradeoff != null)
            {
                using (List <CommodityChange> .Enumerator enumerator = tuning.mTradeoff.mOutputs.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        CommodityChange current = enumerator.Current;
                        if (current.Commodity == CommodityKind.CatScratch)
                        {
                            LinkedInteractionInstance.BeginCommodityUpdate(current, 1f);
                        }
                    }
                }
            }

            bool success = DoTimedLoop(RandomUtil.GetFloat(kPetFightTimeMinMax[0], kPetFightTimeMinMax[1]),
                                       ExitReason.Default);

            EndCommodityUpdates(success);
            Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives.GetMotiveValue(CommodityKind.Energy - 200));
            LinkedInteractionInstance.EndCommodityUpdates(success);
            bool actorWon = DoesActorWinFight();

            if (!actorWon)
            {
                AnimateSim("Swap");
                SetActor("x", Target);
                SetActor("y", Actor);
                skillTarget.wonFight(Actor, Target.LotCurrent == Target.LotHome);
                skillActor.lostFight(Target);
                skillTarget.AddPoints(200f, true, true);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightLose",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessageNegative);
            }
            else
            {
                skillActor.wonFight(Target, Actor.LotCurrent == Actor.LotHome);
                skillTarget.lostFight(Actor);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightWin",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessagePositive);
            }
            AnimateSim("Exit");

            if (Actor.IsCat)
            {
                Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                if (Actor.Posture is PouncePosture)
                {
                    Actor.PopPosture();
                }
            }
            else
            {
                Actor.UnrequestWalkStyle(WalkStyle.PetRun);
            }

            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Fight Pet", wasRecipient: false, wasAccepted: true, actorWon, CommodityTypes.Undefined));
            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Fight Pet", wasRecipient: true, wasAccepted: true, !actorWon, CommodityTypes.Undefined));

            if (mPetFightNoiseBroadcast != null)
            {
                mPetFightNoiseBroadcast.EndBroadcast();
                mPetFightNoiseBroadcast = null;
            }
            FinishSocial("Fight Pet", bApplySocialEffect: true);
            skillActor.StopSkillGain();
            skillTarget.StopSkillGain();
            FinishLinkedInteraction();
            WaitForSyncComplete();
            StandardExit(removeFromUseList: false);

            LikingChange();

            // Check for death conditions BEFORE new wounds assigned
            CheckForDeath(actorWon);
            AssignFightWounds();

            // If this is called from ChaseOffLot, then the target will flee if it loses
            if (!actorWon && actorRunOnLose && Actor.LotCurrent != Actor.LotHome)
            {
                Actor.PopPosture();
                Actor.RequestWalkStyle(WalkStyle.PetRun);
                MakeSimGoHome(Actor, false);
            }
            else if (actorWon && targetRunOnLose && Target.LotCurrent != Target.LotHome)
            {
                Target.PopPosture();
                if (Target.IsHuman)
                {
                    Target.RequestWalkStyle(WalkStyle.MeanChasedRun);
                }
                else
                {
                    Target.RequestWalkStyle(WalkStyle.PetRun);
                }
                MakeSimGoHome(Target, false);
            }

            return(success);
        }
Beispiel #17
0
            // Methods
            public override bool Run() // Run
            {
                Slot[] routingSlots = this.Target.GetRoutingSlots();
                bool   flag         = false;
                Route  route        = this.Actor.CreateRoute();

                if (route.PlanToSlot(this.Target, routingSlots).Succeeded())
                {
                    flag = this.Actor.DoRoute(route);
                }
                else if (this.Actor.RouteToObjectRadius(this.Target, 1f))
                {
                    flag = true;
                }
                //SpeedTrap.Sleep(10);
                base.StandardEntry();
                // Pet Only Crazy CLIP Fixed No CLIP
                if (Actor.IsNPC && Actor.SimDescription.IsPet)
                {
                    this.Actor.Kill(SimDescription.DeathType.PetOldAgeGood);
                    //KillSimNiecX.MineKill(Actor, SimDescription.DeathType.PetOldAgeGood, true);
                    return(false);
                }
                if (Actor.IsInActiveHousehold && Actor.SimDescription.IsPet)
                {
                    this.Actor.Motives.MaxEverything();
                    Actor.Autonomy.Motives.FreezeDecayEverythingExcept(new CommodityKind[0]);
                    return(false);
                }
                base.BeginCommodityUpdates();
                base.AcquireStateMachine("JellyBean");
                base.SetActor("x", this.Actor);
                base.SetActor("magicjellybeanbush", this.Target);
                base.EnterState("x", "JellyBeanEnter");
                if (RandomUtil.RandomChance01(100) && !Actor.IsInActiveHousehold)
                {
                    base.AnimateSim("Poisoned");
                    if (!Actor.CanBeKilled()) // My Mod is CanBeKilled Not Modifed The Sims 3 is File Dll Gameplay
                    {
                        KillSimNiecX.MineKill(Actor, SimDescription.DeathType.Starve);
                        SpeedTrap.Sleep(10);
                        //return false;
                    }
                    Actor.Kill(SimDescription.DeathType.Starve);
                    SpeedTrap.Sleep(10);
                    //return false;
                }
                else
                {
                    float @float = RandomUtil.GetFloat(1f);
                    if (@float < 100 && this.Actor.IsInActiveHousehold)
                    {
                        base.AnimateSim("NormalExit");
                        {
                            this.Actor.Motives.MaxEverything();
                            Actor.Autonomy.Motives.FreezeDecayEverythingExcept(new CommodityKind[0]);
                            return(false);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Actor.BuffManager.AddElement(BuffNames.TooSpicy, Origin.FromMagicJellyBean);
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalPositive);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanPos_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.NormalNegative);
                        VisualEffect.FireOneShotEffect("ep7BuffJellyBeanNeg_main", this.Actor, Sim.FXJoints.Pelvis, VisualEffect.TransitionType.SoftTransition);
                        if (RandomUtil.CoinFlip())
                        {
                            this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.NowOrLater);
                        }
                        else
                        {
                            this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.NowOrLater);
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend;

                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend) && !this.Actor.IsSimBot)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransPositive);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Excited, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.Cheer, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else if (@float < JellyBeanBush.kChanceToCatchOnFire + JellyBeanBush.kChanceToBeElectrocuted + JellyBeanBush.kChanceToGetTooSpicy + JellyBeanBush.kChanceToGetPositiveBuff + JellyBeanBush.kChanceToGetNegitiveBuff + JellyBeanBush.kChanceToGetPosTransBuff + JellyBeanBush.kChanceToGetNegTransBuff && this.Actor.IsNPC)
                    {
                        base.AnimateSim("NormalExit");
                        OccultImaginaryFriend occultImaginaryFriend2;
                        if (!this.Actor.BuffManager.HasTransformBuff() && !this.Actor.IsWearingSpecialOutfit(UniversityMascot.MascotOutfitKey) && !OccultImaginaryFriend.TryGetOccultFromSim(this.Actor, out occultImaginaryFriend2) && this.Actor.IsNPC)
                        {
                            this.Target.ApplyRandomBuff(this.Actor, JellyBeanBush.JellyBeanBuffType.TransNegative);
                            if (RandomUtil.CoinFlip())
                            {
                                this.Actor.PlayReaction(ReactionTypes.Shocked, ReactionSpeed.AfterInteraction);
                            }
                            else
                            {
                                this.Actor.PlayReaction(ReactionTypes.HeadPain, ReactionSpeed.AfterInteraction);
                            }
                        }
                    }
                    else
                    {
                        base.AnimateSim("NormalExit");
                    }
                }
                base.EndCommodityUpdates(true);
                base.StandardExit();
                EventTracker.SendEvent(EventTypeId.kEatMagicJellyBean, this.Actor);
                return(true);
            }
Beispiel #18
0
        public static void FixupOccults(FutureDescendantService ths, FutureDescendantService.FutureDescendantHouseholdInfo descendantHouseholdInfo)
        {
            Common.StringBuilder msg = new Common.StringBuilder("FixupOccults");

            if (descendantHouseholdInfo == null)
            {
                msg += Common.NewLine + "descendantHouseholdInfo null";
            }

            if (descendantHouseholdInfo.DescendantHousehold == null)
            {
                msg += Common.NewLine + "descendantHouseholdInfo.DescendantHousehold null";
            }

            if (!descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty)
            {
                msg += Common.NewLine + "mFutureDescendantHosueholdInfoDirty is false";
            }

            if (Traveler.Settings.mChanceOfOccultHybrid == 0)
            {
                msg += Common.NewLine + "Hybrid 0, returning";
                Common.DebugWriteLog(msg);
                ths.FixupOccults(descendantHouseholdInfo);
                return;
            }

            try
            {
                if (((descendantHouseholdInfo != null) && descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty) && (descendantHouseholdInfo.DescendantHousehold != null))
                {
                    descendantHouseholdInfo.mFutureDescendantHouseholdInfoDirty = false;
                    List <OccultTypes> list  = null;
                    float minAlienPercentage = 0f;
                    float maxAlienPercentage = 0f;
                    if (descendantHouseholdInfo.mProgenitorSimIds != null)
                    {
                        foreach (ulong num in descendantHouseholdInfo.mProgenitorSimIds)
                        {
                            SimDescription item     = null;
                            bool           unpacked = false;
                            msg += Common.NewLine + "Num: " + num;
                            item = FutureDescendantHouseholdInfoEx.CreateProgenitor(num, out unpacked);

                            if (CrossWorldControl.sRetention.transitionedOccults.ContainsKey(num))
                            {
                                list = CrossWorldControl.sRetention.transitionedOccults[num];
                            }
                            else
                            {
                                msg += Common.NewLine + "Couldn't find Sim in transitionedOccults (Maybe they had none?)";
                            }

                            if (item != null)
                            {
                                // EA appears to transition this... I hope :)
                                msg += Common.NewLine + "Working on " + item.FullName;
                                if (SimTypes.IsServiceAlien(item))
                                {
                                    msg += Common.NewLine + "Is full blood Alien";
                                    maxAlienPercentage = 1f;
                                }
                                else
                                {
                                    msg += Common.NewLine + "Died (2)";
                                    if (item.AlienDNAPercentage == 0 && item.IsAlien)
                                    {
                                        msg += Common.NewLine + "IsAlien";
                                        minAlienPercentage = 0;
                                        maxAlienPercentage = 1;
                                    }
                                    else
                                    {
                                        if (item.AlienDNAPercentage > maxAlienPercentage)
                                        {
                                            maxAlienPercentage = item.mAlienDNAPercentage;
                                        }
                                        else if (item.AlienDNAPercentage > minAlienPercentage)
                                        {
                                            minAlienPercentage = item.mAlienDNAPercentage;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                msg += Common.NewLine + "Failed to find SimDesc";
                            }
                        }
                    }

                    if (descendantHouseholdInfo.mHouseholdMembers != null)
                    {
                        foreach (ulong num3 in descendantHouseholdInfo.mHouseholdMembers)
                        {
                            SimDescription newSim = SimDescription.Find(num3);
                            if (newSim != null && !newSim.IsDead)
                            {
                                msg += Common.NewLine + "Processing: " + newSim.FullName;
                                if (Traveler.Settings.mChanceOfOccultMutation == 0)
                                {
                                    msg += Common.NewLine + "Occult Mutation 0";
                                    List <OccultTypes> descendantOccults = OccultTypeHelper.CreateList(newSim, true);
                                    foreach (OccultTypes type in descendantOccults)
                                    {
                                        if (list == null || !list.Contains(type))
                                        {
                                            OccultTypeHelper.Remove(newSim, type, true);
                                        }
                                    }
                                }

                                if (list != null && list.Count > 0)
                                {
                                    msg += Common.NewLine + "Applying Occult Chance to " + newSim.FullName;
                                    bool success = FutureDescendantHouseholdInfoEx.ApplyOccultChance(newSim, list, Traveler.Settings.mChanceOfOccultHybrid, Traveler.Settings.mChanceOfOccultMutation, Traveler.Settings.mMaxOccult);
                                    if (success)
                                    {
                                        msg += Common.NewLine + "Added occults";
                                    }
                                }
                                else
                                {
                                    msg += Common.NewLine + "No occults found...";
                                }

                                if (minAlienPercentage > 0 || maxAlienPercentage > 0 && RandomUtil.CoinFlip())
                                {
                                    float percent = (minAlienPercentage + maxAlienPercentage) / 2f;
                                    float jitter  = SimDescription.kAlienDNAJitterPercent * 2; // 2 generations have passed considering Travelers approach to descendants
                                    percent = RandomUtil.GetFloat(-jitter, jitter);
                                    newSim.SetAlienDNAPercentage(MathUtils.Clamp(percent, 0f, 1f));

                                    msg += Common.NewLine + "Made alien. Percent: " + newSim.mAlienDNAPercentage;
                                }
                            }
                            else
                            {
                                msg += Common.NewLine + "New Sim was null.";
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("", e);
            }
            finally
            {
                Common.DebugWriteLog(msg);
            }
        }
Beispiel #19
0
        public override bool Run()
        {
            try
            {
                mLinkedActor = LinkedInteractionInstance.InstanceActor;

                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

                bool succeeded = true;
                if (mIsMaster)
                {
                    Target.mRoutingSims.Add(Actor);
                    Target.mRoutingSims.Add(mLinkedActor);
                }

                if (!mIsMaster)
                {
                    bool success = false;

                    Actor.RouteToObjectRadialRange(Target, 1.5f, 4f);
                    while (Target.mRoutingSims.Contains(mLinkedActor))
                    {
                        AncientPortalWooHoo interaction = LinkedInteractionInstance as AncientPortalWooHoo;
                        if (interaction == null)
                        {
                            break;
                        }

                        if (mLinkedActor.HasExitReason(ExitReason.Canceled))
                        {
                            break;
                        }

                        if (interaction.mNowWaiting)
                        {
                            success = true;
                            break;
                        }

                        SpeedTrap.Sleep(0xa);
                    }

                    if (!success)
                    {
                        Actor.AddExitReason(ExitReason.RouteFailed);
                        return(false);
                    }
                }

                bool routeSuccess = false;

                Route r = Actor.CreateRoute();
                r.AddObjectToIgnoreForRoute(mLinkedActor.ObjectId);
                r.PlanToSlot(Target, Target.GetRoutingSlots());
                routeSuccess = Actor.DoRoute(r);

                if ((mIsMaster) && (routeSuccess))
                {
                    routeSuccess = !Actor.InUse;
                }

                if (!routeSuccess)
                {
                    Actor.AddExitReason(ExitReason.RouteFailed);
                    return(false);
                }

                CommonWoohoo.TestNakedOutfit(Woohooer.Settings.mNakedOutfitAncientPortal, Actor);

                StandardEntry();

                EnterStateMachine("AncientPortal", "Enter", "x", "portal");

                AddOneShotScriptEventHandler(0x65, HideSim);
                AddOneShotScriptEventHandler(0x66, ShowSim);
                AnimateSim("InsidePortal");

                if (mIsMaster)
                {
                    Target.RemoveFromUseList(Actor);

                    mNowWaiting = true;

                    RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                }

                BeginCommodityUpdates();

                if (mReactToSocialBroadcaster == null)
                {
                    mReactToSocialBroadcaster = new ReactionBroadcaster(Actor, Conversation.ReactToSocialParams, SocialComponentEx.ReactToJealousEventHigh);
                    CommonWoohoo.CheckForWitnessedCheating(Actor, mLinkedActor, !Rejected);
                }

                if ((Target.BoobyTrapComponent != null) ? Target.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription) : false)
                {
                    Target.TriggerTrap(Actor);
                }

                int count = 0;

                while (Target.mRoutingSims.Contains(mLinkedActor))
                {
                    AncientPortalWooHoo interaction = LinkedInteractionInstance as AncientPortalWooHoo;
                    if (interaction == null)
                    {
                        break;
                    }

                    if (mLinkedActor.HasExitReason(ExitReason.Canceled))
                    {
                        break;
                    }

                    if (!mIsMaster)
                    {
                        interaction.mWasSuccess = true;

                        if (count > 30)
                        {
                            break;
                        }
                        count++;

                        Target.SetOpacity(RandomUtil.GetFloat(0f, 1f), 0.25f);
                    }

                    SpeedTrap.Sleep(10);
                }

                if (!mIsMaster)
                {
                    Target.SetOpacity(1f, 1f);
                }

                AnimateSim("Exit");

                for (int i = 0; i < AncientPortal.CatchABeam.kPotentialTravelBuffs.Length; i++)
                {
                    if (RandomUtil.RandomChance(AncientPortal.CatchABeam.kChanceForEachBuff))
                    {
                        Actor.BuffManager.AddElement(AncientPortal.CatchABeam.kPotentialTravelBuffs[i], Origin.FromAncientPortal);
                    }
                }

                if (mIsMaster)
                {
                    RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);
                }

                EndCommodityUpdates(succeeded);
                StandardExit();

                if ((mWasSuccess) && (mIsMaster))
                {
                    CommonWoohoo.RunPostWoohoo(Actor, mLinkedActor, Target, definition.GetStyle(this), definition.GetLocation(Target), true);

                    if (CommonPregnancy.IsSuccess(Actor, mLinkedActor, Autonomous, definition.GetStyle(this)))
                    {
                        CommonPregnancy.Impregnate(Actor, mLinkedActor, Autonomous, definition.GetStyle(this));
                    }
                }

                Actor.Wander(1f, 2f, false, RouteDistancePreference.PreferNearestToRouteOrigin, false);
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
            finally
            {
                Target.mRoutingSims.Remove(Actor);
            }
        }
Beispiel #20
0
        protected void BlendWings(List <SimDescription> parents)
        {
            try
            {
                int wingRate = GetValue <BlendFairyWingsOption, int>();
                if (wingRate > 0)
                {
                    OccultFairy occultType = Sim.OccultManager.GetOccultType(OccultTypes.Fairy) as OccultFairy;
                    if (occultType != null)
                    {
                        CASFairyData fairyData = occultType.FairyData;
                        if (fairyData != null)
                        {
                            List <Vector3> parentColors = new List <Vector3>();
                            foreach (SimDescription parent in parents)
                            {
                                bool    success;
                                Vector3 color = GetWingColor(parent, out success);
                                if (success)
                                {
                                    IncStat("Wing Color: " + color);

                                    parentColors.Add(color);
                                }
                            }

                            if (parentColors.Count >= 2)
                            {
                                RandomUtil.RandomizeListOfObjects(parentColors);

                                Vector3 ahsv = CompositorUtil.ColorShifter.ColorToHsv(parentColors[0]);
                                Vector3 bhsv = CompositorUtil.ColorShifter.ColorToHsv(parentColors[1]);

                                IncStat("Wing ChoiceA: " + ahsv);
                                IncStat("Wing ChoiceB: " + bhsv);

                                Vector3 resultHSV = new Vector3();
                                resultHSV.y = RandomUtil.CoinFlip() ? ahsv.y : bhsv.y;
                                resultHSV.z = RandomUtil.CoinFlip() ? ahsv.z : bhsv.z;

                                float difference = (ahsv.x - bhsv.x) * RandomUtil.GetFloat(wingRate / 100f);
                                if (difference == 0)
                                {
                                    difference = RandomUtil.GetFloat(GetValue <BlendFairyWingsMutateOption, int>() / 100f);
                                    difference = Math.Max(0, Math.Min(1f, difference));
                                }

                                AddStat("Wing Difference", difference);

                                float min = ahsv.x;
                                float max = bhsv.x;
                                if (ahsv.x > bhsv.x)
                                {
                                    min = bhsv.x;
                                    max = ahsv.x;
                                }

                                if (RandomUtil.CoinFlip())
                                {
                                    resultHSV.x = min + difference;
                                }
                                else
                                {
                                    resultHSV.x = max - difference;
                                }

                                IncStat("Wing Result: " + resultHSV);

                                fairyData.WingColor = CompositorUtil.ColorShifter.HsvToColor(resultHSV);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(Sim, e);
            }
        }
Beispiel #21
0
        public static SimDescription MakeDescendant(SimDescription dad, SimDescription mom, SimDescription robotDad, SimDescription robotMom,
                                                    CASAgeGenderFlags age, CASAgeGenderFlags gender, float averageMood, Random pregoRandom, bool interactive, bool updateGenealogy,
                                                    bool setName, WorldName homeWorld, bool plantSimBaby, Pregnancy.BabyCustomizeData customizeData)
        {
            if (robotDad == null && robotMom == null)
            {
                Common.DebugNotify("CommonSurrogatePregnancy.MakeDescendant" + Common.NewLine + " - Fail: Robot Parnets Null");
                return(null);
            }

            SimBuilder simBuilder = new SimBuilder();

            simBuilder.Age            = age;
            simBuilder.Gender         = gender;
            simBuilder.Species        = CASAgeGenderFlags.Human;
            simBuilder.TextureSize    = 1024u;
            simBuilder.UseCompression = true;
            List <SimDescription> list = new List <SimDescription>();

            if (mom != null)
            {
                list.Add(mom);
            }

            if (dad != null)
            {
                list.Add(dad);
            }

            float alienDNAPercentage = SimDescription.GetAlienDNAPercentage(dad, mom, true);

            SimDescription[] array = list.ToArray();
            bool             flag  = alienDNAPercentage >= SimDescription.kMinAlienDNAPercentToBeAlien;

            if (plantSimBaby)
            {
                float skinToneIndex = OccultPlantSim.kBaseGreenSkinIndex + RandomUtil.GetFloat(1f - OccultPlantSim.kBaseGreenSkinIndex);
                simBuilder.SkinTone      = new ResourceKey(2751605866008866797uL, 55867754u, 0u);
                simBuilder.SkinToneIndex = skinToneIndex;
            }
            else
            {
                Genetics.InheritSkinColor(simBuilder, array, pregoRandom, homeWorld);
            }

            if (customizeData.IsBabyCustomized)
            {
                CASPart mPart = customizeData.EyeColorPreset.mPart;

                if (simBuilder.AddPart(mPart))
                {
                    string mPresetString = customizeData.EyeColorPreset.mPresetString;

                    if (!string.IsNullOrEmpty(mPresetString))
                    {
                        OutfitUtils.ApplyPresetStringToPart(simBuilder, mPart, mPresetString);
                    }
                }
            }
            else
            {
                Genetics.InheritEyeColor(simBuilder, array, pregoRandom);
            }

            Genetics.InheritFacialBlends(simBuilder, array, pregoRandom);
            ResourceKey geneticHairstyleKey = Genetics.InheritHairStyle(gender, dad, mom, pregoRandom, flag);

            Genetics.InheritBodyShape(simBuilder, array, pregoRandom);
            bool  flag2 = pregoRandom.Next(0, 2) == 0;
            float num   = (float)pregoRandom.NextDouble() * 100f;

            Color[] array2;

            if (customizeData.IsBabyCustomized)
            {
                array2 = new Color[10];

                for (int i = 0; i < 4; i++)
                {
                    array2[i]     = customizeData.HairColor[i];
                    array2[i + 5] = customizeData.HairColor[i];
                }

                array2[4] = customizeData.HairColor[0];
                array2[9] = customizeData.HairColor[0];
            }
            else if (age == CASAgeGenderFlags.Elder)
            {
                array2 = Genetics.GetRandomElderHairColor();
            }
            else
            {
                array2 = Genetics.InheritHairColor(simBuilder, array, pregoRandom);
            }

            SimDescription baby = Genetics.MakeSim(simBuilder, CASAgeGenderFlags.Baby, gender, simBuilder.SkinTone, simBuilder.SkinToneIndex, array2, homeWorld, 4294967295u, false);

            if (baby == null)
            {
                return(null);
            }

            baby.SetAlienDNAPercentage(alienDNAPercentage);
            baby.GeneticHairstyleKey = geneticHairstyleKey;
            bool flag3 = false;

            if (num < Genetics.kInheritMomHiddenBodyHairStyleChance)
            {
                flag3 |= Genetics.InheritBodyHairstyle(baby, mom);
            }

            if (!flag3 || num < Genetics.kInheritDadBodyHairStyleChance + Genetics.kInheritMomHiddenBodyHairStyleChance)
            {
                Genetics.InheritBodyHairstyle(baby, dad);
            }

            if (customizeData.IsBabyCustomized)
            {
                Genetics.TraitOutcome traitOutcome = Genetics.AssignTraits(baby, dad, mom, false, averageMood, pregoRandom);
                List <TraitNames>     list2        = new List <TraitNames>();
                List <Trait>          list3        = new List <Trait>();

                foreach (Trait current in baby.TraitManager.List)
                {
                    if (!current.IsVisible)
                    {
                        list3.Add(current);
                    }
                }

                baby.TraitManager.RemoveAllElements();

                if (customizeData.CurrentTraits != null)
                {
                    foreach (ITraitEntryInfo current2 in customizeData.CurrentTraits)
                    {
                        baby.TraitManager.AddElement((TraitNames)current2.TraitGuid);
                    }

                    if (customizeData.CurrentTraits.Count != 2)
                    {
                        baby.TraitManager.AddRandomTrait(2 - customizeData.CurrentTraits.Count);
                    }

                    foreach (Trait current3 in list3)
                    {
                        baby.TraitManager.AddHiddenElement((TraitNames)current3.TraitGuid);
                    }
                }

                foreach (Trait current4 in baby.TraitManager.List)
                {
                    if (current4.IsVisible)
                    {
                        list2.Add((TraitNames)current4.TraitGuid);
                    }
                }

                if (interactive)
                {
                    bool   isFemale   = baby.IsFemale;
                    string titleText  = Localization.LocalizeString(baby.IsFemale, "Gameplay/CAS/Genetics:MakeBabyTitle", new object[0]);
                    string promptText = null;

                    switch (traitOutcome)
                    {
                    case Genetics.TraitOutcome.Horrible:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsHorrible";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Bad:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraitsBad";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Average:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescTwoTraits";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale),
                                baby.TraitManager.GetElement((ulong)list2[1]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Good:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDescOneTraits";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                                baby.TraitManager.GetElement((ulong)list2[0]).TraitName(baby.IsFemale)
                            });
                        break;
                    }

                    case Genetics.TraitOutcome.Excellent:
                    {
                        string entryKey = "Gameplay/CAS/Genetics:MakeBabyDesc";
                        promptText = Localization.LocalizeString(baby.IsFemale, entryKey, new object[]
                            {
                                robotMom == null ? mom : robotMom,
                            });
                        break;
                    }
                    }

                    while (string.IsNullOrEmpty(baby.FirstName))
                    {
                        baby.FirstName = StringInputDialog.Show(titleText, promptText, "", CASBasics.GetMaxNameLength(), StringInputDialog.Validation.SimNameText);
                    }
                }
            }
            else
            {
                Genetics.AssignTraits(baby, dad, mom, interactive, averageMood, pregoRandom);
            }

            if (setName)
            {
                baby.LastName = array[0].LastName;

                if (!interactive)
                {
                    baby.FirstName = SimUtils.GetRandomGivenName(baby.IsMale, homeWorld);
                }
            }

            baby.CelebrityManager.SetBabyLevel(Genetics.AssignBabyCelebrityLevel(dad, mom));

            if (updateGenealogy)
            {
                if (robotDad != null && robotMom == null)
                {
                    if (robotDad.Genealogy != null)
                    {
                        robotDad.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (mom != null && mom.Genealogy != null)
                    {
                        mom.Genealogy.AddChild(baby.Genealogy);
                    }
                }
                else if (robotMom != null && robotDad == null)
                {
                    if (robotMom.Genealogy != null)
                    {
                        robotMom.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (dad != null && dad.Genealogy != null)
                    {
                        dad.Genealogy.AddChild(baby.Genealogy);
                    }
                }
                else
                {
                    if (robotDad.Genealogy != null)
                    {
                        robotDad.Genealogy.AddChild(baby.Genealogy);
                    }

                    if (robotMom.Genealogy != null)
                    {
                        robotMom.Genealogy.AddChild(baby.Genealogy);
                    }
                }
            }

            OccultTypes occultTypes = OccultTypes.None;

            if (flag2)
            {
                if (mom != null)
                {
                    CASSupernaturalData supernaturalData = mom.SupernaturalData;

                    if (supernaturalData != null)
                    {
                        occultTypes = supernaturalData.OccultType;
                    }
                }
            }
            else if (dad != null)
            {
                CASSupernaturalData supernaturalData2 = dad.SupernaturalData;

                if (supernaturalData2 != null)
                {
                    occultTypes = supernaturalData2.OccultType;
                }
            }

            if (plantSimBaby)
            {
                occultTypes = OccultTypes.PlantSim;
            }

            if (!OccultManager.DoesOccultTransferToOffspring(occultTypes))
            {
                occultTypes = OccultTypes.None;
            }

            if (RandomUtil.CoinFlip())
            {
                if (occultTypes == OccultTypes.Fairy)
                {
                    baby.AddSupernaturalData(OccultTypes.Fairy);
                    CASFairyData fairyData = baby.SupernaturalData as CASFairyData;

                    if (fairyData != null)
                    {
                        Vector3   wingColor;
                        WingTypes wingType;
                        Genetics.InheritWings(baby, mom, dad, pregoRandom, out wingColor, out wingType);
                        fairyData.WingType  = wingType;
                        fairyData.WingColor = wingColor;
                    }
                }

                if (occultTypes != OccultTypes.None)
                {
                    baby.OccultManager.AddOccultType(occultTypes, false, false, false);
                }
            }

            return(baby);
        }
Beispiel #22
0
        public override bool Run()
        {
            try
            {
                Definition interactionDefinition = InteractionDefinition as Definition;
                if (interactionDefinition == null)
                {
                    return(false);
                }
                if (Autonomous && (interactionDefinition.mUsageType == BusinessPlanning.None))
                {
                    interactionDefinition.mUsageType = (BusinessPlanning)RandomUtil.GetInt(0, 1);
                }
                IInteractionNameCanBeOverriden overriden = this;
                if (overriden != null)
                {
                    overriden.SetInteractionName(interactionDefinition.GetAutonomousInteractionName());
                    UpdateCaption = true;
                }
                if (this.mRunFromInventory && Actor.Inventory.Contains(Target))
                {
                    Vector3 vector;
                    Vector3 vector2;
                    FindGoodLocationBooleans     constraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles;
                    World.FindGoodLocationParams fglParams   = new World.FindGoodLocationParams(Actor.Position, constraints);
                    if (!GlobalFunctions.FindGoodLocation(Target, fglParams, out vector, out vector2))
                    {
                        return(false);
                    }
                    Actor.Inventory.TryToRemove(Target);
                    Target.SetPosition(vector);
                    Target.SetForward(vector2);
                    Target.AddToWorld();
                    Target.SetOpacity(0f, 0f);
                }
                if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), AcademicBusinessPlanner.kTimeToWaitInLine))
                {
                    Actor.Inventory.TryToAdd(Target);
                    return(false);
                }
                if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    Actor.Inventory.TryToAdd(Target);
                    return(false);
                }
                StandardEntry();
                Target.EnableFootprintAndPushSims(AcademicBusinessPlanner.sFootprintHash, Actor);
                if (this.mRunFromInventory)
                {
                    Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                    Target.SetOpacityTransition(0f, 1f, 1f);
                }
                AcquireStateMachine("BusinessPlanner");
                SetActor("x", Actor);
                SetActor("planner", Target);
                List <AcademicDegreeNames> namesNeeded = new List <AcademicDegreeNames>();
                namesNeeded.Add(AcademicDegreeNames.Business);
                BeginCommodityUpdatesAccountingForAcademicPerformance(namesNeeded);
                Target.mCurrentBusinessPlanningType = interactionDefinition.mUsageType;
                mCurrentStateMachine.EnterState("x", "Enter");
                if (!Target.PlannerIsOpen)
                {
                    AnimateSim("Open");
                    Target.PlannerIsOpen = true;
                }
                float kXPIncreasePerWorking     = 0f;
                ReactionBroadcaster broadcaster = null;
                if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan)
                {
                    AnimateSim("Work");
                    this.mWaitTime        = RandomUtil.GetFloat(kMinWorkLength, kMaxWorkLength);
                    kXPIncreasePerWorking = AcademicBusinessPlanner.UseBusinessPlanner.kXPIncreasePerWorking;
                }
                else
                {
                    AnimateSim("Practice");
                    this.mWaitTime        = RandomUtil.GetFloat(kMinPresentationLength, kMaxPresentationLength);
                    kXPIncreasePerWorking = kXPIncreasePerPresentation;
                    broadcaster           = new ReactionBroadcaster(Target, kPresentationBroadcastParams, new ReactionBroadcaster.BroadcastCallback(this.BroadcastCallback));
                }
                DoTimedLoop(this.mWaitTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                bool flag2 = false;
                foreach (InteractionInstance instance in Actor.InteractionQueue.InteractionList)
                {
                    if ((instance != this) && (instance is AcademicBusinessPlanner.UseBusinessPlanner))
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (!flag2 && Target.PlannerIsOpen)
                {
                    AnimateSim("Close");
                    Target.PlannerIsOpen = false;
                }
                AnimateSim("Exit");
                Target.DisableFootprint(AcademicBusinessPlanner.sFootprintHash);
                EndCommodityUpdates(true);
                StandardExit();
                if (!Actor.HasExitReason(ExitReason.Canceled))
                {
                    if (interactionDefinition.mUsageType == BusinessPlanning.PresentBusinessPlan)
                    {
                        EventTracker.SendEvent(EventTypeId.kPresentedBusinessPlan, Actor, Target.LotCurrent);
                    }
                    else if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan)
                    {
                        EventTracker.SendEvent(EventTypeId.kWorkedOnBusinessPlan, Actor, Target.LotCurrent);
                    }
                }
                if (broadcaster != null)
                {
                    broadcaster.EndBroadcast();
                    broadcaster.Dispose();
                    broadcaster = null;
                }

                // Custom, removed IsUniversityWorld() check

                Business occupationAsCareer = Actor.OccupationAsCareer as Business;
                if (occupationAsCareer != null)
                {
                    occupationAsCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking);
                }

                AcademicCareer occupationAsAcademicCareer = Actor.OccupationAsAcademicCareer;
                if (((occupationAsAcademicCareer != null) && (occupationAsAcademicCareer.DegreeInformation != null)) && (occupationAsAcademicCareer.DegreeInformation.AcademicDegreeName == AcademicDegreeNames.Business))
                {
                    occupationAsAcademicCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking);
                }

                if (!Target.PlannerIsOpen)
                {
                    Actor.WaitForExitReason(2f, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                    if (!Actor.Inventory.Contains(Target))
                    {
                        Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true);
                        Actor.Inventory.TryToAdd(Target);
                    }
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Beispiel #23
0
        public bool LoopAnimation()
        {
            if (!DrinkFromPondHelper.RouteToDrinkLocation(Hit.mPoint, Actor, Hit.mType, Hit.mId))
            {
                return(false);
            }
            StandardEntry();
            EnterStateMachine("CatHuntInPond", "Enter", "x");
            AddOneShotScriptEventHandler(101u, (SacsEventHandler)(object)new SacsEventHandler(SnapOnExit));
            AnimateSim("PrePounceLoop");
            // TODO: If we don't have an opportunity for catching fish faster, we should
            float mLoopLengthForNextFish = RandomUtil.GetFloat(EWCatFishHere.kMinMaxPrePounceTime[0], EWCatFishHere.kMinMaxPrePounceTime[1]);
            bool  loopFlag = DoTimedLoop(mLoopLengthForNextFish);

            if (loopFlag)
            {
                EventTracker.SendEvent(EventTypeId.kGoFishingCat, Actor);
                float successBonus = 0;
                // Check for salt and freshwater opportunity bonuses
                if ((TerrainIsWaterPond && skill.OppPondProvisionerCompleted) ||
                    (!TerrainIsWaterPond && skill.OppSaltaholicCompleted))
                {
                    successBonus = EWCatFishingSkill.kFishCatchingBonus;
                }
                bool successFlag = RandomUtil.InterpolatedChance(0f, skill.MaxSkillLevel, EWCatFishHere.kMinMaxSuccesChance[0] + successBonus,
                                                                 EWCatFishHere.kMinMaxSuccesChance[1] + successBonus, skill.SkillLevel);
                FishType fishType = FishType.None;
                AnimateSim("FishLoop");
                if (successFlag)
                {
                    fishType = EWCatFishHere.GetCaughtFishType(Actor, Hit);
                    switch (fishType)
                    {
                    case FishType.None:
                    {
                        // This is just in case there is weirdness.
                        AnimateSim("ExitFailure");
                        break;
                    }

                    default:
                    {
                        Fish fish = Fish.CreateFishOfRandomWeight(fishType, Actor.SimDescription);
                        EventTracker.SendEvent(EventTypeId.kPreyTypeCaught, Actor, fish);
                        string message = skill.RegisterCaughtFish(fish, TerrainIsWaterPond);
                        if (fish.CatHuntingComponent != null)
                        {
                            fish.CatHuntingComponent.SetCatcher(Actor);
                        }
                        fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.Carried);
                        SetActor("fish", (IHasScriptProxy)(object)fish);
                        mNumberFishCaught++;
                        if (Actor.Motives.GetValue(CommodityKind.Hunger) <= EWCatFishHere.kEatFishHungerThreshold)
                        {
                            // Notify if cat eats caught fish
                            message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:EatFishTns",
                                                                   Actor, fish.GetLocalizedName(), fish.Weight);
                            Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive);
                            AnimateSim("ExitEat");
                            fish.Destroy();
                            Actor.Motives.ChangeValue(CommodityKind.Hunger, EWCatFishHere.kHungerGainFromEating);
                        }
                        else
                        {
                            if (message != "")
                            {
                                // Notify if the fish is interesting (new type or weight record)
                                message += Localization.LocalizeString("Gameplay/Abstracts/ScriptObject/CatFishHere:PutFishInInventoryTns",
                                                                       Actor, fish.GetLocalizedName(), fish.Weight);
                                Actor.ShowTNSIfSelectable(message, NotificationStyle.kGameMessagePositive);
                            }
                            AnimateSim("ExitInventory");
                            fish.UpdateVisualState(CatHuntingComponent.CatHuntingModelState.InInventory);
                            if (!Actor.Inventory.TryToAdd(fish))
                            {
                                fish.Destroy();
                            }
                        }
                        break;
                    }
                    }
                }
                else
                {
                    AnimateSim("ExitFailure");
                }
            }
            else
            {
                AnimateSim("ExitPrePounce");
            }
            StandardExit();
            return(loopFlag);
        }
Beispiel #24
0
        public static void RandomizeBlends(Logger log, SimDescription me, Vector2 rangeIfSet, bool addToExisting, Vector2 rangeIfUnset, bool propagate, bool disallowAlien)
        {
            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, CASParts.sPrimary))
            {
                if (!builder.OutfitValid)
                {
                    return;
                }

                foreach (BlendUnit blend in BlendUnits)
                {
                    switch (me.Species)
                    {
                    case CASAgeGenderFlags.Human:
                        switch (blend.Category)
                        {
                        case FacialBlendCategories.Dog:
                        case FacialBlendCategories.LittleDog:
                        case FacialBlendCategories.Cat:
                        case FacialBlendCategories.PetCommon:
                        case FacialBlendCategories.Horse:
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Cat:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Cat))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.LittleDog:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.LittleDog))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Dog:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Dog))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Horse:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Horse))
                        {
                            continue;
                        }
                        break;
                    }

                    if (disallowAlien)
                    {
                        ResourceKey alienEyeCKey = new ResourceKey(ResourceUtils.HashString64("EyeAlienCorrector"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeCKey)
                        {
                            continue;
                        }

                        ResourceKey alienEyeKey = new ResourceKey(ResourceUtils.HashString64("EyeAlien"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeKey)
                        {
                            continue;
                        }

                        ResourceKey alienEarKey = new ResourceKey(ResourceUtils.HashString64("EarPoint"), 0x358b08a, 0);
                        if (blend.mKey == alienEarKey)
                        {
                            continue;
                        }
                    }

                    float value = GetValue(builder.Builder, blend);

                    if (value == 0)
                    {
                        value = RandomUtil.GetFloat(rangeIfUnset.x, rangeIfUnset.y);

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Unset Final 100s", (int)(value * 100));
                        }
                    }
                    else
                    {
                        if (!addToExisting)
                        {
                            value = 0;
                        }

                        float newValue = RandomUtil.GetFloat(rangeIfSet.x, rangeIfSet.y);

                        if (log != null)
                        {
                            log("Set Delta 100s", (int)(newValue * 100));
                        }

                        value += newValue;

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Set Final 100s", (int)(value * 100));
                        }
                    }

                    SetValue(builder.Builder, blend, value);
                }
            }

            if (propagate)
            {
                new SavedOutfit.Cache(me).PropagateGenetics(me, CASParts.sPrimary);
            }
        }
Beispiel #25
0
        public static void DayPassedCallback(AgingManager ths)
        {
            List <AgingState> statesToGraduate = new List <AgingState>();
            bool silentGraduation = true;
            bool noSchools        = Sims3.Gameplay.Queries.CountObjects <ISchoolRabbitHole>() == 0x0;

            if (ths.Enabled)
            {
                float hoursPassedOfDay = SimClock.HoursPassedOfDay;
                float agingYearsPassed = 1f / ths.SimDaysPerAgingYear;
                if (hoursPassedOfDay > AgingManager.kHourToShowBirthdayMessage)
                {
                    foreach (AgingState state in ths.AgingStates)
                    {
                        if (state != null)
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                        }
                    }
                    return;
                }

                if (!GameUtils.IsFutureWorld())
                {
                    ths.AgeVacationWorldSims(agingYearsPassed);
                }

                foreach (AgingState state in ths.AgingStates)
                {
                    try
                    {
                        if (ths.IsAgingStateValid(state))
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                            state.DayPassedSinceLastTransition         = true;
                            Sim createdSim = state.SimDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                Sims3.Gameplay.UI.HudModel hudModel = Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel;
                                if (hudModel != null)
                                {
                                    hudModel.OnSimAgeChanged(createdSim.ObjectId);
                                }
                            }

                            // Custom
                            CommonDayPassedUpdates(ths, state, statesToGraduate, ref silentGraduation, noSchools);

                            if (((state.AgeTransitionEarlyMessageAlarm != AlarmHandle.kInvalidHandle) || (state.AgeTransitionWithoutCakeAlarm != AlarmHandle.kInvalidHandle)) || (state.AgeTransitionMessageAlarm != AlarmHandle.kInvalidHandle))
                            {
                                float timeLeft = AlarmManager.Global.GetTimeLeft(state.AgeTransitionWithoutCakeAlarm, TimeUnit.Hours);
                                if ((timeLeft > 0f) && (timeLeft <= 24f))
                                {
                                    continue;
                                }
                                ths.CancelAgingAlarmsForSim(state);
                            }

                            IAlarmOwner simDescription = state.SimDescription;
                            if (ths.SimIsOldEnoughToTransition(state))
                            {
                                if (state.SimDescription.Age == CASAgeGenderFlags.Elder)
                                {
                                    EventTracker.SendEvent(new MiniSimDescriptionEvent(EventTypeId.kSimGettingOld, state.SimDescription));

                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarm(RandomUtil.GetFloat(12f, 24f), TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, "The Cake is a Lie and Then You Die", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);
                                    }
                                }
                                else
                                {
                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        float time     = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                        float maxValue = float.MaxValue;
                                        if (createdSim != null)
                                        {
                                            maxValue = (24f + createdSim.HoursUntilWakeupTime) - AgingManager.kHourToAgeWithoutCake;
                                        }

                                        maxValue = Math.Min(maxValue, AgingManager.kLatestHourToAgeWithoutCake - hoursPassedOfDay);

                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarmRepeating(maxValue, TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, 15f, TimeUnit.Minutes, "The Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);

                                        if (!state.SimDescription.IsEnrolledInBoardingSchool())
                                        {
                                            state.AgeTransitionMessageAlarm = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, state.ShowAgeTransitionMessageCallback, "Tell Player that the Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                            AlarmManager.Global.AlarmWillYield(state.AgeTransitionMessageAlarm);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (!state.SimDescription.Elder && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowBirthdayMessage))
                                {
                                    float num6 = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                    state.AgeTransitionEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num6, TimeUnit.Hours, state.ShowAgeTransitionEarlyMessageCallback, "Tell player that the cake will be a lie in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.AgeTransitionEarlyMessageAlarm);
                                }

                                if (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowGraduationMessage))
                                {
                                    float num7 = AgingManager.kHourToShowGraduationMessage - hoursPassedOfDay;
                                    state.GraduationEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num7, TimeUnit.Hours, state.ShowGraduationEarlyMessageCallback, "Tell player that graduation will be in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.GraduationEarlyMessageAlarm);
                                }
                            }

                            if (((createdSim != null) && createdSim.IsSelectable) && (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysBeforeAgingToDelayGraduation)))
                            {
                                statesToGraduate = null;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state.SimDescription, e);
                    }
                }
            }
            else
            {
                foreach (AgingState state3 in ths.AgingStates)
                {
                    if (ths.IsAgingStateValid(state3))
                    {
                        state3.DayPassedSinceLastTransition = true;

                        // Custom
                        CommonDayPassedUpdates(ths, state3, statesToGraduate, ref silentGraduation, noSchools);
                    }
                }
            }

            if ((statesToGraduate != null) && (statesToGraduate.Count > 0x0))
            {
                foreach (AgingState state4 in statesToGraduate)
                {
                    try
                    {
                        if (noSchools)
                        {
                            state4.SimDescription.GraduationType = GraduationType.NoSchool;
                        }
                        else if (silentGraduation)
                        {
                            state4.SimDescription.GraduationType = GraduationType.Graduate;
                            Sim sim2 = state4.SimDescription.CreatedSim;
                            if (sim2 != null)
                            {
                                sim2.SetDefaultGraduatedStateIfNeccessary();
                            }
                        }
                        else
                        {
                            School.GraduateSim(state4.SimDescription);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state4.SimDescription, e);
                    }
                    finally
                    {
                        state4.ShouldBeGraduating = false;
                    }
                }
            }
        }
Beispiel #26
0
        public static bool ProcessAllInteraction(Sim actorIsCurrentTask)
        {
            if (actorIsCurrentTask == null ||
                actorIsCurrentTask.ObjectId.mValue != ScriptCore.Simulator.Simulator_GetCurrentTaskImpl() ||
                !Simulator.CheckYieldingContext(false))
            {
                return(false);
            }

            bool okI = false;
            var  sim = actorIsCurrentTask;

            NFinalizeDeath.CheckYieldingContext();

            if (Simulator.GetProxy(sim.ObjectId) == null)
            {
                NFinalizeDeath.ThrowResetException(null);
            }

            var simIQ = sim.InteractionQueue;


            try
            {
                if (sim.SimDescription == null)
                {
                    sim.mSimDescription = Create.NiecNullSimDescription(true, false, true);
                }

                if (simIQ == null)
                {
                    sim.mInteractionQueue = simIQ = new Sims3.Gameplay.ActorSystems.InteractionQueue(sim);
                }
                else
                {
                    if (simIQ.mInteractionList == null)
                    {
                        simIQ.mInteractionList = new List <InteractionInstance>();
                    }
                    else
                    {
                        while (simIQ.mInteractionList != null && niec_std.list_remove(simIQ.mInteractionList, null))
                        {
                            Simulator.Sleep(0);
                        }
                    }
                }
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); }
            catch (StackOverflowException)
            { sim.mPosture = null; throw; }
            catch (ResetException)
            { throw; }
            catch
            {
                NFinalizeDeath.CheckYieldingContext();

                for (int i = 0; i < 45; i++)
                {
                    Simulator.Sleep(0);
                }
            }

            try
            {
                simIQ.mCurrentTransitionInteraction = null;
                if (!NiecHelperSituation.__acorewIsnstalled__ && simIQ.mRunningInteractions.Count != 0)
                {
                    simIQ.OnReset();
                }

                ShouldBabyOrToddler(simIQ);

                var simIQList = simIQ.mInteractionList;
                if (simIQList == null || simIQList.Count == 0)
                {
                    return(false);
                }

                var simIQListArray = simIQList.ToArray();
                for (int i = 0; i < simIQListArray.Length; i++)
                {
                    InteractionInstance inCurrentInteraction = simIQListArray[i];
                    if (inCurrentInteraction == null || inCurrentInteraction.InteractionDefinition == null)
                    {
                        while (simIQList != null && niec_std.list_remove(simIQList, null))
                        {
                            Simulator.Sleep(0);
                            simIQList = simIQ.mInteractionList;
                        }

                        if (simIQList == null)
                        {
                            break;
                        }

                        continue;
                    }

                    if (simIQList.IndexOf(inCurrentInteraction) != 0)
                    {
                        break;
                    }

                    if (simIQList == null)
                    {
                        break;
                    }

                    if (sim.mPosture != null)
                    {
                        int  num  = 4;
                        bool flag = false;
                        int  num2 = 10;

                        sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.PlayRouteFailNextTimeOnly;

                        List <InteractionObjectPair> list = new List <InteractionObjectPair>();

                        while (num > 0 && num2 > 0)
                        {
                            if (!inCurrentInteraction.Autonomous)
                            {
                                inCurrentInteraction.Target.ClearBlockTime();
                                if (sim.mPosture.Container != null)
                                {
                                    sim.mPosture.Container.ClearBlockTime();
                                }
                            }

                            sim.ClearExitReasons();

                            if (!inCurrentInteraction.Target.PreTransition(inCurrentInteraction))
                            {
                                inCurrentInteraction.PostureTransitionFailed(false);

                                sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                            }

                            InteractionInstance interactionInstance2 = null;
                            if (inCurrentInteraction.Target is IGlass && sim.SimDescription.IsBonehilda)
                            {
                                inCurrentInteraction.PosturePreconditions = null;
                            }

                            interactionInstance2 = ((inCurrentInteraction.PosturePreconditions != null || sim.Posture is IHaveCustomTransitionForNullPosturePreconditions) ? sim.Posture.GetTransition(inCurrentInteraction) : sim.Posture.GetStandingTransition());
                            if (interactionInstance2 == null)
                            {
                                num = 0;
                            }

                            else
                            {
                                if (num == 4 && (!inCurrentInteraction.Test() || (!inCurrentInteraction.IsTargetValid())))
                                {
                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                                }

                                if (list.Contains(interactionInstance2.InteractionObjectPair))
                                {
                                    CleanUpOrOnFailureInteraction(sim, interactionInstance2, false, false);
                                    num--;
                                    continue;
                                }

                                list.Add(interactionInstance2.InteractionObjectPair);

                                sim.ClearExitReasons();
                                simIQ.mCurrentTransitionInteraction = interactionInstance2;
                                flag = false;

                                try
                                {
                                    if (inCurrentInteraction.Target != null && sim.LookAtManager != null && inCurrentInteraction.Target.Parent != sim)
                                    {
                                        sim.LookAtManager.SetInteractionLookAt(inCurrentInteraction.Target as GameObject, Sim.LookAtInterestingnessOfTargetWhenRunningTransition, LookAtJointFilter.HeadBones);
                                    }
                                    flag = NFinalizeDeath._RunInteractionWithoutCleanUp(interactionInstance2);
                                }
                                finally
                                {
                                    sim.ClearSynchronizationData();
                                    CleanUpOrOnFailureInteraction(sim, interactionInstance2, false, flag);
                                    simIQ.mCurrentTransitionInteraction = null;
                                }

                                if (inCurrentInteraction.Target == null || inCurrentInteraction.Target.HasBeenDestroyed)
                                {
                                    simIQ.mIsHeadInteractionLocked = false;
                                    sim.PlayRouteFailFrequency     = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }
                                if (flag && simIQ.GetHeadInteraction() != inCurrentInteraction)
                                {
                                    simIQ.mIsHeadInteractionLocked = false;
                                    sim.PlayRouteFailFrequency     = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }

                                if (flag && sim.HasExitReason(ExitReason.SuspensionRequested))
                                {
                                    RemoveQueue(false, simIQ, simIQList, sim, inCurrentInteraction);
                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }

                                if (sim.HasExitReason(ExitReason.CancelExternal))
                                {
                                    if (!(sim.Posture is IDoNotGoToStandingOnTransitionFailed))
                                    {
                                        InteractionInstance standingTransition = sim.Posture.GetStandingTransition();
                                        if (standingTransition != null)
                                        {
                                            NFinalizeDeath.AddItemToList(simIQ.mInteractionList, standingTransition);
                                        }
                                    }
                                    inCurrentInteraction.PostureTransitionFailed(flag);

                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                                }

                                if (!flag)
                                {
                                    if (ShouldTimeUpdate(interactionInstance2))
                                    {
                                        interactionInstance2.Target.UpdateBlockTime();
                                    }
                                    num = 4;
                                }
                            }
                            num--;
                            num2--;
                        }

                        sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;

                        if (sim.Posture != null && !sim.Posture.Satisfies(inCurrentInteraction.PosturePreconditions, inCurrentInteraction.Target, sim.Posture.GetRequiredCheck()))
                        {
                            return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                        }
                    }


                    bool t = SCOSR.IsScriptCore2020() && NiecHelperSituation.isdgmods && NiecHelperSituation.__acorewIsnstalled__ && (inCurrentInteraction is Sim.GoToVirtualHome || inCurrentInteraction is Sim.GoToVirtualHome.GoToVirtualHomeInternal);

                    if (t || !inCurrentInteraction.Test() || (!inCurrentInteraction.IsTargetValid()))
                    {
                        niec_std.list_remove(simIQList, inCurrentInteraction);

                        if (inCurrentInteraction.Target != null)
                        {
                            if (!t)
                            {
                                try
                                {
                                    inCurrentInteraction.CallCallbackOnFailure(sim);
                                }
                                catch (NMAntiSpyException)
                                { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                                catch (StackOverflowException)
                                { sim.mPosture = null; throw; }
                                catch (ResetException)
                                { throw; }
                                catch (Exception)
                                {
                                    NFinalizeDeath.CheckYieldingContext();
                                }

                                try
                                {
                                    inCurrentInteraction.Cleanup();
                                }
                                catch (NMAntiSpyException)
                                { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                                catch (StackOverflowException)
                                { sim.mPosture = null; throw; }
                                catch (ResetException)
                                { throw; }
                                catch (Exception)
                                {
                                    NFinalizeDeath.CheckYieldingContext();
                                }
                            }
                            else
                            {
                                inCurrentInteraction.mbOnStartCalled = true;
                                inCurrentInteraction.mbOnStopCalled  = true;
                            }
                        }

                        if (sim.IsSelectable)
                        {
                            simIQ.FireQueueChanged();
                        }

                        continue;
                    }

                    if (inCurrentInteraction.InteractionObjectPair == null)
                    {
                        continue;
                    }

                    simIQ.mIsHeadInteractionLocked = true;

                    var runningInList = simIQ.mRunningInteractions;
                    if (runningInList != null)
                    {
                        runningInList.Push(inCurrentInteraction);
                    }

                    try
                    {
                        inCurrentInteraction.CallCallbackOnStart(sim);
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    { sim.mPosture = null; throw; }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }

                    simIQ.mIsHeadInteractionActive = true;

                    try
                    {
                        if (inCurrentInteraction != null && inCurrentInteraction.Autonomous && sim.mAutonomy != null && sim.mAutonomy.IsRunningLocalAutonomy && !sim.IsActiveSim && (sim.IsSelectable || RandomUtil.GetFloat(100f) < Sim.AutonomyThoughtBalloonPercentageChance) && inCurrentInteraction.InteractionObjectPair.Tradeoff != null)
                        {
                            CommodityKind physicalOrTraitMotive = sim.Motives.GetPhysicalOrTraitMotive(inCurrentInteraction.InteractionObjectPair.Tradeoff);
                            sim.ShowBalloonForMotive(ThoughtBalloonTypes.kThoughtBalloon, ThoughtBalloonPriority.Low, ThoughtBalloonDuration.Short, ThoughtBalloonCooldown.None, ThoughtBalloonAxis.kNeutral, physicalOrTraitMotive, inCurrentInteraction.Target);
                        }
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    { sim.mPosture = null; throw; }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }

                    sim.ClearExitReasons();

                    try
                    {
                        okI = NFinalizeDeath._RunInteractionWithoutCleanUp(inCurrentInteraction);
                        if (okI)
                        {
                            inCurrentInteraction.CallCallbackOnCompletion(sim);
                        }
                        else
                        {
                            inCurrentInteraction.CallCallbackOnFailure(sim);
                        }
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    {
                        NFinalizeDeath.ThrowResetException(null);
                        throw;
                    }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }


                    sim.ClearSynchronizationData();
                    NFinalizeDeath.CheckYieldingContext();

                    if (sim.HasExitReason(ExitReason.CancelledByPosture) && !sim.Posture.HasBeenCanceled)
                    {
                        sim.Posture.CancelPosture(sim);
                    }

                    if (!inCurrentInteraction.WasInUse && sim.OnlyHasExitReason(ExitReason.ObjectInUse))
                    {
                        inCurrentInteraction.WasInUse = true;
                    }

                    if (!okI && inCurrentInteraction.Target != null && ShouldTimeUpdate(inCurrentInteraction))
                    {
                        inCurrentInteraction.Target.UpdateBlockTime();
                    }

                    if (okI && inCurrentInteraction.Target != null && sim.IsSelectable)
                    {
                        EventTracker.SendEvent(new InteractionSuccessEvent(EventTypeId.kInteractionSuccess, sim, inCurrentInteraction.Target, inCurrentInteraction.InteractionObjectPair));
                    }

                    RemoveQueue(okI, simIQ, simIQList, sim, inCurrentInteraction);

                    if (inCurrentInteraction.ShouldReenque)
                    {
                        simIQ.ConsiderReenqueing(inCurrentInteraction);
                    }

                    if (Simulator.CheckYieldingContext(false))
                    {
                        simIQ.PutDownCarriedObjects(inCurrentInteraction);
                    }

                    NFinalizeDeath.CheckYieldingContext();

                    niec_std.list_remove(simIQList, inCurrentInteraction);
                    inCurrentInteraction.Cleanup();

                    NFinalizeDeath.CheckYieldingContext();

                    while (simIQList != null && niec_std.list_remove(simIQList, null))
                    {
                        NFinalizeDeath.CheckYieldingContext();
                        Simulator.Sleep(0);
                        simIQList = simIQ.mInteractionList;
                    }

                    if (simIQList == null)
                    {
                        break;
                    }

                    if (sim.IsSelectable)
                    {
                        simIQ.FireQueueChanged();
                    }

                    if (okI)
                    {
                        break;
                    }
                }
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
            catch (StackOverflowException)
            { sim.mPosture = null; throw; }

            if (simIQ.mInteractionList != null && simIQ.mInteractionList.Count == 0)
            {
                sim.QueueIdleLogic();
            }

            return(okI);
        }