| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Reflection;
|
|---|
| 4 |
|
|---|
| 5 | namespace AllocsFixes.CustomCommands
|
|---|
| 6 | {
|
|---|
| 7 | public class RepairChunkDensity : ConsoleCmdAbstract {
|
|---|
| 8 | public override string GetDescription () {
|
|---|
| 9 | return "check and optionally fix densities of a chunk";
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | public override string GetHelp () {
|
|---|
| 13 | return "Usage:\n" +
|
|---|
| 14 | " 1. repairchunkdensity <x> <z>\n" +
|
|---|
| 15 | " 2. repairchunkdensity <x> <z> fix\n" +
|
|---|
| 16 | "1. Teleports the player given by his SteamID, player name or entity id (as given by e.g. \"lpi\")\n" +
|
|---|
| 17 | " to the specified location. Use y = -1 to spawn on ground.\n" +
|
|---|
| 18 | "2. As 1, but destination given by another player which has to be online\n" +
|
|---|
| 19 | "3. Teleport the local player to the position calculated by his current position and the given offsets";
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | public override string[] GetCommands () {
|
|---|
| 23 | return new string[] { "repairchunkdensity", "rcd" };
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | public override void Execute (List<string> _params, CommandSenderInfo _senderInfo) {
|
|---|
| 27 | try {
|
|---|
| 28 | if (_params.Count < 2 || _params.Count > 3) {
|
|---|
| 29 | SdtdConsole.Instance.Output ("Wrong number of arguments, expected 2 or 3, found " + _params.Count + ".");
|
|---|
| 30 | return;
|
|---|
| 31 | } else {
|
|---|
| 32 | int x = int.MinValue;
|
|---|
| 33 | int z = int.MinValue;
|
|---|
| 34 |
|
|---|
| 35 | int.TryParse (_params [0], out x);
|
|---|
| 36 | int.TryParse (_params [1], out z);
|
|---|
| 37 |
|
|---|
| 38 | if (x == int.MinValue || z == int.MinValue) {
|
|---|
| 39 | SdtdConsole.Instance.Output ("At least one of the given coordinates is not a valid integer");
|
|---|
| 40 | return;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | Chunk c = GameManager.Instance.World.GetChunkFromWorldPos (x, 0, z) as Chunk;
|
|---|
| 44 | if (c == null) {
|
|---|
| 45 | SdtdConsole.Instance.Output ("No chunk could be loaded from the given coordinates");
|
|---|
| 46 | return;
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | if (_params.Count == 3) {
|
|---|
| 50 | if (_params [2].ToLower () != "fix") {
|
|---|
| 51 | SdtdConsole.Instance.Output ("Three parameters given but third parameter is not \"fix\"");
|
|---|
| 52 | return;
|
|---|
| 53 | }
|
|---|
| 54 | c.RepairDensities ();
|
|---|
| 55 | c.isModified = true;
|
|---|
| 56 | SdtdConsole.Instance.Output ("Chunk repaired");
|
|---|
| 57 | } else {
|
|---|
| 58 | c.CheckDensities (true);
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 | } catch (Exception e) {
|
|---|
| 62 | Log.Out ("Error in RepairChunkDensity.Execute: " + e);
|
|---|
| 63 | }
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | }
|
|---|
| 67 | }
|
|---|