1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Threading;
|
---|
4 | using UnityEngine;
|
---|
5 |
|
---|
6 | namespace CoppisAdditions.CustomCommands
|
---|
7 | {
|
---|
8 | public class SpawnScouts : ConsoleCmdAbstract
|
---|
9 | {
|
---|
10 | public override string GetDescription ()
|
---|
11 | {
|
---|
12 | return "spawn scouts near a player or coordinate";
|
---|
13 | }
|
---|
14 |
|
---|
15 | public override string GetHelp ()
|
---|
16 | {
|
---|
17 | return "Spawn scouts near a player." +
|
---|
18 | "Usage:\n" +
|
---|
19 | " ss <steam id/player name/entity id>\n" +
|
---|
20 | "or" +
|
---|
21 | " ss <x> <y> <z>\n";
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override string[] GetCommands ()
|
---|
25 | {
|
---|
26 | return new string[] { "ss" };
|
---|
27 | }
|
---|
28 |
|
---|
29 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo)
|
---|
30 | {
|
---|
31 | try {
|
---|
32 | if (_params.Count != 1 && _params.Count != 3) {
|
---|
33 | SdtdConsole.Instance.Output ("Wrong number of arguments, expected 1 or 3, found " + _params.Count + ".");
|
---|
34 | SdtdConsole.Instance.Output (" ");
|
---|
35 | SdtdConsole.Instance.Output (GetHelp ());
|
---|
36 | return;
|
---|
37 | }
|
---|
38 |
|
---|
39 | Vector3 pos = new Vector3 ();
|
---|
40 | int x = int.MinValue;
|
---|
41 | int y = int.MinValue;
|
---|
42 | int z = int.MinValue;
|
---|
43 |
|
---|
44 | if (_params.Count == 1) {
|
---|
45 | ClientInfo ci1 = ConsoleHelper.ParseParamIdOrName (_params [0]);
|
---|
46 | if (ci1 == null) {
|
---|
47 | SdtdConsole.Instance.Output ("Playername or entity/steamid id not found.");
|
---|
48 | return;
|
---|
49 | }
|
---|
50 | EntityPlayer ep1 = GameManager.Instance.World.Players.dict [ci1.entityId];
|
---|
51 | pos = ep1.GetPosition ();
|
---|
52 | } else if (_params.Count == 3) {
|
---|
53 | int.TryParse (_params [0], out x);
|
---|
54 | int.TryParse (_params [1], out y);
|
---|
55 | int.TryParse (_params [2], out z);
|
---|
56 |
|
---|
57 | if (x == int.MinValue || y == int.MinValue || z == int.MinValue) {
|
---|
58 | SdtdConsole.Instance.Output ("x:" + x);
|
---|
59 | SdtdConsole.Instance.Output ("y:" + y);
|
---|
60 | SdtdConsole.Instance.Output ("z:" + z);
|
---|
61 | SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer");
|
---|
62 | return;
|
---|
63 | }
|
---|
64 |
|
---|
65 | pos = new Vector3 ((float)x, (float)y, (float)z);
|
---|
66 | }
|
---|
67 |
|
---|
68 | AIDirectorChunkEventComponent chunkComponent = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorChunkEventComponent> ();
|
---|
69 | if (chunkComponent == null) {
|
---|
70 | SdtdConsole.Instance.Output ("No AIDirectorChunkEventComponent Component found");
|
---|
71 | return;
|
---|
72 | }
|
---|
73 |
|
---|
74 | chunkComponent.SpawnScouts (pos);
|
---|
75 | SdtdConsole.Instance.Output ("Scouts spawning at " + pos.x + ", " + pos.y + ", " + pos.z);
|
---|
76 |
|
---|
77 | } catch (Exception e) {
|
---|
78 | Log.Out ("Error in SpawnScouts: " + e);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | }
|
---|