Esempio n. 1
0
        public static bool InventoryContainsDragonball(int whichDragonball, Item[] inventory)
        {
            for (var i = 0; i < inventory.Length; i++)
            {
                var item = inventory[i];
                if (item == null)
                {
                    continue;
                }

                if (item.modItem == null)
                {
                    continue;
                }

                if (!(item.modItem is DragonBallItem))
                {
                    continue;
                }

                var dbItem = item.modItem as DragonBallItem;
                // assume this runs before the inventory loop that turns stone balls into real ones - we don't care which it is, if it's legit, we don't want to spawn dragonballs replacing it.
                if (dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetStoneBallFromNumber(whichDragonball)) && dbItem.WorldDragonBallKey == GetWorld().WorldDragonBallKey)
                {
                    return(true);
                }
                if (dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetDragonBallItemTypeFromNumber(whichDragonball)) && dbItem.WorldDragonBallKey == GetWorld().WorldDragonBallKey)
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public override void MouseOver(int i, int j)
        {
            Player player = Main.LocalPlayer;

            player.noThrow       = 2;
            player.showItemIcon  = true;
            player.showItemIcon2 = mod.ItemType(DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBallAmI));
        }
Esempio n. 3
0
 /// <summary>
 ///     Whether a single dragon ball of a specific type is present in an inventory.
 /// </summary>
 /// <param name="inventory">The inventory being checked.</param>
 /// <param name="whichDragonBall">Which (int) dragon ball we're looking for.</param>
 /// <returns></returns>
 public static bool IsDragonBallPresent(this Item[] inventory, int whichDragonBall)
 {
     return
         ((
              from item in inventory
              where item != null && item.modItem != null
              where item.modItem is DragonBallItem
              select(DragonBallItem) item.modItem
              ).Any(
              dbItem => dbItem.item.type == ItemHelper.GetItemTypeFromName(DragonBallItem.GetDragonBallItemTypeFromNumber(whichDragonBall))
              ));
 }
Esempio n. 4
0
        public static void SwapDragonBallWithStoneBall(Item[] inventory, int WorldDragonBallKey, int WhichDragonBall)
        {
            // this dragon ball was pulled in from another world. Turn it into a rock.
            int dbKey  = WorldDragonBallKey;
            int dbSlot = ItemHelper.RemoveDragonBall(inventory, WorldDragonBallKey, WhichDragonBall);

            // something went wrong, abort.
            if (dbSlot == -1)
            {
                return;
            }
            var newStoneBall = DBZMOD.instance.GetItem(DragonBallItem.GetStoneBallFromNumber(WhichDragonBall)).item.DeepClone();
            var dbData       = newStoneBall.modItem as DragonBallItem;

            dbData.WorldDragonBallKey = dbKey;
            inventory[dbSlot]         = newStoneBall;
        }
Esempio n. 5
0
        public static void SwapStoneBallWithDragonBall(Item[] inventory, int WorldDragonBallKey, int WhichDragonBall)
        {
            // this stone ball was pulled back into its world. Turn it into a dragon ball.
            int dbKey  = WorldDragonBallKey;
            int dbSlot = ItemHelper.RemoveStoneBall(inventory, WorldDragonBallKey, WhichDragonBall);

            // something went wrong, abort.
            if (dbSlot == -1)
            {
                return;
            }
            var dbType        = DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBall);
            var newDragonBall = DBZMOD.instance.GetItem(DragonBallItem.GetDragonBallItemTypeFromNumber(WhichDragonBall)).item.DeepClone();
            var dbData        = newDragonBall.modItem as DragonBallItem;

            dbData.WorldDragonBallKey = dbKey;
            inventory[dbSlot]         = newDragonBall;
        }
Esempio n. 6
0
        /// <summary>
        ///     Return the slot of the inventory a dragon ball was in after deleting it.
        ///     This is used to replace a dragon ball with an inert dragon ball brought from other worlds.
        /// </summary>
        /// <returns></returns>
        public static int RemoveStoneBall(Item[] inventory, int dbKey, int whichDragonBall)
        {
            string ballType    = DragonBallItem.GetStoneBallFromNumber(whichDragonBall);
            int    ballTypeInt = GetItemTypeFromName(ballType);

            for (var i = 0; i < inventory.Length; i++)
            {
                var item = inventory[i];
                if (item == null)
                {
                    continue;
                }

                if (item.modItem == null)
                {
                    continue;
                }

                if (item.type != ballTypeInt)
                {
                    continue;
                }

                if (item.modItem is DragonBallItem)
                {
                    var dBall = item.modItem as DragonBallItem;
                    if (dBall.WorldDragonBallKey == dbKey)
                    {
                        inventory[i].TurnToAir();
                        return(i);
                    }
                }
            }

            // dragonball wasn't found, return an oob index.
            return(-1);
        }
Esempio n. 7
0
        public static void ScanInventoryForIllegitimateDragonballs(Item[] inventory)
        {
            for (var i = 0; i < inventory.Length; i++)
            {
                var item = inventory[i];
                if (item == null)
                {
                    continue;
                }

                if (item.modItem == null)
                {
                    continue;
                }

                if (!(item.modItem is DragonBallItem))
                {
                    continue;
                }

                var dbItem  = item.modItem as DragonBallItem;
                var dbWorld = DBZMOD.instance.GetModWorld("DBZWorld") as DBZWorld;
                if (dbItem.WorldDragonBallKey != dbWorld.WorldDragonBallKey)
                {
                    SwapDragonBallWithStoneBall(inventory, dbItem.WorldDragonBallKey.Value, dbItem.GetWhichDragonBall());
                }
                else
                {
                    if (DragonBallItem.IsItemStoneBall(dbItem.item.type))
                    {
                        // this stone ball is being re-legitimized, which is not a word
                        SwapStoneBallWithDragonBall(inventory, dbItem.WorldDragonBallKey.Value, dbItem.GetWhichDragonBall());
                    }
                }
            }
        }