[84] | 1 | using System;
|
---|
| 2 |
|
---|
| 3 | public class SetTimeReal : ConsoleCommand
|
---|
| 4 | {
|
---|
| 5 | public SetTimeReal (ConsoleSdtd cons) : base(cons)
|
---|
| 6 | {
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | public override string Description ()
|
---|
| 10 | {
|
---|
| 11 | return "set current ingame time, params: <day> <hour> <min>";
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | public override string[] Names ()
|
---|
| 15 | {
|
---|
| 16 | return new string[] { "settimereal", "str" };
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public override void Run (string[] _params)
|
---|
| 20 | {
|
---|
[103] | 21 | try {
|
---|
| 22 | if (_params.Length != 3) {
|
---|
[107] | 23 | m_Console.SendResult ("Usage: settimereal <day> <hour> <min>");
|
---|
[103] | 24 | return;
|
---|
| 25 | }
|
---|
[84] | 26 |
|
---|
[103] | 27 | int day, hour, min;
|
---|
| 28 | if (!int.TryParse (_params [0], out day)) {
|
---|
[107] | 29 | m_Console.SendResult ("Could not parse day number \"" + _params [0] + "\"");
|
---|
[103] | 30 | return;
|
---|
| 31 | }
|
---|
| 32 | if (day < 1) {
|
---|
[107] | 33 | m_Console.SendResult ("Day must be >= 1");
|
---|
[103] | 34 | return;
|
---|
| 35 | }
|
---|
| 36 | if (!int.TryParse (_params [1], out hour)) {
|
---|
[107] | 37 | m_Console.SendResult ("Could not parse hour \"" + _params [1] + "\"");
|
---|
[103] | 38 | return;
|
---|
| 39 | }
|
---|
| 40 | if (hour > 23) {
|
---|
[107] | 41 | m_Console.SendResult ("Hour must be <= 23");
|
---|
[103] | 42 | return;
|
---|
| 43 | }
|
---|
| 44 | if (!int.TryParse (_params [2], out min)) {
|
---|
[107] | 45 | m_Console.SendResult ("Could not parse minute \"" + _params [2] + "\"");
|
---|
[103] | 46 | return;
|
---|
| 47 | }
|
---|
| 48 | if (min > 59) {
|
---|
[107] | 49 | m_Console.SendResult ("Minute must be <= 59");
|
---|
[103] | 50 | return;
|
---|
| 51 | }
|
---|
| 52 | if ((day < 1) || (hour < 8 && day < 1)) {
|
---|
[107] | 53 | m_Console.SendResult ("Time may not be prior to day 1, 8:00");
|
---|
[103] | 54 | return;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | ulong time = ((ulong)(day - 1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000;
|
---|
| 58 | m_Console.gameManager.World.gameTime = time;
|
---|
[107] | 59 | m_Console.SendResult (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time));
|
---|
[103] | 60 | } catch (Exception e) {
|
---|
| 61 | Log.Out ("Error in SetTimeReal.Run: " + e);
|
---|
[84] | 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|