////////////////

        /*public override bool CanRightClick() {
         *      return true;
         * }
         *
         * public override bool ConsumeItem( Player player ) {
         *      SoundEmitterItem.OpenUI( this.item );
         *
         *      return false;
         * }*/


        ////////////////

        public override bool UseItem(Player player)
        {
            if (Main.netMode == NetmodeID.Server || player.whoAmI != Main.myPlayer)
            {
                return(base.UseItem(player));
            }

            string timerName = "SoundEmitterPlace_" + player.whoAmI;

            if (Timers.GetTimerTickDuration(timerName) > 0)
            {
                return(base.UseItem(player));
            }
            Timers.SetTimer(timerName, 15, false, () => false);

            if (this.Def == null)
            {
                Main.NewText("Sound Emitter settings must be first specified (click item's button).");
                return(base.UseItem(player));
            }

            if (SoundEmitterItem.AttemptSoundEmitterPlacementForCurrentPlayer(this.Def))
            {
                PlayerItemHelpers.RemoveInventoryItemQuantity(player, this.item.type, 1);
            }
            else
            {
                //SoundEmitterItem.AttemptSoundEmitterToggle( Main.MouseWorld );
            }

            return(base.UseItem(player));
        }
Example #2
0
        protected override void ReceiveOnServer(int fromWho)
        {
            var myworld = ModContent.GetInstance <EmittersWorld>();

            myworld.AddEmitter(this.GetNewEmitter(), this.TileX, this.TileY);

            PlayerItemHelpers.RemoveInventoryItemQuantity(Main.player[this.FromWho], ModContent.ItemType <EmitterItem>(), 1);
        }
Example #3
0
        ////////////////

        protected override void ReceiveOnClient()
        {
            var myworld = ModContent.GetInstance <EmittersWorld>();

            Main.PlaySound(SoundID.Item108, new Vector2(this.TileX << 4, this.TileY << 4));

            myworld.AddEmitter(this.GetNewEmitter(), this.TileX, this.TileY);

            PlayerItemHelpers.RemoveInventoryItemQuantity(Main.player[this.FromWho], ModContent.ItemType <EmitterItem>(), 1);
        }
        private static bool ScribeBlankContractIf(Player player, Item item)
        {
            int  blankContractType = ModContent.ItemType <BlankContractItem>();
            Item contractItem      = PlayerItemFinderHelpers.FindFirstOfPossessedItemFor(
                player,
                new HashSet <int> {
                blankContractType
            },
                false
                );

            var myContractItem = contractItem.modItem as BlankContractItem;

            if (contractItem == null || myContractItem == null)
            {
                Main.NewText("No blank contract item in player's possession.", Color.Yellow);
                return(false);
            }

            if (item?.active != true)
            {
                if (IntrinsicsConfig.Instance.DebugModeInfo)
                {
                    Main.NewText("BlankContractItem reports it cannot swap selected item");
                }
                return(false);
            }

            if (!myContractItem.CanAddItem(item))
            {
                Main.NewText("This item cannot be scribed.", Color.Yellow);
                return(false);
            }

            bool hasMadeContract = myContractItem.CreateImpartmentContract(player, item);

            if (IntrinsicsConfig.Instance.DebugModeInfo)
            {
                Main.NewText("Impartment contract created? " + hasMadeContract);
            }

            if (!hasMadeContract)
            {
                return(false);
            }

            PlayerItemHelpers.RemoveInventoryItemQuantity(player, item.type, 1);
            PlayerItemHelpers.RemoveInventoryItemQuantity(player, blankContractType, 1);
            Main.mouseItem = new Item();

            return(hasMadeContract);
        }
Example #5
0
        public static bool AttemptToTemporaryLicenseItem(Player player, Item item)
        {
            int trialLicenseType = ModContent.ItemType <TrialLicenseItem>();
            int totalLicenses    = ItemFinderHelpers.CountTotalOfEach(player.inventory, new HashSet <int> {
                trialLicenseType
            });
            int needed = LicenseItem.ComputeCost(item);

            if (totalLicenses < needed)
            {
                return(false);
            }

            var realItemDef = new ItemDefinition(item.type);

            var myplayer = player.GetModPlayer <LicensesPlayer>();

            myplayer.TrialLicenseItemByDefinition(realItemDef, true);

            PlayerItemHelpers.RemoveInventoryItemQuantity(player, trialLicenseType, needed);

            return(true);
        }