private void RunWarpInterruptDecisions(Item anyOrNoItem)
        {
            var config = WICLibConfig.Instance;

            if (!config.Get <bool>(nameof(config.WarpWarmupInterruptedByMovement)))
            {
                return;
            }
            if (anyOrNoItem == null || anyOrNoItem.IsAir || this.player.itemTime == 0)                  // Item not in use
            {
                return;
            }

            var warpItems = config.Get <List <ItemDefinition> >(nameof(config.WarpItems));

            //switch( item.type ) {
            //case ItemID.MagicMirror:
            //case ItemID.CellPhone:
            //case ItemID.IceMirror:
            //case ItemID.RecallPotion:
            if (warpItems.Contains(new ItemDefinition(anyOrNoItem.type)))
            {
                if (this.player.velocity.X != 0 || this.player.velocity.Y != 0)
                {
                    if (this.player.whoAmI == Main.myPlayer)
                    {
                        WICLibMod.ShowAlert("Warping interrupted by movement.");
                    }

                    this.EndWarp();
                }
            }
        }
Ejemplo n.º 2
0
        public override bool CanUseItem(Item item, Player player)
        {
            var config    = WICLibConfig.Instance;
            var warpItems = config.Get <List <ItemDefinition> >(nameof(config.WarpItems));

            //switch( item.type ) {
            //case ItemID.MagicMirror:
            //case ItemID.CellPhone:
            //case ItemID.IceMirror:
            //case ItemID.RecallPotion:
            if (warpItems.Contains(new ItemDefinition(item.type)))
            {
                if (config.Get <bool>(nameof(config.WarpItemsBlocked)))
                {
                    if (player.whoAmI == Main.myPlayer)
                    {
                        WICLibMod.ShowAlert("Warp items disabled by config.");
                    }
                    return(false);
                }
                if (config.Get <bool>(nameof(config.ChaosStateBlocksWarpItems)))
                {
                    if (player.HasBuff(BuffID.ChaosState))
                    {
                        if (player.whoAmI == Main.myPlayer)
                        {
                            WICLibMod.ShowAlert("Warp items disabled by Chaos State.");
                        }
                        return(false);
                    }
                }

                var myplayer = player.GetModPlayer <WICPlayer>();
                if (!myplayer.IsWarpEnabled)
                {
                    if (player.whoAmI == Main.myPlayer)
                    {
                        WICLibMod.ShowAlert(myplayer.WarpDeniedMessage);
                    }
                    return(false);
                }
            }

            return(base.CanUseItem(item, player));
        }