-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
UseStyleShowcase.cs
59 lines (51 loc) · 1.7 KB
/
UseStyleShowcase.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
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ExampleMod.Content.Items
{
/// <summary>
/// This item lets you test the existing ItemUseStyleID values for Item.useStyle. Note that the sword texture might not fit each of the useStyle animations.
/// </summary>
public class UseStyleShowcase : ModItem
{
public override string Texture => "ExampleMod/Content/Items/Weapons/ExampleSword";
public override void SetDefaults() {
Item.width = 40;
Item.height = 40;
// In Visual Studio, you can click on "ItemUseStyleID" and then press F12 to see the list of possible values. You can also type "ItemUseStyleID." to view the list of possible values.
Item.useStyle = ItemUseStyleID.Swing;
Item.useTime = 30;
Item.useAnimation = 30;
Item.autoReuse = true;
Item.UseSound = SoundID.Item1;
}
public override void NetSend(BinaryWriter writer) {
writer.Write((byte)Item.useStyle);
}
public override void NetReceive(BinaryReader reader) {
Item.useStyle = reader.ReadByte();
}
public override bool AltFunctionUse(Player player) {
return true;
}
public override bool? UseItem(Player player) {
if (player.whoAmI != Main.myPlayer) {
return true;
}
if (player.altFunctionUse == 2) {
Item.useStyle++;
if (Item.useStyle > ItemUseStyleID.RaiseLamp) {
Item.useStyle = ItemUseStyleID.Swing;
}
Main.NewText($"Switching to ItemUseStyleID #{Item.useStyle}");
// This line will trigger NetSend to be called at the end of this game update, allowing the changes to useStyle to be in sync.
Item.NetStateChanged();
}
else {
Main.NewText($"This is ItemUseStyleID #{Item.useStyle}");
}
return true;
}
}
}