Exemple #1
0
        public static void OnWoohooed(Event e)
        {
            using (Common.TestSpan span = new Common.TestSpan(ScoringLookup.Stats, "Duration CommonWoohoo:OnWoohooed"))
            {
                WooHooEvent wEvent = e as WooHooEvent;
                if (wEvent == null)
                {
                    return;
                }

                Sim actor = wEvent.Actor as Sim;
                if (actor == null)
                {
                    return;
                }

                SimDescription targetDesc = null;

                Sim target = wEvent.TargetObject as Sim;
                if (target != null)
                {
                    targetDesc = target.SimDescription;
                }
                else if (actor.SimDescription.IsPregnant)
                {
                    targetDesc = SimDescription.Find(actor.SimDescription.Pregnancy.DadDescriptionId);
                }

                if (targetDesc == null)
                {
                    return;
                }

                CommonWoohoo.WoohooLocation location = WoohooLocation.Bed;

                CommonWoohoo.WoohooStyle style = WoohooStyle.Safe;

                IWooHooDefinition woohoo = null;

                NRaasWooHooEvent customEvent = wEvent as NRaasWooHooEvent;
                if (customEvent != null)
                {
                    location = customEvent.Location;
                    style    = customEvent.Style;
                }
                else
                {
                    if (actor.CurrentInteraction != null)
                    {
                        woohoo = actor.CurrentInteraction.InteractionDefinition as IWooHooDefinition;
                        if (woohoo == null)
                        {
                            if (actor.CurrentInteraction is Shower.TakeShower)
                            {
                                foreach (Sim sim in actor.LotCurrent.GetAllActors())
                                {
                                    if ((sim.CurrentInteraction != null) && (sim.CurrentInteraction.Target == actor))
                                    {
                                        woohoo = sim.CurrentInteraction.InteractionDefinition as IWooHooDefinition;
                                        if (woohoo != null)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        if (woohoo != null)
                        {
                            location = woohoo.GetLocation(wEvent.ObjectUsed);

                            style = woohoo.GetStyle(actor.CurrentInteraction);
                            if ((style == WoohooStyle.Safe) && (Woohooer.Settings.ReplaceWithRisky))
                            {
                                style = WoohooStyle.Risky;
                            }
                        }
                    }

                    if (wEvent.BedUsed != null)
                    {
                        if (wEvent.BedUsed is Tent)
                        {
                            location = WoohooLocation.Tent;
                        }
                        else if (wEvent.BedUsed is Igloo)
                        {
                            location = WoohooLocation.Igloo;
                        }
                        else if (wEvent.BedUsed is FairyHouse)
                        {
                            location = WoohooLocation.FairyHouse;
                        }
                    }
                    else if ((woohoo == null) && (wEvent.ObjectUsed != null))
                    {
                        foreach (WoohooLocationControl check in Common.DerivativeSearch.Find <WoohooLocationControl>())
                        {
                            if (check.Matches(wEvent.ObjectUsed))
                            {
                                location = check.Location;
                                break;
                            }
                        }
                    }
                }

                KamaSimtra.AddNotch(actor.SimDescription, targetDesc, actor.LotCurrent, location, style);

                Woohooer.Settings.AddCount(actor);

                WoohooBuffs.Apply(actor, target, style == WoohooStyle.Risky);

                KamaSimtraSettings.ServiceData data = KamaSimtra.Settings.GetServiceData(targetDesc.SimDescriptionId, true);
                if (data != null)
                {
                    data.Dispose();
                }
            }
        }