public void CleanupActions(Sim s, float x)
        {
            try
            {
                CourtesansPerfume perfume = Courtesan.GetPerfume(base.Target);
                if (perfume != null)
                {
                    perfume.restoreOldRelationship(base.Actor);
                    base.Target.BuffManager.RemoveElement(BuffNames.StrideOfPride);
                    base.Target.BuffManager.RemoveElement(BuffNames.WalkOfShame);
                }
            }
            catch (Exception e)
            {
                Message.Sender.ShowError(base.Target, "Restoring original relationships failed", false, e);
            }

            try
            {
                Lot.MetaAutonomyType venueType = base.Actor.LotCurrent.GetMetaAutonomyType;
                Courtesan.SwitchToProperClothing(base.Actor, venueType);
                Courtesan.SwitchToProperClothing(base.Target, venueType);
            }
            catch (Exception e)
            {
                Message.Sender.ShowError(base.Actor, "Cannot restore clothes", false, e);
            }
        }
            public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                bool result = false;

                if (!isAutonomous)
                {
                    CourtesansPerfume perfume = Courtesan.GetPerfume(target);
                    if (perfume != null)
                    {
                        if (perfume.Pimp == null)
                        {
                            InteractionDefinition interaction = BuyWooHoo.Singleton;
                            result = Courtesan.IsTalkingTo(actor, target, result);

                            if (actor.InteractionQueue.HasInteractionOfTypeAndTarget(ToggleTakeMistress.Singleton, target))
                            {
                                result = true;
                            }
                        }
                        else
                        {
                            result = true;
                        }
                    }
                }

                return(result);
            }
            public override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction)
            {
                string            price   = "0";
                Sim               owner   = null;
                CourtesansPerfume perfume = Courtesan.GetPerfume(target);

                if (perfume != null)
                {
                    price = perfume.PimpShare.ToString();

                    owner = perfume.Pimp;
                }

                string name = "Ask for personal fulltime service(§" + price + ")";

                if (owner == actor)
                {
                    name = "Fire from your service";
                }
                else if (owner != null)
                {
                    name = "Ask to stop working for " + owner.FullName;
                }
                return(name);
            }
        public override bool Run()
        {
            Courtesan role = Courtesan.AssignedRole(base.Target);

            if (role != null)
            {
                CourtesansPerfume perfume = role.GetPerfume();
                Sim owner = perfume.Pimp;
                if (owner == null)
                {
                    perfume.Pimp = this.Actor;
                    Message.Sender.Show(base.Target, "I have obligations today, but I'll come to you tomorrow");
                }
                else if (Actor == owner)
                {
                    perfume.Pimp = null;
                }
                else
                {
                    Message.Sender.Show(base.Target, "Only my employer can fire me!");
                }
            }

            return(true);
        }
        private void CreateAndStoreRelationship(Sim buyer, Sim seller)
        {
            Relationship      relationToTarget = buyer.GetRelationship(seller, true);
            CourtesansPerfume perfume          = Courtesan.GetPerfume(seller);

            if (perfume != null)
            {
                perfume.storeAndIncreaseRelationship(buyer, relationToTarget);
                //perfume.storeOldRelationship(buyer, relationToTarget.LTR.CurrentLTR);
                // relationToTarget.LTR.ForceChangeState(LongTermRelationshipTypes.Partner);
            }
        }
        public override bool Run()
        {
            try
            {
                Sim buyer  = base.Actor;
                Sim seller = base.Target;
                CourtesansPerfume perfume = Courtesan.GetPerfume(seller);
                if (perfume != null)
                {
                    Bed place = FindNearestBed(perfume);
                    if (place != null)
                    {
                        if (perfume.mConfirmWoohoo)
                        {
                            bool woohooOk = AcceptCancelDialog.Show(buyer.FullName + " wants to woohoo with " + seller.FullName + ". Is this Ok?");
                            if (!woohooOk)
                            {
                                return(true);
                            }
                        }

                        CreateAndStoreRelationship(buyer, seller);
                        Pay(buyer, seller);
                        PushWooHooOnBed(seller, buyer, place, new Callback(this.CleanupActions));
                        //InteractionInstance sellerCleanupAction = AfterWooHooCleanup.Singleton.CreateInstanceWithCallbacks(seller, seller,
                        //    new InteractionPriority(InteractionPriorityLevel.UserDirected), false, false,
                        //    new Callback(this.RestoreRelationship), new Callback(this.DoNothing), new Callback(this.DoNothing)
                        //    );
                        //sellerCleanupAction.MustRun = true;
                        //seller.InteractionQueue.AddAfterCheckingForDuplicates(sellerCleanupAction);

                        //InteractionInstance buyerCleanupAction =
                        //   AfterWooHooCleanup.Singleton.CreateInstance(buyer, buyer,
                        //   new InteractionPriority(InteractionPriorityLevel.UserDirected), false, false);
                        //buyerCleanupAction.MustRun = true;
                        //buyer.InteractionQueue.AddAfterCheckingForDuplicates(buyerCleanupAction);
                    }
                    else
                    {
                        Message.Sender.Show("All the beds in this lot are already in use");
                    }
                }
            }
            catch (Exception e)
            {
                Message.Sender.ShowError(base.Target, "Buy WooHoo failed", false, e);
            }
            return(true);
        }
            public override string GetInteractionName(Sim actor, Sim target, InteractionObjectPair interaction)
            {
                string            price   = "";
                CourtesansPerfume perfume = Courtesan.GetPerfume(target);

                if (perfume != null)
                {
                    int total = perfume.PricePerWoohoo + perfume.PimpShare;
                    if (total > 0)
                    {
                        price = "(§" + total.ToString() + ")";
                    }
                }

                return("Ask to WooHoo " + price);
            }
        public void Pay(Sim buyer, Sim seller)
        {
            CourtesansPerfume perfume = Courtesan.GetPerfume(seller);

            if (perfume != null)
            {
                int basePay = perfume.PricePerWoohoo;
                int pimpFee = perfume.PimpShare;
                int total   = basePay + pimpFee;
                if (total < buyer.FamilyFunds)
                {
                    buyer.ModifyFunds(-total);
                    seller.ModifyFunds(basePay);
                    Sim pimp = perfume.Pimp;
                    if (pimp != null)
                    {
                        pimp.ModifyFunds(pimpFee);
                    }
                }
            }
        }
            public override bool Test(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                bool result = false;
                CourtesansPerfume perfume = Courtesan.GetPerfume(target);

                if (perfume != null)
                {
                    if (perfume.GenderMatches(actor, target))
                    {
                        result = IsTalkingToOrAlreadyBuying(actor, target, result);
                    }
                }
                else
                {
                    if (Message.Sender.IsDebugging())
                    {
                        Message.Sender.Debug(this, "action is not enabled since perfume does not exist");
                    }
                }

                return(result);
            }