-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpawnCommand.cs
123 lines (108 loc) · 3.95 KB
/
SpawnCommand.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
116
117
118
119
120
121
122
123
using GraphicsLib.Examples;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace GraphicsLib {
public class SpawnCommand : ModCommand {
public override string Command => "spawnobj";
public override CommandType Type => CommandType.Chat;
public override string Usage => "[c/ff6a00:Usage: /spawnobj <example type>]";
public override string Description => "Spawns an example from GraphicsLib";
public override void Action(CommandCaller caller, string input, string[] args) {
if(args.Length < 1) {
caller.Reply("Expected a positive integer argument.", Color.Red);
return;
}
if(args.Length > 1) {
caller.Reply("Too many arguments specified.", Color.Red);
return;
}
if(!uint.TryParse(args[0], out uint type)) {
caller.Reply("Invalid argument", Color.Red);
return;
}
int spawned;
switch(type) {
case 0:
//Example Line: Velocity
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleLine>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleLine.AI_ShowVelocity);
caller.Reply("Spawned: Example Line - Velocity");
break;
case 1:
//Example Line: Previous Postions
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleLine>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleLine.AI_ShowLocations);
caller.Reply("Spawned: Example Line - Old Postions");
break;
case 2:
//Example Line: Previous Postions, Lerped Color
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleLine>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleLine.AI_ShowLocation_LerpColor);
caller.Reply("Spawned: Example Line - Old Postions, Lerped Color");
break;
case 3:
//Example Scale Mesh: Scale Vertically
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleScaleMesh>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleScaleMesh.AI_ScaleVertically);
caller.Reply("Spawned: Example Mesh - Scale Vertically");
break;
case 4:
//Example Scale Mesh: Scale Horizontally
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleScaleMesh>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleScaleMesh.AI_ScaleHorizontally);
caller.Reply("Spawned: Example Mesh - Scale Horizontally");
break;
case 5:
//Example Scale Mesh: Rotate, then Scale
spawned = Projectile.NewProjectile(new EntitySource_DebugCommand("GraphiscLib command"),
caller.Player.Center - new Vector2(0, 80),
Main.rand.NextVector2Unit() * 7f,
ModContent.ProjectileType<ExampleScaleMesh>(),
0,
0,
caller.Player.whoAmI,
ai0: ExampleScaleMesh.AI_RotateThenScale);
caller.Reply("Spawned: Example Mesh - Scale with Initial Rotation");
break;
default:
caller.Reply("Unknown example type requested", Color.Red);
return;
}
if(Main.netMode == NetmodeID.MultiplayerClient)
NetMessage.SendData(MessageID.SyncProjectile, number: spawned);
}
}
}