Exemplo n.º 1
0
        internal static void UpdateTradingState()
        {
            var mymod = IntrinsicsMod.Instance;
            var plr   = Main.player[Main.myPlayer];

            mymod.IsTrading = Main.playerInventory &&
                              mymod.IsTrading &&
                              !plr.dead &&
                              WanderingGhostNPC.CanTrade();

            if (!mymod.IsTrading)
            {
                Item item = mymod.TradeItem;

                if (!item.IsAir)
                {
                    int itemIdx = Item.NewItem((int)plr.position.X, (int)plr.position.Y, item.width, item.height, item.type, item.stack, false, (int)item.prefix, true, false);

                    Main.item[itemIdx]             = item.Clone();
                    Main.item[itemIdx].newAndShiny = false;
                    Main.item[itemIdx].position    = plr.Center;
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(MessageID.SyncItem, -1, -1, null, itemIdx, 1f, 0f, 0f, 0, 0, 0);
                    }

                    mymod.TradeItem = new Item();
                }
            }
        }
Exemplo n.º 2
0
        public static bool AttemptTrade(ref Item tradeItem)
        {
            var mymod   = IntrinsicsMod.Instance;
            var itemDef = new ItemDefinition(tradeItem.type);

            if (mymod.Config.TradeItemContractTatters.ContainsKey(itemDef))
            {
                int tatterNum = mymod.Config.TradeItemContractTatters[itemDef];
                NPC npc       = WanderingGhostNPC.GetNearestGhost(Main.LocalPlayer);

                ItemHelpers.CreateItem(npc.position, ModContent.ItemType <ContractTatterItem>(), tatterNum, 16, 16);
                ItemHelpers.ReduceStack(tradeItem, 1);

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        ////

        public static bool CanTrade()
        {
            return(WanderingGhostNPC.GetNearestGhost(Main.LocalPlayer) != null);
        }