-
Notifications
You must be signed in to change notification settings - Fork 10
/
TextItem.cs
115 lines (102 loc) · 4 KB
/
TextItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using CalamityMod.Items;
using CalamityMod.Projectiles.Melee;
using CalamityOverhaul.Content.Items.Melee.Extras;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace CalamityOverhaul
{
internal class TextItem : ModItem
{
public override string Texture => "CalamityOverhaul/icon";
//private bool old;
public override bool IsLoadingEnabled(Mod mod) {
return true;
}
public override void SetDefaults() {
Item.width = 80;
Item.height = 80;
Item.damage = 9999;
Item.DamageType = DamageClass.Default;
Item.useAnimation = Item.useTime = 13;
Item.useTurn = true;
Item.useStyle = ItemUseStyleID.Swing;
Item.knockBack = 2.25f;
Item.UseSound = SoundID.Item1;
Item.autoReuse = true;
Item.shootSpeed = 8f;
Item.shoot = ProjectileID.PurificationPowder;
Item.value = CalamityGlobalItem.RarityYellowBuyPrice;
Item.rare = ItemRarityID.Yellow;
}
public override void UpdateInventory(Player player) {
//player.velocity.Domp();
//bool news = player.PressKey(false);
//if (news && !old) {
// player.QuickSpawnItem(player.parent(), Main.HoverItem, Main.HoverItem.stack);
//}
//old = news;
}
public override void HoldItem(Player player) {
}
private void WriteTile(BinaryWriter writer, Tile tile, Point offsetPoint) {
writer.Write(offsetPoint.X);
writer.Write(offsetPoint.Y);
writer.Write(tile.WallType);
writer.Write(tile.TileType);
writer.Write(tile.TileFrameX);
writer.Write(tile.TileFrameY);
writer.Write(tile.HasTile);
writer.Write((byte)tile.Slope);
}
private void SetTile(BinaryReader reader) {
int tilePosX = reader.ReadInt32() + 3720;
int tilePosY = reader.ReadInt32() + 400;
ushort wallType = reader.ReadUInt16();
ushort tileType = reader.ReadUInt16();
short frameX = reader.ReadInt16();
short frameY = reader.ReadInt16();
bool hasTile = reader.ReadBoolean();
byte slope = reader.ReadByte();
Tile tile = Main.tile[tilePosX, tilePosY];
if (wallType > 1) {
tile.WallType = wallType;
tile.LiquidAmount = 255;
}
tile.HasTile = hasTile;
tile.Slope = (SlopeType)slope;
if (tileType > 0) {
tile.TileType = tileType;
}
tile.TileFrameX = frameX;
tile.TileFrameY = frameY;
CWRUtils.SafeSquareTileFrame(tilePosX, tilePosY);
}
public override bool? UseItem(Player player) {
Point startPoint = new Point(1720, 400);
Point endPoint = new Point(1720, 400);
int heiget = 2000;
int wid = 1400;
//using (BinaryWriter writer = new BinaryWriter(File.Open("D:\\TileWorldData\\structure.dat", FileMode.Create))) {
// for (int x = 0; x < wid; x++) {
// for (int y = 0; y < heiget; y++) {
// Point offsetPoint = new Point(x, y);
// WriteTile(writer, Main.tile[startPoint.X + x, startPoint.Y + y], offsetPoint);
// }
// }
//}
//Point point = new Point((int)Main.MouseWorld.X / 16, (int)Main.MouseWorld.Y / 16);
//point.Domp();
//using (BinaryReader reader = new BinaryReader(File.Open("D:\\TileWorldData\\structure.dat", FileMode.Open))) {
// for (int x = 0; x < wid; x++) {
// for (int y = 0; y < heiget; y++) {
// SetTile(reader);
// }
// }
//}
return true;
}
}
}