示例#1
0
        public TrainTunnelRecipe(TrainTunnelItem myitem) : base(myitem.mod)
        {
            this.AddTile(TileID.TinkerersWorkbench);

            this.AddRecipeGroup("HamstarHelpers:WarpPotions", 3);
            this.AddIngredient(ItemID.Explosives, 1);
            this.AddIngredient(ItemID.WoodenBeam, 25);

            this.SetResult(myitem);
        }
示例#2
0
        ////////////////

        public override void PostDrawInInventory(SpriteBatch sb, Vector2 pos, Rectangle frame, Color draw_color, Color item_color, Vector2 origin, float scale)
        {
            float   new_scale  = 2.75f;
            Vector2 str_origin = Main.fontMouseText.MeasureString(">");
            Vector2 new_pos    = new Vector2(
                (pos.X + (scale * (float)frame.Width / 2f)),                    // - ( (new_scale * str_origin.X) / 2 ),
                (pos.Y + (scale * (float)frame.Height / 2f))                    // - ( (new_scale * str_origin.Y) / 2 )
                );

            float rads = -TrainTunnelItem.GetRadiansOfDirection(this.Direction);

            sb.DrawString(Main.fontMouseText, ">", new_pos, Color.Red, rads, str_origin / new_scale, new_scale * scale, SpriteEffects.None, 1f);
        }
示例#3
0
        ////////////////

        public override bool CanUseItem(Player player)
        {
            if (Timers.GetTimerTickDuration("TrainTunnelPlaceError") > 0)
            {
                Timers.SetTimer("TrainTunnelPlaceError", 15, () => false);
                return(false);
            }
            Timers.SetTimer("TrainTunnelPlaceError", 15, () => false);

            int min_range  = OnARailMod.Instance.Config.TrainTunnelMinTileRange;
            int range_span = OnARailMod.Instance.Config.TrainTunnelMaxTileRange - min_range;

            float   rad       = MathHelper.Pi / 180f;
            float   base_rads = TrainTunnelItem.GetRadiansOfDirection(this.Direction) - (rad * 5f);
            Vector2?_dest     = null;

            for (int i = 0; i < 100; i++)
            {
                float rads = base_rads + (rad * (Main.rand.NextFloat() * 10f));
                float dist = min_range + (range_span * Main.rand.NextFloat());

                _dest = TrainTunnelItem.ScanForExitCandidate(player.position, rads, dist);
                if (_dest != null)
                {
                    break;
                }
            }

            if (_dest != null)
            {
                var dest = (Vector2)_dest;
                TrainTunnelTileEntity.AwaitingExitTunnelPosition = new Point16((int)(dest.X / 16f), (int)(dest.Y / 16f));
            }
            else
            {
                Main.NewText("Could not find suitable tunnel exit. Try again, or change tunnel direction.", Color.Red);
            }

            return(_dest != null);              // Tile hasn't been placed yet; Terraria could still decide it will fail
        }