Example #1
0
        public override bool Run()
        {
            try
            {
                MailboxDoor doorOfSim = Target.GetDoorOfSim(Actor);
                if ((doorOfSim == null) || !Actor.RouteToSlotAndCheckInUse(Target, doorOfSim.Slot))
                {
                    return(false);
                }

                bool flag = false;
                StandardEntry();
                EnterStateMachine("mailbox", "Enter", "x", "mailbox");
                SetActor("wallMailboxes", Target);
                SetParameter("IsWallMailbox", Target.IsWallMailboxVariant);
                doorOfSim.SetAnimParams(mCurrentStateMachine);
                string instanceName = (Target.Inventory.AmountIn <Bill>() > 0x0) ? "Bill" : "Package";
                mObjectInHand = GlobalFunctions.CreateObjectOutOfWorld(instanceName, "Sims3.Gameplay.Core.Null", null) as GameObject;
                SetActor("bills", mObjectInHand);
                bool flagUp = Target.FlagUp;
                SetParameter("IsFlagAlreadyUp", flagUp);
                doorOfSim.SetProductVersionForDoorAnim(mCurrentStateMachine);
                if (((Target.BoobyTrapComponent != null) ? Target.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription) : false) && Target.TriggerTrap(Actor))
                {
                    EnterState("x", "Get Mail");
                }
                else
                {
                    AnimateSim("Get Mail");
                    flag = MailboxEx.GrabMail(Target, Actor);
                    doorOfSim.UnsetProductVersionForDoorAnim(mCurrentStateMachine);
                    AnimateSim("Put Flag Down");
                }

                RemoveActor("bills");
                mObjectInHand.Destroy();
                mObjectInHand = null;
                AnimateSim("Exit");
                StandardExit();
                return(flag);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #2
0
        public override bool Run()
        {
            try
            {
                int    simoleons = 0;
                string s         = CommonMethodsTaxCollector.ShowDialogueNumbersOnly(CommonMethodsTaxCollector.LocalizeString("MakeDonation", new object[] { base.Target.info.Name }),
                                                                                     string.Empty, string.Empty);

                if (int.TryParse(s, out simoleons))
                {
                    MailboxDoor mailboxDoor = this.Target.GetDoorOfSim(this.Actor);// ?? this.Target.GetAnyDoor();

                    //Route to mailbox
                    if (mailboxDoor == null || !this.Actor.RouteToObjectRadius(base.Target, 1))
                    {
                        return(false);
                    }

                    if (simoleons > this.Actor.FamilyFunds)
                    {
                        this.Actor.AddExitReason(ExitReason.CanceledByScript);
                        return(false);
                    }

                    bool flag = true;
                    base.StandardEntry();
                    base.EnterStateMachine("mailbox", "Enter", "x", "mailbox");
                    base.SetActor("wallMailboxes", this.Target);
                    base.SetParameter("IsWallMailbox", true);
                    mailboxDoor.SetAnimParams(this.mCurrentStateMachine);

                    bool flagUp = false;
                    base.SetParameter("IsFlagAlreadyUp", flagUp);
                    base.BeginCommodityUpdates();

                    mailboxDoor.SetProductVersionForDoorAnim(this.mCurrentStateMachine);
                    base.AnimateSim("Put Mail s1");
                    mailboxDoor.UnsetProductVersionForDoorAnim(this.mCurrentStateMachine);
                    base.AnimateSim("Put Mail");

                    //Substract money and add to funds
                    this.Actor.ModifyFunds(-simoleons);
                    base.Target.info.Funds += simoleons;

                    if (base.Target.info.DonationMoodValue > 0)
                    {
                        EventTracker.SendEvent(new IncrementalEvent(EventTypeId.kDonatedToCharity, this.Actor, null, (float)simoleons));
                        this.Actor.BuffManager.AddElement(BuffNames.Charitable, base.Target.info.DonationMoodValue, Origin.FromCharity);
                        this.Actor.DonatedToCharityTime = (int)SimClock.ElapsedTime(TimeUnit.Days);
                    }


                    Audio.StartSound("ui_object_buy");

                    base.EndCommodityUpdates(flag);
                    base.AnimateSim("Exit");
                    base.StandardExit();
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                CommonMethodsTaxCollector.PrintMessage(ex.Message);
            }

            return(true);
        }